Search in sources :

Example 6 with TestMetaServer

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

the class AbstractMetaServerClusterTest method createMetaServers.

protected void createMetaServers(int serverCount) throws Exception {
    for (int i = 0; i < serverCount; i++) {
        int port = portUsable(defaultMetaServerPort());
        TestMetaServer testMetaServer = createMetaServer(i + 1, port, zkPort);
        add(testMetaServer);
    }
}
Also used : TestMetaServer(com.ctrip.xpipe.redis.meta.server.TestMetaServer)

Example 7 with TestMetaServer

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

the class AbstractMetaServerClusterTest method createMetaServer.

protected TestMetaServer createMetaServer(int index, int port, int zkPort, String configFile) throws Exception {
    TestMetaServer testMetaServer = new TestMetaServer(index, port, zkPort, configFile);
    testMetaServer.initialize();
    testMetaServer.start();
    return testMetaServer;
}
Also used : TestMetaServer(com.ctrip.xpipe.redis.meta.server.TestMetaServer)

Example 8 with TestMetaServer

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

the class ClusterServersApiTest method testClusterChanged.

@Test
public void testClusterChanged() throws Exception {
    createMetaServers(metaServerCount);
    sleep(waitForMetaServerOkTime);
    logger.info(remarkableMessage("[testClusterChanged][begin send cluster change message]"));
    ClusterMeta clusterMeta = randomCluster();
    for (TestMetaServer server : getServers()) {
        String path = META_SERVER_SERVICE.CLUSTER_CHANGE.getRealPath(server.getAddress());
        logger.info("[testClusterChanged]{}", path);
        restTemplate.postForEntity(path, clusterMeta, String.class, clusterMeta.getId());
        restTemplate.put(path, clusterMeta, String.class, clusterMeta.getId());
        restTemplate.delete(path, clusterMeta.getId());
    }
}
Also used : TestMetaServer(com.ctrip.xpipe.redis.meta.server.TestMetaServer) ClusterMeta(com.ctrip.xpipe.redis.core.entity.ClusterMeta) Test(org.junit.Test)

Example 9 with TestMetaServer

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

the class ClusterServersApiTest method testMakeMasterReadOnly.

@Test
public void testMakeMasterReadOnly() throws Exception {
    createMetaServers(metaServerCount);
    sleep(waitForMetaServerOkTime);
    logger.info(remarkableMessage("[testMakeMasterReadOnly][begin send make master read only message]"));
    for (TestMetaServer server : getServers()) {
        logger.info("[testChangePrimaryDcCheck]{}", server.getAddress());
        MetaServerConsoleService consoleService = new DefaultMetaServerConsoleService(server.getAddress());
        MetaServerConsoleService.PreviousPrimaryDcMessage message = consoleService.makeMasterReadOnly(getClusterId(), getShardId(), true);
        logger.info("[testMakeMasterReadOnly][true]{}", message);
        message = consoleService.makeMasterReadOnly(getClusterId(), getShardId(), false);
        logger.info("[testMakeMasterReadOnly][false]{}", message);
    }
}
Also used : TestMetaServer(com.ctrip.xpipe.redis.meta.server.TestMetaServer) 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 10 with TestMetaServer

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

the class ClusterServersApiTest method testDoChangePrimaryDc.

@Test
public void testDoChangePrimaryDc() throws Exception {
    createMetaServers(metaServerCount);
    sleep(waitForMetaServerOkTime);
    logger.info(remarkableMessage("[testDoChangePrimaryDc][begin send change primary dc message]"));
    for (TestMetaServer server : getServers()) {
        logger.info(remarkableMessage("[testDoChangePrimaryDc][jq]"));
        MetaServerConsoleService.PrimaryDcChangeRequest request = new MetaServerConsoleService.PrimaryDcChangeRequest();
        request.setMasterInfo(new MasterInfo(RunidGenerator.DEFAULT.generateRunid(), 100L));
        MetaServerConsoleService consoleService = new DefaultMetaServerConsoleService(server.getAddress());
        PrimaryDcChangeMessage message = consoleService.doChangePrimaryDc(getClusterId(), getShardId(), "jq", request);
        logger.info("{}", message);
        logger.info(remarkableMessage("[testDoChangePrimaryDc][oy]"));
        message = consoleService.doChangePrimaryDc(getClusterId(), getShardId(), "oy", request);
        logger.info("{}", message);
    }
}
Also used : MasterInfo(com.ctrip.xpipe.redis.core.protocal.pojo.MasterInfo) TestMetaServer(com.ctrip.xpipe.redis.meta.server.TestMetaServer) 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) PrimaryDcChangeMessage(com.ctrip.xpipe.redis.core.metaserver.MetaServerConsoleService.PrimaryDcChangeMessage) 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