Search in sources :

Example 1 with DefaultLocalConfigProvider

use of com.ctrip.framework.dal.cluster.client.config.DefaultLocalConfigProvider 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();
}
Also used : ClusterConfigProvider(com.ctrip.framework.dal.cluster.client.config.ClusterConfigProvider) DefaultLocalConfigProvider(com.ctrip.framework.dal.cluster.client.config.DefaultLocalConfigProvider) ClusterConfig(com.ctrip.framework.dal.cluster.client.config.ClusterConfig) BeforeClass(org.junit.BeforeClass)

Example 2 with DefaultLocalConfigProvider

use of com.ctrip.framework.dal.cluster.client.config.DefaultLocalConfigProvider 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()));
}
Also used : ClusterConfigProvider(com.ctrip.framework.dal.cluster.client.config.ClusterConfigProvider) DefaultLocalConfigProvider(com.ctrip.framework.dal.cluster.client.config.DefaultLocalConfigProvider) ClusterConfig(com.ctrip.framework.dal.cluster.client.config.ClusterConfig) Test(org.junit.Test)

Example 3 with DefaultLocalConfigProvider

use of com.ctrip.framework.dal.cluster.client.config.DefaultLocalConfigProvider 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()));
}
Also used : ClusterConfigProvider(com.ctrip.framework.dal.cluster.client.config.ClusterConfigProvider) DefaultLocalConfigProvider(com.ctrip.framework.dal.cluster.client.config.DefaultLocalConfigProvider) ClusterConfig(com.ctrip.framework.dal.cluster.client.config.ClusterConfig) Test(org.junit.Test)

Example 4 with DefaultLocalConfigProvider

use of com.ctrip.framework.dal.cluster.client.config.DefaultLocalConfigProvider 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());
}
Also used : DataSourceIdentity(com.ctrip.platform.dal.dao.datasource.DataSourceIdentity) Connection(java.sql.Connection) Cluster(com.ctrip.framework.dal.cluster.client.Cluster) ClusterConfigProvider(com.ctrip.framework.dal.cluster.client.config.ClusterConfigProvider) ConnectionAction(com.ctrip.platform.dal.dao.client.ConnectionAction) DefaultLocalConfigProvider(com.ctrip.framework.dal.cluster.client.config.DefaultLocalConfigProvider) ClusterConfig(com.ctrip.framework.dal.cluster.client.config.ClusterConfig) DalConnectionLocator(com.ctrip.platform.dal.dao.client.DalConnectionLocator) Test(org.junit.Test)

Aggregations

ClusterConfig (com.ctrip.framework.dal.cluster.client.config.ClusterConfig)4 ClusterConfigProvider (com.ctrip.framework.dal.cluster.client.config.ClusterConfigProvider)4 DefaultLocalConfigProvider (com.ctrip.framework.dal.cluster.client.config.DefaultLocalConfigProvider)4 Test (org.junit.Test)3 Cluster (com.ctrip.framework.dal.cluster.client.Cluster)1 ConnectionAction (com.ctrip.platform.dal.dao.client.ConnectionAction)1 DalConnectionLocator (com.ctrip.platform.dal.dao.client.DalConnectionLocator)1 DataSourceIdentity (com.ctrip.platform.dal.dao.datasource.DataSourceIdentity)1 Connection (java.sql.Connection)1 BeforeClass (org.junit.BeforeClass)1