use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class ClientConfigMonitor method checkClusterInfo.
private void checkClusterInfo(OuterClientService.ClusterInfo clusterInfo) {
if (clusterInfo.getGroups() == null || clusterInfo.getGroups().isEmpty())
return;
String clusterName = clusterInfo.getName(), shardName;
for (OuterClientService.GroupInfo group : clusterInfo.getGroups()) {
List<OuterClientService.InstanceInfo> instances = group.getInstances();
if (instances == null || instances.isEmpty())
continue;
shardName = group.getName();
for (OuterClientService.InstanceInfo instance : instances) {
if (!instance.isCanRead()) {
alertManager.alert(clusterName, shardName, new HostPort(instance.getIPAddress(), instance.getPort()), ALERT_TYPE.CLIENT_INSTANCE_NOT_OK, "instance cannot read");
}
if (!instance.isStatus()) {
alertManager.alert(clusterName, shardName, new HostPort(instance.getIPAddress(), instance.getPort()), ALERT_TYPE.CLIENT_INSTANCE_NOT_OK, "instance is not valid");
}
}
}
}
use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class BacklogActiveMonitor method sampleInfoReplication.
public void sampleInfoReplication(long recordTime, BaseSamplePlan<InstanceInfoReplicationResult> plan) {
for (HostPort hostPort : plan.getHostPort2SampleResult().keySet()) {
RedisSession session = sessionManager.findOrCreateSession(hostPort.getHost(), hostPort.getPort());
session.infoReplication(new Callbackable<String>() {
@Override
public void success(String message) {
addInstanceSuccess(recordTime, hostPort.getHost(), hostPort.getPort(), message);
}
@Override
public void fail(Throwable throwable) {
addInstanceFail(recordTime, hostPort.getHost(), hostPort.getPort(), throwable);
}
});
}
}
use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class BecomePrimaryAction method doChangePrimaryDc.
protected PrimaryDcChangeMessage doChangePrimaryDc(String clusterId, String shardId, String newPrimaryDc, MasterInfo masterInfo) {
doChangeMetaCache(clusterId, shardId, newPrimaryDc);
executionLog.info(String.format("[chooseNewMaster][begin]"));
Pair<String, Integer> newMaster = chooseNewMaster(clusterId, shardId);
executionLog.info(String.format("[chooseNewMaster]%s:%d", newMaster.getKey(), newMaster.getValue()));
// wait for slave to achieve master offset
offsetWaiter.tryWaitfor(new HostPort(newMaster.getKey(), newMaster.getValue()), masterInfo, executionLog);
List<RedisMeta> slaves = getAllSlaves(newMaster, dcMetaCache.getShardRedises(clusterId, shardId));
makeRedisesOk(newMaster, slaves);
makeKeepersOk(clusterId, shardId, newMaster);
changeSentinel(clusterId, shardId, newMaster);
return new PrimaryDcChangeMessage(executionLog.getLog(), newMaster.getKey(), newMaster.getValue());
}
use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class DefaultPrimaryDcPrepareToChange method prepare.
@Override
public MetaServerConsoleService.PreviousPrimaryDcMessage prepare(String clusterId, String shardId) {
logger.info("[prepare]{}, {}", clusterId, shardId);
MetaServerConsoleService.PreviousPrimaryDcMessage message = new MetaServerConsoleService.PreviousPrimaryDcMessage();
ExecutionLog executionLog = new ExecutionLog(String.format("meta server:%s", currentClusterServer.getClusterInfo()));
Pair<String, Integer> keeperMaster = currentMetaManager.getKeeperMaster(clusterId, shardId);
message.setMasterAddr(new HostPort(keeperMaster.getKey(), keeperMaster.getValue()));
executionLog.info("[prepare]" + keeperMaster);
RedisInfo redisInfo = getInfoReplication(keeperMaster, executionLog);
MasterInfo masterInfo = convert(redisInfo, executionLog);
message.setMasterInfo(masterInfo);
logger.info("[prepare]{}, {}, {}", keeperMaster, redisInfo, masterInfo);
makeMasterReadOnly(clusterId, shardId, keeperMaster, true, executionLog);
removeSentinel(clusterId, shardId, executionLog);
message.setMessage(executionLog.getLog());
return message;
}
use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class DefaultPrimaryDcPrepareToChange method addSentinel.
private void addSentinel(String clusterId, String shardId, ExecutionLog executionLog) {
logger.info("[addSentinel]{},{}", clusterId, shardId);
Pair<String, Integer> keeperMaster = currentMetaManager.getKeeperMaster(clusterId, shardId);
sentinelManager.addSentinel(clusterId, shardId, new HostPort(keeperMaster.getKey(), keeperMaster.getValue()), executionLog);
}
Aggregations