use of com.ctrip.xpipe.endpoint.ClusterShardHostPort in project x-pipe by ctripcorp.
the class SentinelCollector4Keeper method collect.
@Override
public void collect(SentinelSample sentinelSample) {
String clusterId = sentinelSample.getSamplePlan().getClusterId();
String shardId = sentinelSample.getSamplePlan().getShardId();
sentinelSample.getSamplePlan().getHostPort2SampleResult().forEach(((hostPort, instanceSentinelResult) -> {
if (metaCache.inBackupDc(hostPort)) {
ClusterShardHostPort entry = new ClusterShardHostPort(clusterId, shardId, hostPort);
doCollect(entry, instanceSentinelResult);
}
}));
}
use of com.ctrip.xpipe.endpoint.ClusterShardHostPort 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());
}
}
use of com.ctrip.xpipe.endpoint.ClusterShardHostPort 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;
}
use of com.ctrip.xpipe.endpoint.ClusterShardHostPort in project x-pipe by ctripcorp.
the class SentinelCollector4Keeper method doCollect.
private void doCollect(ClusterShardHostPort entry, InstanceSentinelResult result) {
Set<SentinelHello> hellos = result.getHellos();
for (SentinelHello hello : hellos) {
HostPort masterAddr = hello.getMasterAddr();
String monitorName = hello.getMonitorName();
boolean masterGood = ObjectUtils.equals(masterAddr, metaCache.findMasterInSameShard(entry.getHostPort()));
boolean monitorGood = StringUtil.trimEquals(monitorName, metaCache.getSentinelMonitorName(entry.getClusterName(), entry.getShardName()));
SentinelCollectorAction.getAction(masterGood, monitorGood).doAction(this, hello, entry);
}
}
use of com.ctrip.xpipe.endpoint.ClusterShardHostPort in project x-pipe by ctripcorp.
the class OuterClientServiceProcessor method onEvent.
@Override
public void onEvent(AbstractInstanceEvent instanceEvent) throws HealthEventProcessorException {
HostPort hostPort = instanceEvent.getHostPort();
Pair<String, String> clusterShard = metaCache.findClusterShard(hostPort);
if (!instanceInBackupDc(hostPort)) {
logger.info("[onEvent][instance not in backupDc]{}, {}", clusterShard, hostPort);
return;
}
ClusterShardHostPort clusterShardHostPort = new ClusterShardHostPort(hostPort);
if (clusterShard != null) {
clusterShardHostPort.setClusterName(clusterShard.getKey());
clusterShardHostPort.setShardName(clusterShard.getValue());
}
if (instanceEvent instanceof InstanceUp) {
finalStateSetterManager.set(clusterShardHostPort, true);
} else if (instanceEvent instanceof InstanceDown) {
if (masterUp(clusterShardHostPort)) {
quorumMarkInstanceDown(clusterShardHostPort);
} else {
logger.info("[onEvent][master down, do not call client service]{}", instanceEvent);
}
} else {
throw new IllegalStateException("unknown event:" + instanceEvent);
}
}
Aggregations