Search in sources :

Example 1 with Listener

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
            }
        }
}
Also used : DalRuntimeException(com.ctrip.platform.dal.exceptions.DalRuntimeException) DalRuntimeException(com.ctrip.platform.dal.exceptions.DalRuntimeException) Listener(com.ctrip.framework.dal.cluster.client.base.Listener) ClusterConfig(com.ctrip.framework.dal.cluster.client.config.ClusterConfig)

Aggregations

Listener (com.ctrip.framework.dal.cluster.client.base.Listener)1 ClusterConfig (com.ctrip.framework.dal.cluster.client.config.ClusterConfig)1 DalRuntimeException (com.ctrip.platform.dal.exceptions.DalRuntimeException)1