private synchronized void loadUser(final String app) throws ExecutionException, TddlException { String dataId = DATAID_PREFIX + this.cluster + "." + app + DATAID_SUFFIX; ConfigDataHandler cdh = getConfigDataHandler(app, dataId); String config = cdh.getData(); if (StringUtil.isEmpty(config)) { cdhs.invalidate(dataId); cdh.destroy(); // 重新拿一下新的dataId String newDataId = DATAID_PREFIX + app + DATAID_SUFFIX; cdh = getConfigDataHandler(app, newDataId); config = cdh.getData(); } this.parseConfig(dataId, app, config); }
private synchronized void unLoadUser(final String app) throws TddlException { String dataId = DATAID_PREFIX + this.cluster + "." + app + DATAID_SUFFIX; ConfigDataHandler cdh = cdhs.getIfPresent(dataId); if (cdh != null) { cdh.destroy(); cdhs.invalidate(dataId); } String newDataId = DATAID_PREFIX + app + DATAID_SUFFIX; cdh = cdhs.getIfPresent(newDataId); if (cdh != null) { cdh.destroy(); cdhs.invalidate(dataId); } users.remove(app); }
@Override protected void doDestroy() throws TddlException { for (ConfigDataHandler cdh : cdhs.asMap().values()) { try { cdh.destroy(); } catch (Exception e) { // ignore } } for (SchemaConfig schema : schemas.values()) { TDataSource dataSource = schema.getDataSource(); try { if (dataSource != null) { dataSource.destroy(); } } catch (Exception e) { // ignore } } }
/** * Do not add cluster to keep compatible with old tddl * * @param app * @throws ExecutionException * @throws TddlException */ private void loadQuarantine(String app) throws ExecutionException, TddlException { String dataId = DATAID_PREFIX + app + QUARANTINE_SURFIX; ConfigDataHandler cdh = getQuarantineDataHandler(app, dataId); String config = cdh.getData(); this.parseQuarantineConfig(dataId, app, config); }