Search in sources :

Example 6 with MasterInfo

use of com.ctrip.xpipe.redis.core.protocal.pojo.MasterInfo in project x-pipe by ctripcorp.

the class BecomePrimaryActionTest method test.

@Test
public void test() throws Exception {
    BecomePrimaryAction becomePrimaryAction = new BecomePrimaryAction(dcMetaCache, currentMetaManager, sentinelManager, offsetWaiter, new ExecutionLog(getTestName()), getXpipeNettyClientKeyedObjectPool(), newMasterChooser, scheduled, executors);
    PrimaryDcChangeMessage message = becomePrimaryAction.changePrimaryDc(getClusterId(), getShardId(), newPrimaryDc, new MasterInfo());
    logger.info("{}", message);
}
Also used : MasterInfo(com.ctrip.xpipe.redis.core.protocal.pojo.MasterInfo) ExecutionLog(com.ctrip.xpipe.redis.meta.server.dcchange.ExecutionLog) BecomePrimaryAction(com.ctrip.xpipe.redis.meta.server.dcchange.impl.BecomePrimaryAction) PrimaryDcChangeMessage(com.ctrip.xpipe.redis.core.metaserver.MetaServerConsoleService.PrimaryDcChangeMessage) Test(org.junit.Test) AbstractMetaServerTest(com.ctrip.xpipe.redis.meta.server.AbstractMetaServerTest)

Example 7 with MasterInfo

use of com.ctrip.xpipe.redis.core.protocal.pojo.MasterInfo in project x-pipe by ctripcorp.

the class DefaultOffsetwaiterTest method testWaitTimeout.

@Test
public void testWaitTimeout() throws Exception {
    String masterReplId = RunidGenerator.DEFAULT.generateRunid();
    Long masterOffset = 10000L;
    MasterInfo masterInfo = new MasterInfo(masterReplId, masterOffset);
    startServer(port, new Callable<String>() {

        private Long offset = masterOffset - 200;

        @Override
        public String call() throws Exception {
            return toRedisProtocalString("# Replication\r\n" + "role:slave\r\n" + "master_host:127.0.0.1\r\n" + "master_port:6379\r\n" + "master_link_status:up\r\n" + "master_last_io_seconds_ago:8\r\n" + "master_sync_in_progress:0\r\n" + "slave_repl_offset:" + offset + "\r\n" + "slave_priority:100\r\n" + "slave_read_only:1\r\n" + "connected_slaves:0\r\n" + "master_replid:" + masterReplId + "\r\n" + "master_replid2:0000000000000000000000000000000000000000\r\n" + "master_repl_offset:" + offset + "\r\n" + "second_repl_offset:-1\r\n" + "repl_backlog_active:1\r\n" + "repl_backlog_size:1048576\r\n" + "repl_backlog_first_byte_offset:1\r\n" + "repl_backlog_histlen:13202");
        }
    });
    Assert.assertFalse(offsetwaiter.tryWaitfor(new HostPort(host, port), masterInfo, executionLog));
}
Also used : MasterInfo(com.ctrip.xpipe.redis.core.protocal.pojo.MasterInfo) HostPort(com.ctrip.xpipe.endpoint.HostPort) Test(org.junit.Test) AbstractMetaServerTest(com.ctrip.xpipe.redis.meta.server.AbstractMetaServerTest)

Example 8 with MasterInfo

use of com.ctrip.xpipe.redis.core.protocal.pojo.MasterInfo in project x-pipe by ctripcorp.

the class DefaultOffsetwaiterTest method testWaitAndSucceed2_8_19.

@Test
public void testWaitAndSucceed2_8_19() throws Exception {
    String masterReplId = RunidGenerator.DEFAULT.generateRunid();
    Long masterOffset = 10000L;
    MasterInfo masterInfo = new MasterInfo(masterReplId, masterOffset);
    startServer(port, new Callable<String>() {

        private Long offset = masterOffset - 200;

        @Override
        public String call() throws Exception {
            offset += 100;
            return toRedisProtocalString("# Replication\r\n" + "role:slave\r\n" + "master_host:127.0.0.1\r\n" + "master_port:6379\r\n" + "master_link_status:up\r\n" + "master_last_io_seconds_ago:1\r\n" + "master_sync_in_progress:0\r\n" + "slave_repl_offset:" + offset + "\r\n" + "slave_priority:100\r\n" + "slave_read_only:1\r\n" + "connected_slaves:0\r\n" + "master_repl_offset:0\r\n" + "repl_backlog_active:0\r\n" + "repl_backlog_size:104857600\r\n" + "repl_backlog_first_byte_offset:0\r\n" + "repl_backlog_histlen:0");
        }
    });
    Assert.assertTrue(offsetwaiter.tryWaitfor(new HostPort(host, port), masterInfo, executionLog));
}
Also used : MasterInfo(com.ctrip.xpipe.redis.core.protocal.pojo.MasterInfo) HostPort(com.ctrip.xpipe.endpoint.HostPort) Test(org.junit.Test) AbstractMetaServerTest(com.ctrip.xpipe.redis.meta.server.AbstractMetaServerTest)

Example 9 with MasterInfo

use of com.ctrip.xpipe.redis.core.protocal.pojo.MasterInfo in project x-pipe by ctripcorp.

the class DefaultOffsetwaiterTest method testWaitforMaster.

@Test
public void testWaitforMaster() throws Exception {
    MasterInfo masterInfo = new MasterInfo(RunidGenerator.DEFAULT.generateRunid(), 1L);
    startServer(port, toRedisProtocalString("# Replication\r\n" + "role:master\r\n" + "connected_slaves:1\r\n" + "slave0:ip=127.0.0.1,port=6479,state=online,offset=12936,lag=0\r\n" + "master_replid:ebe8dc36b4a9901af79ac117fa55d45e3dbb92a1\r\n" + "master_replid2:0000000000000000000000000000000000000000\r\n" + "master_repl_offset:12936\r\n" + "second_repl_offset:-1\r\n" + "repl_backlog_active:1\r\n" + "repl_backlog_size:1048576\r\n" + "repl_backlog_first_byte_offset:1\r\n" + "repl_backlog_histlen:12936"));
    Assert.assertFalse(offsetwaiter.tryWaitfor(new HostPort(host, port), masterInfo, executionLog));
}
Also used : MasterInfo(com.ctrip.xpipe.redis.core.protocal.pojo.MasterInfo) HostPort(com.ctrip.xpipe.endpoint.HostPort) Test(org.junit.Test) AbstractMetaServerTest(com.ctrip.xpipe.redis.meta.server.AbstractMetaServerTest)

Example 10 with MasterInfo

use of com.ctrip.xpipe.redis.core.protocal.pojo.MasterInfo in project x-pipe by ctripcorp.

the class DefaultOffsetwaiterTest method testWaitAndSucceed.

@Test
public void testWaitAndSucceed() throws Exception {
    String masterReplId = RunidGenerator.DEFAULT.generateRunid();
    Long masterOffset = 10000L;
    MasterInfo masterInfo = new MasterInfo(masterReplId, masterOffset);
    startServer(port, new Callable<String>() {

        private Long offset = masterOffset - 200;

        @Override
        public String call() throws Exception {
            offset += 100;
            return toRedisProtocalString("# Replication\r\n" + "role:slave\r\n" + "master_host:127.0.0.1\r\n" + "master_port:6379\r\n" + "master_link_status:up\r\n" + "master_last_io_seconds_ago:8\r\n" + "master_sync_in_progress:0\r\n" + "slave_repl_offset:" + offset + "\r\n" + "slave_priority:100\r\n" + "slave_read_only:1\r\n" + "connected_slaves:0\r\n" + "master_replid:" + masterReplId + "\r\n" + "master_replid2:0000000000000000000000000000000000000000\r\n" + "master_repl_offset:" + offset + "\r\n" + "second_repl_offset:-1\r\n" + "repl_backlog_active:1\r\n" + "repl_backlog_size:1048576\r\n" + "repl_backlog_first_byte_offset:1\r\n" + "repl_backlog_histlen:13202");
        }
    });
    Assert.assertTrue(offsetwaiter.tryWaitfor(new HostPort(host, port), masterInfo, executionLog));
}
Also used : MasterInfo(com.ctrip.xpipe.redis.core.protocal.pojo.MasterInfo) HostPort(com.ctrip.xpipe.endpoint.HostPort) Test(org.junit.Test) AbstractMetaServerTest(com.ctrip.xpipe.redis.meta.server.AbstractMetaServerTest)

Aggregations

MasterInfo (com.ctrip.xpipe.redis.core.protocal.pojo.MasterInfo)12 Test (org.junit.Test)9 AbstractMetaServerTest (com.ctrip.xpipe.redis.meta.server.AbstractMetaServerTest)7 HostPort (com.ctrip.xpipe.endpoint.HostPort)6 PrimaryDcChangeMessage (com.ctrip.xpipe.redis.core.metaserver.MetaServerConsoleService.PrimaryDcChangeMessage)4 ExecutionLog (com.ctrip.xpipe.redis.meta.server.dcchange.ExecutionLog)4 MetaServerConsoleService (com.ctrip.xpipe.redis.core.metaserver.MetaServerConsoleService)2 RedisInfo (com.ctrip.xpipe.redis.core.protocal.pojo.RedisInfo)2 BecomeBackupAction (com.ctrip.xpipe.redis.meta.server.dcchange.impl.BecomeBackupAction)2 BecomePrimaryAction (com.ctrip.xpipe.redis.meta.server.dcchange.impl.BecomePrimaryAction)2 RedisMeta (com.ctrip.xpipe.redis.core.entity.RedisMeta)1 DefaultMetaServerConsoleService (com.ctrip.xpipe.redis.core.metaserver.impl.DefaultMetaServerConsoleService)1 InfoReplicationComplementCommand (com.ctrip.xpipe.redis.core.protocal.cmd.InfoReplicationComplementCommand)1 SlaveInfo (com.ctrip.xpipe.redis.core.protocal.pojo.SlaveInfo)1 TestMetaServer (com.ctrip.xpipe.redis.meta.server.TestMetaServer)1 InetSocketAddress (java.net.InetSocketAddress)1