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);
}
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));
}
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));
}
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));
}
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));
}
Aggregations