use of com.ctrip.xpipe.endpoint.HostPort 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.endpoint.HostPort 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));
}
use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class DefaultOffsetwaiterTest method testWaitforSlaveDifferentReplid.
@Test
public void testWaitforSlaveDifferentReplid() throws Exception {
MasterInfo masterInfo = new MasterInfo(RunidGenerator.DEFAULT.generateRunid(), 1L);
startServer(port, 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:13202\r\n" + "slave_priority:100\r\n" + "slave_read_only:1\r\n" + "connected_slaves:0\r\n" + "master_replid:ebe8dc36b4a9901af79ac117fa55d45e3dbb92a1\r\n" + "master_replid2:0000000000000000000000000000000000000000\r\n" + "master_repl_offset:13202\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.endpoint.HostPort in project x-pipe by ctripcorp.
the class DefaultBacklogActiveCollectorTest method analysisInfoReplication2.
@Test
public void analysisInfoReplication2() throws Exception {
doNothing().when(alertManager).alert(any(), any(), any(), any(), any());
Assert.assertNotNull(redisConfManager);
RedisConf redisConf = new RedisConf(new HostPort(), "", "");
redisConf.setXredisVersion("1.0.0");
redisConf.setRedisVersion("4.0.1");
when(redisConfManager.findOrCreateConfig("127.0.0.1", 6379)).thenReturn(redisConf);
collector.analysisInfoReplication("role:slave\n" + "master_host:10.2.54.233\n" + "master_port:7381\n" + "master_link_status:up\n" + "master_last_io_seconds_ago:0\n" + "master_sync_in_progress:1\n" + "slave_repl_offset:1439009182\n" + "slave_priority:100\n" + "slave_read_only:1\n" + "connected_slaves:0\n" + "master_replid:204b8d599765dd3dead6faa089aeb77d9d8726f5\n" + "master_replid2:0000000000000000000000000000000000000000\n" + "master_repl_offset:1439009182\n" + "second_repl_offset:-1\n" + "repl_backlog_active:0\n" + "repl_backlog_size:104857600\n" + "repl_backlog_first_byte_offset:1340037212\n" + "repl_backlog_histlen:98971971", "cluster", "shard", new HostPort("127.0.0.1", 6379));
verify(alertManager, never()).alert(any(), any(), any(), any(), any());
}
use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class DefaultSentinelMonitorsCheckTest method checkSentinel.
@Test
public void checkSentinel() throws Exception {
when(metaCache.findClusterShardBySentinelMonitor(any())).thenReturn(null);
checker.checkSentinel(new SentinelMeta().setAddress("127.0.0.1:5000,127.0.0.1:5001,127.0.0.1:5002"), new HostPort("127.0.0.1", 5000));
verify(alertManager, atLeastOnce()).alert(eq(null), eq(null), eq(null), eq(ALERT_TYPE.SENTINEL_MONITOR_INCONSIS), anyString());
verify(sentinelManager, atLeastOnce()).removeSentinelMonitor(any(), any());
}
Aggregations