use of com.ctrip.framework.dal.cluster.client.config.ClusterConfig in project dal by ctripcorp.
the class DefaultClusterTest method init.
@BeforeClass
public static void init() {
ClusterConfigProvider provider = new DefaultLocalConfigProvider("demo-cluster");
// todo-lhj xiu dance
ClusterConfig config = provider.getClusterConfig(mockCustomizedOption());
cluster = config.generate();
}
use of com.ctrip.framework.dal.cluster.client.config.ClusterConfig in project dal by ctripcorp.
the class DefaultLocalConfigProviderTest method test.
@Test
public void test() {
ClusterConfigProvider provider = new DefaultLocalConfigProvider("demo-cluster");
// todo-lhj xiu dan ce
ClusterConfig config = provider.getClusterConfig(DefaultClusterTest.mockCustomizedOption());
LOGGER.info(String.format("cluster config: %s", config.toString()));
}
use of com.ctrip.framework.dal.cluster.client.config.ClusterConfig in project dal by ctripcorp.
the class ClusterConfigParserTest method test.
@Test
public void test() {
ClusterConfigProvider provider = new DefaultLocalConfigProvider("TestCluster");
// todo-lhj
ClusterConfig config = provider.getClusterConfig(new DefaultDalConfigCustomizedOption());
LOGGER.info(String.format("cluster config: %s", config.toString()));
}
use of com.ctrip.framework.dal.cluster.client.config.ClusterConfig in project dal by ctripcorp.
the class ClusterDatabaseSetTest method testNonShardingCluster.
@Test
public void testNonShardingCluster() {
ClusterConfigProvider provider = new DefaultLocalConfigProvider("NonShardingCluster");
// todo-lhj
ClusterConfig config = provider.getClusterConfig(new DefaultDalConfigCustomizedOption());
Cluster cluster = config.generate();
ClusterDatabaseSet databaseSet = new ClusterDatabaseSet("NonShardingCluster", cluster, new DalConnectionLocator() {
@Override
public void setup(Collection<DatabaseSet> databaseSets) {
}
@Override
public Connection getConnection(String name) throws Exception {
return null;
}
@Override
public Connection getConnection(String name, ConnectionAction action) throws Exception {
return null;
}
@Override
public Connection getConnection(DataSourceIdentity id) throws Exception {
return null;
}
@Override
public Connection getConnection(DataSourceIdentity id, ConnectionAction action) throws Exception {
return null;
}
@Override
public IntegratedConfigProvider getIntegratedConfigProvider() {
return null;
}
@Override
public void setupCluster(Cluster cluster) {
}
@Override
public void uninstallCluster(Cluster cluster) {
}
@Override
public void initialize(Map<String, String> settings) throws Exception {
}
});
Assert.assertFalse(databaseSet.isShardingSupported());
Assert.assertEquals(1, databaseSet.getMasterDbs().size());
Assert.assertEquals(0, databaseSet.getSlaveDbs().size());
}
use of com.ctrip.framework.dal.cluster.client.config.ClusterConfig 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