use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class ScheduledAlertMessageDecoratorTest method generateBody.
@Test
public void generateBody() throws Exception {
HostPort hostPort = new HostPort("192.168.1.10", 6379);
Map<ALERT_TYPE, Set<AlertEntity>> alerts = new HashMap<>();
alerts.put(ALERT_TYPE.CLIENT_INCONSIS, Collections.singleton(new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.CLIENT_INCONSIS)));
alerts.put(ALERT_TYPE.XREDIS_VERSION_NOT_VALID, Collections.singleton(new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.XREDIS_VERSION_NOT_VALID)));
String body = decorator.generateBody(alerts);
logger.info("{}", body);
}
use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class DefaultRedisSessionManager method findOrCreateSession.
@Override
public RedisSession findOrCreateSession(String host, int port) {
if (StringUtil.isEmpty(host) || port == 0) {
throw new IllegalArgumentException("Redis Host/Port can not be empty: " + host + ":" + port);
}
HostPort hostPort = new HostPort(host, port);
RedisSession session = sessions.get(hostPort);
if (session == null) {
synchronized (this) {
session = sessions.get(hostPort);
if (session == null) {
session = new RedisSession(findRedisConnection(host, port), hostPort, executors, pingAndDelayExecutor);
sessions.put(hostPort, session);
}
}
}
return session;
}
use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class VersionMonitor method sampleVersionCheck.
private void sampleVersionCheck(long startNanoTime, BaseSamplePlan<VersionInstanceResult> plan) {
for (Map.Entry<HostPort, VersionInstanceResult> entry : plan.getHostPort2SampleResult().entrySet()) {
HostPort hostPort = entry.getKey();
try {
RedisSession redisSession = findRedisSession(hostPort);
redisSession.infoServer(new Callbackable<String>() {
@Override
public void success(String message) {
addInstanceSuccess(startNanoTime, hostPort.getHost(), hostPort.getPort(), message);
}
@Override
public void fail(Throwable throwable) {
addInstanceFail(startNanoTime, hostPort.getHost(), hostPort.getPort(), throwable);
}
});
} catch (Exception e) {
addInstanceFail(startNanoTime, hostPort.getHost(), hostPort.getPort(), e);
}
}
}
use of com.ctrip.xpipe.endpoint.HostPort 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.HostPort 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