use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class DefaultPingServiceTest method testPingService.
@Test
@DirtiesContext
public void testPingService() throws IOException {
Executors.newScheduledThreadPool(1).scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
System.out.println(pingService.isRedisAlive(new HostPort("127.0.0.1", 6379)));
}
}, 0, 2, TimeUnit.SECONDS);
waitForAnyKeyToExit();
}
use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class SenderManagerTest method sendAlerts.
@Test
public void sendAlerts() 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)));
alerts.put(ALERT_TYPE.QUORUM_DOWN_FAIL, Collections.singleton(new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.QUORUM_DOWN_FAIL)));
alerts.put(ALERT_TYPE.SENTINEL_RESET, Collections.singleton(new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.SENTINEL_RESET)));
alerts.put(ALERT_TYPE.REDIS_CONF_REWRITE_FAILURE, Collections.singleton(new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.REDIS_CONF_REWRITE_FAILURE)));
alerts.put(ALERT_TYPE.REDIS_REPL_DISKLESS_SYNC_ERROR, Collections.singleton(new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.REDIS_REPL_DISKLESS_SYNC_ERROR)));
alerts.put(ALERT_TYPE.MIGRATION_MANY_UNFINISHED, Collections.singleton(new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.MIGRATION_MANY_UNFINISHED)));
logger.info("{}", alerts);
senderManager.sendAlerts(alerts);
}
use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class DefaultPrimaryDcPrepareToChange method deprepare.
@Override
public MetaServerConsoleService.PreviousPrimaryDcMessage deprepare(String clusterId, String shardId) {
logger.info("[deprepare]{}, {}", 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("[deprepare]" + keeperMaster);
makeMasterReadOnly(clusterId, shardId, keeperMaster, false, executionLog);
addSentinel(clusterId, shardId, executionLog);
message.setMessage(executionLog.getLog());
return message;
}
use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class SentinelUpdateController method convert2SentinelTbl.
@VisibleForTesting
protected SetinelTbl convert2SentinelTbl(SentinelModel sentinelModel) {
StringBuilder sb = new StringBuilder();
for (HostPort hostPort : sentinelModel.getSentinels()) {
sb.append(hostPort.getHost()).append(':').append(hostPort.getPort()).append(',');
}
String sentinels = sb.deleteCharAt(sb.length() - 1).toString();
SetinelTbl proto = new SetinelTbl();
proto.setSetinelAddress(sentinels);
proto.setDeleted(false);
proto.setSetinelDescription(sentinelModel.getDesc());
proto.setDcId(dcService.find(sentinelModel.getDcName()).getId());
return proto;
}
use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class DefaultDelayMonitor method convertToSampleResult.
private DelaySampleResult convertToSampleResult(Sample<InstanceDelayResult> sample) {
BaseSamplePlan<InstanceDelayResult> plan = sample.getSamplePlan();
DelaySampleResult sampleResult = new DelaySampleResult(sample.getStartTime(), plan.getClusterId(), plan.getShardId());
for (Entry<HostPort, InstanceDelayResult> entry : plan.getHostPort2SampleResult().entrySet()) {
HostPort hostPort = entry.getKey();
InstanceDelayResult delay = entry.getValue();
long delayNanos = SAMPLE_LOST_AND_NO_PONG;
if (delay.isDone()) {
delayNanos = delay.calculateDelay(sample.getStartNanoTime());
} else {
if (pingSvc.isRedisAlive(hostPort)) {
delayNanos = SAMPLE_LOST_BUT_PONG;
}
}
if (delay.isMaster()) {
sampleResult.setMasterDelayNanos(hostPort, delayNanos);
} else {
sampleResult.addSlaveDelayNanos(hostPort, delayNanos);
}
}
return sampleResult;
}
Aggregations