Search in sources :

Example 6 with RedisConf

use of com.ctrip.xpipe.redis.console.health.redisconf.RedisConf in project x-pipe by ctripcorp.

the class DefaultBacklogActiveCollector method analysisInfoReplication.

@VisibleForTesting
void analysisInfoReplication(String infoReplication, String cluster, String shard, HostPort hostPort) {
    boolean isBacklogActive = RedisInfoUtils.getReplBacklogActive(infoReplication);
    String role = RedisInfoUtils.getRole(infoReplication);
    if (!isBacklogActive && Server.SERVER_ROLE.SLAVE.sameRole(role)) {
        // master last io seconds ago == server.master ? unix time - last ! -1
        if (RedisInfoUtils.isMasterSyncInProgress(infoReplication) || RedisInfoUtils.getMasterLastIoSecondsAgo(infoReplication) == -1) {
            logger.info("[analysisInfoReplication] master sync in progress, waiting for {}, {}, {}", cluster, shard, hostPort);
            return;
        }
        RedisConf redisConf = redisConfManager.findOrCreateConfig(hostPort.getHost(), hostPort.getPort());
        if ((!StringUtil.isEmpty(redisConf.getRedisVersion()) && StringUtil.compareVersion(redisConf.getRedisVersion(), "4.0.0") >= 0) || !StringUtil.isEmpty(redisConf.getXredisVersion())) {
            String message = "Redis replication backlog not active";
            alertManager.alert(cluster, shard, hostPort, ALERT_TYPE.REPL_BACKLOG_NOT_ACTIVE, message);
        } else {
            logger.warn("[analysisInfoReplication]Redis {}-{}-{} backlog_active is 0, " + "but redis is not xredis or with version greater than 4.0.0", cluster, shard, hostPort);
        }
    }
}
Also used : RedisConf(com.ctrip.xpipe.redis.console.health.redisconf.RedisConf) VisibleForTesting(com.ctrip.xpipe.utils.VisibleForTesting)

Example 7 with RedisConf

use of com.ctrip.xpipe.redis.console.health.redisconf.RedisConf 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());
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort) RedisConf(com.ctrip.xpipe.redis.console.health.redisconf.RedisConf) Test(org.junit.Test)

Aggregations

RedisConf (com.ctrip.xpipe.redis.console.health.redisconf.RedisConf)7 HostPort (com.ctrip.xpipe.endpoint.HostPort)4 Test (org.junit.Test)4 VisibleForTesting (com.ctrip.xpipe.utils.VisibleForTesting)2 AbstractConsoleIntegrationTest (com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest)1