Search in sources :

Example 11 with HostPort

use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.

the class OuterClientServiceProcessor method quorumMarkInstanceDown.

private void quorumMarkInstanceDown(ClusterShardHostPort clusterShardHostPort) {
    HostPort hostPort = clusterShardHostPort.getHostPort();
    List<HEALTH_STATE> health_states = consoleServiceManager.allHealthStatus(hostPort.getHost(), hostPort.getPort());
    logger.info("[quorumMarkInstanceDown]{}, {}", clusterShardHostPort, health_states);
    boolean quorum = consoleServiceManager.quorumSatisfy(health_states, (state) -> state == HEALTH_STATE.UNHEALTHY || state == HEALTH_STATE.DOWN);
    if (quorum) {
        finalStateSetterManager.set(clusterShardHostPort, false);
    } else {
        logger.info("[quorumMarkInstanceDown][quorum fail]{}, {}", clusterShardHostPort, quorum);
        alertManager.alert(clusterShardHostPort.getClusterName(), clusterShardHostPort.getShardName(), hostPort, ALERT_TYPE.QUORUM_DOWN_FAIL, hostPort.toString());
    }
}
Also used : ClusterShardHostPort(com.ctrip.xpipe.endpoint.ClusterShardHostPort) HostPort(com.ctrip.xpipe.endpoint.HostPort)

Example 12 with HostPort

use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.

the class OuterClientServiceProcessor method masterUp.

private boolean masterUp(ClusterShardHostPort clusterShardHostPort) {
    // master up
    HostPort redisMaster = metaCache.findMasterInSameShard(clusterShardHostPort.getHostPort());
    boolean masterUp = allMonitorCollector.getState(redisMaster) == HEALTH_STATE.UP;
    if (!masterUp) {
        logger.info("[masterUp][master down instance:{}, master:{}]", clusterShardHostPort, redisMaster);
    }
    return masterUp;
}
Also used : ClusterShardHostPort(com.ctrip.xpipe.endpoint.ClusterShardHostPort) HostPort(com.ctrip.xpipe.endpoint.HostPort)

Example 13 with HostPort

use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.

the class MetricDelayCollector method collect.

@Override
public void collect(DelaySampleResult result) {
    try {
        List<MetricData> data = new LinkedList<>();
        for (Entry<HostPort, Long> entry : result.getSlaveHostPort2Delay().entrySet()) {
            MetricData point = getPoint(entry.getKey(), entry.getValue(), result);
            data.add(point);
        }
        HostPort masterHostPort = result.getMasterHostPort();
        if (masterHostPort != null) {
            MetricData point = getPoint(masterHostPort, result.getMasterDelayNanos(), result);
            data.add(point);
        }
        proxy.writeBinMultiDataPoint(data);
    } catch (Exception e) {
        log.error("Error send metrics to metric", e);
    }
}
Also used : HostPort(com.ctrip.xpipe.endpoint.HostPort) LinkedList(java.util.LinkedList) MetricData(com.ctrip.xpipe.metric.MetricData)

Example 14 with HostPort

use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.

the class DefaultBacklogActiveCollectorTest method analysisInfoReplication3.

@Test
public void analysisInfoReplication3() 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:unkown\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:0\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)

Example 15 with HostPort

use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.

the class DefaultBacklogActiveCollectorTest method analysisInfoReplication.

@Test
public void analysisInfoReplication() 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:0\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).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

HostPort (com.ctrip.xpipe.endpoint.HostPort)79 Test (org.junit.Test)31 AbstractConsoleIntegrationTest (com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest)7 LinkedList (java.util.LinkedList)7 ALERT_TYPE (com.ctrip.xpipe.redis.console.alert.ALERT_TYPE)6 MasterInfo (com.ctrip.xpipe.redis.core.protocal.pojo.MasterInfo)6 AbstractMetaServerTest (com.ctrip.xpipe.redis.meta.server.AbstractMetaServerTest)6 ClusterShardHostPort (com.ctrip.xpipe.endpoint.ClusterShardHostPort)5 HashSet (java.util.HashSet)5 List (java.util.List)5 Map (java.util.Map)5 RedisConf (com.ctrip.xpipe.redis.console.health.redisconf.RedisConf)4 MasterNotFoundException (com.ctrip.xpipe.redis.console.resources.MasterNotFoundException)4 XpipeMetaManager (com.ctrip.xpipe.redis.core.meta.XpipeMetaManager)4 Set (java.util.Set)4 AbstractConsoleTest (com.ctrip.xpipe.redis.console.AbstractConsoleTest)3 AlertEntity (com.ctrip.xpipe.redis.console.alert.AlertEntity)3 AlertManager (com.ctrip.xpipe.redis.console.alert.AlertManager)3 DefaultRedisSessionManager (com.ctrip.xpipe.redis.console.health.DefaultRedisSessionManager)3 ClusterListClusterModel (com.ctrip.xpipe.redis.console.model.consoleportal.ClusterListClusterModel)3