Search in sources :

Example 1 with MasterNotFoundException

use of com.ctrip.xpipe.redis.console.resources.MasterNotFoundException in project x-pipe by ctripcorp.

the class DefaultSentinelCollector method collect.

@Override
public void collect(SentinelSample sentinelSample) {
    Set<SentinelHello> hellos = sentinelSample.getHellos();
    String clusterId = sentinelSample.getSamplePlan().getClusterId();
    String shardId = sentinelSample.getSamplePlan().getShardId();
    String sentinelMonitorName = metaCache.getSentinelMonitorName(clusterId, shardId);
    Set<HostPort> masterDcSentinels = metaCache.getActiveDcSentinels(clusterId, shardId);
    QuorumConfig quorumConfig = consoleConfig.getDefaultSentinelQuorumConfig();
    HostPort masterAddr = null;
    try {
        masterAddr = metaCache.findMaster(clusterId, shardId);
    } catch (MasterNotFoundException e) {
        logger.error("[collect]" + e.getMessage(), e);
    }
    logger.debug("[collect]{},{},{}", clusterId, shardId, hellos);
    // check delete
    Set<SentinelHello> toDelete = checkAndDelete(sentinelMonitorName, masterDcSentinels, hellos, quorumConfig);
    // checkReset
    checkReset(clusterId, shardId, sentinelMonitorName, hellos);
    // check add
    Set<SentinelHello> toAdd = checkToAdd(clusterId, shardId, sentinelMonitorName, masterDcSentinels, hellos, masterAddr, quorumConfig);
    doAction(toDelete, toAdd, quorumConfig);
}
Also used : QuorumConfig(com.ctrip.xpipe.redis.core.meta.QuorumConfig) MasterNotFoundException(com.ctrip.xpipe.redis.console.resources.MasterNotFoundException) HostPort(com.ctrip.xpipe.endpoint.HostPort)

Aggregations

HostPort (com.ctrip.xpipe.endpoint.HostPort)1 MasterNotFoundException (com.ctrip.xpipe.redis.console.resources.MasterNotFoundException)1 QuorumConfig (com.ctrip.xpipe.redis.core.meta.QuorumConfig)1