Search in sources :

Example 1 with TestMetaServer

use of com.ctrip.xpipe.redis.meta.server.TestMetaServer in project x-pipe by ctripcorp.

the class ClusterServersApiTest method testChangePrimaryDcCheck.

@Test
public void testChangePrimaryDcCheck() throws Exception {
    createMetaServers(metaServerCount);
    sleep(waitForMetaServerOkTime);
    logger.info(remarkableMessage("[testChangePrimaryDcCheck][begin send primary dc check message]"));
    for (TestMetaServer server : getServers()) {
        logger.info("[testChangePrimaryDcCheck]{}", server.getAddress());
        MetaServerConsoleService consoleService = new DefaultMetaServerConsoleService(server.getAddress());
        PrimaryDcCheckMessage message = consoleService.changePrimaryDcCheck(getClusterId(), getShardId(), "newPrimaryDc");
        logger.info("[testChangePrimaryDcCheck]{}, {}", server.getAddress(), message);
    }
}
Also used : TestMetaServer(com.ctrip.xpipe.redis.meta.server.TestMetaServer) PrimaryDcCheckMessage(com.ctrip.xpipe.redis.core.metaserver.MetaServerConsoleService.PrimaryDcCheckMessage) MetaServerConsoleService(com.ctrip.xpipe.redis.core.metaserver.MetaServerConsoleService) DefaultMetaServerConsoleService(com.ctrip.xpipe.redis.core.metaserver.impl.DefaultMetaServerConsoleService) DefaultMetaServerConsoleService(com.ctrip.xpipe.redis.core.metaserver.impl.DefaultMetaServerConsoleService) Test(org.junit.Test)

Example 2 with TestMetaServer

use of com.ctrip.xpipe.redis.meta.server.TestMetaServer in project x-pipe by ctripcorp.

the class ClusterServersApiTest method testGetActiveKeeper.

@Test
public void testGetActiveKeeper() throws Exception {
    createMetaServers(metaServerCount);
    sleep(waitForMetaServerOkTime);
    logger.info(remarkableMessage("[testUpdateUpstream][begin send upstream update message]"));
    for (TestMetaServer server : getServers()) {
        String path = META_SERVER_SERVICE.GET_ACTIVE_KEEPER.getRealPath(server.getAddress());
        logger.info("[testGetActiveKeeper]{}", path);
        KeeperMeta keeperMeta = restTemplate.getForObject(path, KeeperMeta.class, "cluster1", "shard1");
        logger.info("[testGetActiveKeeper]{}", keeperMeta);
    }
}
Also used : TestMetaServer(com.ctrip.xpipe.redis.meta.server.TestMetaServer) KeeperMeta(com.ctrip.xpipe.redis.core.entity.KeeperMeta) Test(org.junit.Test)

Example 3 with TestMetaServer

use of com.ctrip.xpipe.redis.meta.server.TestMetaServer in project x-pipe by ctripcorp.

the class AbstractFullIntegrated method startMetaServer.

protected void startMetaServer(MetaServerMeta metaServerMeta, ZkServerMeta zkServerMeta, DcMeta dcMeta) throws Exception {
    logger.info(remarkableMessage("[startMetaServer]{}, {}"), metaServerMeta, zkServerMeta);
    DcInfo dcInfo = getDcInfos().get(dcMeta.getId());
    TestMetaServer testMetaServer = new TestMetaServer(dcInfo.getIncreaseServerId(), metaServerMeta.getPort(), zkServerMeta.getAddress(), getXpipeMetaConfigFile());
    testMetaServer.initialize();
    testMetaServer.start();
    add(testMetaServer);
    dcInfo.setApplicationContext(testMetaServer.getContext());
}
Also used : DcInfo(com.ctrip.xpipe.redis.integratedtest.DcInfo) TestMetaServer(com.ctrip.xpipe.redis.meta.server.TestMetaServer)

Example 4 with TestMetaServer

use of com.ctrip.xpipe.redis.meta.server.TestMetaServer in project x-pipe by ctripcorp.

the class ClusterServerShardingTest method testInit.

@Test
public void testInit() throws Exception {
    createMetaServers(serverCount);
    sleep(sleepForBalance);
    for (TestMetaServer server : getServers()) {
        ApplicationContext context = server.getContext();
        SlotManager slotManager = context.getBean(SlotManager.class);
        slotManager.refresh();
        logger.info("[testInit]{}", server);
        AssertBalance(slotManager);
    }
}
Also used : TestMetaServer(com.ctrip.xpipe.redis.meta.server.TestMetaServer) ApplicationContext(org.springframework.context.ApplicationContext) Test(org.junit.Test)

Example 5 with TestMetaServer

use of com.ctrip.xpipe.redis.meta.server.TestMetaServer in project x-pipe by ctripcorp.

the class ClusterServerShardingTest method testShutdownOther.

@Test
public void testShutdownOther() throws Exception {
    createMetaServers(serverCount);
    sleep(sleepForBalance);
    for (TestMetaServer server : getServers()) {
        if (!server.isLeader()) {
            logger.info(remarkableMessage("[testShutdownOther][begin]{}"), server);
            server.stop();
            logger.info(remarkableMessage("[testShutdownOther][ end ]{}"), server);
            break;
        }
    }
    sleep(TestMetaServer.getWaitforrestarttimemills() + 1000);
    TestMetaServer leader = getLeader();
    SlotManager slotManager = leader.getContext().getBean(SlotManager.class);
    slotManager.refresh();
    Assert.assertEquals(serverCount - 1, slotManager.allServers().size());
    AssertBalance(slotManager);
}
Also used : TestMetaServer(com.ctrip.xpipe.redis.meta.server.TestMetaServer) Test(org.junit.Test)

Aggregations

TestMetaServer (com.ctrip.xpipe.redis.meta.server.TestMetaServer)14 Test (org.junit.Test)11 MetaServerConsoleService (com.ctrip.xpipe.redis.core.metaserver.MetaServerConsoleService)3 DefaultMetaServerConsoleService (com.ctrip.xpipe.redis.core.metaserver.impl.DefaultMetaServerConsoleService)3 ClusterMeta (com.ctrip.xpipe.redis.core.entity.ClusterMeta)1 KeeperMeta (com.ctrip.xpipe.redis.core.entity.KeeperMeta)1 PrimaryDcChangeMessage (com.ctrip.xpipe.redis.core.metaserver.MetaServerConsoleService.PrimaryDcChangeMessage)1 PrimaryDcCheckMessage (com.ctrip.xpipe.redis.core.metaserver.MetaServerConsoleService.PrimaryDcCheckMessage)1 MasterInfo (com.ctrip.xpipe.redis.core.protocal.pojo.MasterInfo)1 DcInfo (com.ctrip.xpipe.redis.integratedtest.DcInfo)1 AbstractMetaServerClusterTest (com.ctrip.xpipe.redis.meta.server.cluster.AbstractMetaServerClusterTest)1 ApplicationContext (org.springframework.context.ApplicationContext)1