use of com.ctrip.framework.dal.cluster.client.base.Listener in project dal by ctripcorp.
the class ClusterConfigAdapter method load.
private void load(DalConnectionStringConfigure configure) {
ClusterConfig clusterConfig;
if (configure instanceof InvalidVariableConnectionString) {
throw new DalRuntimeException("connectionString invalid for db: " + provider.getDbName(), ((InvalidVariableConnectionString) configure).getConnectionStringException());
}
if (configure == null)
throw new RuntimeException("Get null config from mysqlapi for db: " + provider.getDbName());
if (configure instanceof MultiHostConnectionStringConfigure)
clusterConfig = buildMultiHostClusterConfig((MultiHostConnectionStringConfigure) configure);
else
clusterConfig = buildNormalClusterConfig(configure);
clusterConfigRef.getAndSet(clusterConfig);
DalConnectionStringConfigure prev = connStrConfigRef.getAndSet(configure);
if (prev != null && !equals(prev, configure))
for (Listener<ClusterConfig> listener : getListeners()) {
try {
listener.onChanged(this);
} catch (Throwable t) {
// ignore
}
}
}
Aggregations