Search in sources :

Example 1 with TestZkClient

use of com.ctrip.xpipe.zk.impl.TestZkClient in project x-pipe by ctripcorp.

the class AbstractMetaServerContextTest method createZkClient.

public ZkClient createZkClient() throws Exception {
    try {
        TestZkClient zkClient = new TestZkClient();
        zkClient.setZkAddress(zkAddress);
        zkClient.initialize();
        zkClient.start();
        add(zkClient);
        return zkClient;
    } catch (Exception e) {
        logger.info(e.getMessage());
        return null;
    }
}
Also used : TestZkClient(com.ctrip.xpipe.zk.impl.TestZkClient)

Example 2 with TestZkClient

use of com.ctrip.xpipe.zk.impl.TestZkClient in project x-pipe by ctripcorp.

the class TestMetaServer method doStart.

@Override
public void doStart() throws Exception {
    System.setProperty(DefaultDcMetaCache.MEMORY_META_SERVER_DAO_KEY, configFile);
    System.setProperty("TOTAL_SLOTS", String.valueOf(total_slots));
    SpringApplication application = new SpringApplication(TestMetaServer.class);
    application.setBannerMode(Mode.OFF);
    application.setEnvironment(createEnvironment());
    context = application.run(new String[] {});
    TestZkClient client = context.getBean(TestZkClient.class);
    DefaultZkConfig zkConfig = new DefaultZkConfig();
    zkConfig.setZkSessionTimeoutMillis(zkSessionTimeoutMillis);
    client.setZkConfig(zkConfig);
    client.setZkAddress(zkConnectionStr);
    UnitTestServerConfig config = context.getBean(UnitTestServerConfig.class);
    config.setZkAddress(zkConnectionStr);
    config.setMetaServerId(serverId);
    config.setMetaServerPort(serverPort);
    ArrangeTaskTrigger arrangeTaskTrigger = context.getBean(ArrangeTaskTrigger.class);
    arrangeTaskTrigger.setWaitForRestartTimeMills(waitForRestartTimeMills);
    manager = context.getBean(SpringComponentRegistry.class);
    manager.initialize();
    manager.start();
}
Also used : ArrangeTaskTrigger(com.ctrip.xpipe.redis.meta.server.cluster.impl.ArrangeTaskTrigger) SpringComponentRegistry(com.ctrip.xpipe.lifecycle.SpringComponentRegistry) SpringApplication(org.springframework.boot.SpringApplication) UnitTestServerConfig(com.ctrip.xpipe.redis.meta.server.config.UnitTestServerConfig) DefaultZkConfig(com.ctrip.xpipe.zk.impl.DefaultZkConfig) TestZkClient(com.ctrip.xpipe.zk.impl.TestZkClient)

Example 3 with TestZkClient

use of com.ctrip.xpipe.zk.impl.TestZkClient in project x-pipe by ctripcorp.

the class TestProfile method getZkClient.

@Bean
public ZkClient getZkClient() throws Exception {
    TestZkClient zkClient = new TestZkClient();
    zkClient.initialize();
    zkClient.start();
    return zkClient;
}
Also used : TestZkClient(com.ctrip.xpipe.zk.impl.TestZkClient) Bean(org.springframework.context.annotation.Bean)

Example 4 with TestZkClient

use of com.ctrip.xpipe.zk.impl.TestZkClient in project x-pipe by ctripcorp.

the class AbstractMetaServerContextTest method beforeAbstractMetaServerContextTest.

@Before
public void beforeAbstractMetaServerContextTest() throws Exception {
    arrangeTaskStart(false);
    int zkPort = getTestZkPort();
    if (isStartZk()) {
        startZk(zkPort);
    }
    zkAddress = String.format("localhost:%d", zkPort);
    try {
        TestZkClient client = getBean(TestZkClient.class);
        client.setZkAddress(zkAddress);
    } catch (IllegalStateException e) {
    // not found, if not
    }
}
Also used : TestZkClient(com.ctrip.xpipe.zk.impl.TestZkClient) Before(org.junit.Before)

Example 5 with TestZkClient

use of com.ctrip.xpipe.zk.impl.TestZkClient in project x-pipe by ctripcorp.

the class TestProfile method getZkClient.

@Bean
public ZkClient getZkClient(ZkTestServer zkTestServer) throws Exception {
    TestZkClient zkClient = new TestZkClient();
    zkClient.setZkAddress(String.format("%s:%d", "localhost", zkTestServer.getZkPort()));
    zkClient.initialize();
    zkClient.start();
    logger.info("[getZkClient][test]");
    return zkClient;
}
Also used : TestZkClient(com.ctrip.xpipe.zk.impl.TestZkClient) Bean(org.springframework.context.annotation.Bean)

Aggregations

TestZkClient (com.ctrip.xpipe.zk.impl.TestZkClient)5 Bean (org.springframework.context.annotation.Bean)2 SpringComponentRegistry (com.ctrip.xpipe.lifecycle.SpringComponentRegistry)1 ArrangeTaskTrigger (com.ctrip.xpipe.redis.meta.server.cluster.impl.ArrangeTaskTrigger)1 UnitTestServerConfig (com.ctrip.xpipe.redis.meta.server.config.UnitTestServerConfig)1 DefaultZkConfig (com.ctrip.xpipe.zk.impl.DefaultZkConfig)1 Before (org.junit.Before)1 SpringApplication (org.springframework.boot.SpringApplication)1