use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class ClusterServiceImpl method findUnhealthyClusters.
@Override
public List<ClusterListClusterModel> findUnhealthyClusters() {
try {
XpipeMeta xpipeMeta = metaCache.getXpipeMeta();
if (xpipeMeta == null || xpipeMeta.getDcs() == null) {
return Collections.emptyList();
}
String prefix = "健康监测有问题的shard及redis:\n";
Map<String, ClusterListClusterModel> unhealthyClusters = Maps.newHashMap();
for (DcMeta dcMeta : xpipeMeta.getDcs().values()) {
for (ClusterMeta clusterMeta : dcMeta.getClusters().values()) {
StringBuffer sb = new StringBuffer();
for (ShardMeta shardMeta : clusterMeta.getShards().values()) {
boolean shardLogged = false;
for (RedisMeta redisMeta : shardMeta.getRedises()) {
HostPort hostPort = new HostPort(redisMeta.getIp(), redisMeta.getPort());
long delay = delayService.getDelay(hostPort);
if (delay == TimeUnit.NANOSECONDS.toMillis(DefaultDelayMonitor.SAMPLE_LOST_AND_NO_PONG) || delay == TimeUnit.NANOSECONDS.toMillis(DefaultDelayMonitor.SAMPLE_LOST_BUT_PONG)) {
String clusterName = clusterMeta.getId();
unhealthyClusters.putIfAbsent(clusterName, new ClusterListClusterModel(clusterMeta.getId()));
if (!shardLogged) {
shardLogged = true;
sb.append(shardMeta.getId()).append(": ");
}
sb.append(hostPort.toString()).append(", ");
}
}
if (shardLogged) {
sb.append(";\n");
}
}
ClusterListClusterModel cluster = unhealthyClusters.get(clusterMeta.getId());
if (cluster != null) {
String message = cluster.getMessage() == null ? "" : cluster.getMessage();
message += sb.toString();
if (!message.startsWith(prefix)) {
message = prefix + message;
}
cluster.setMessage(message);
}
}
}
return richClusterInfo(unhealthyClusters);
} catch (Exception e) {
logger.error("[findUnhealthyClusters]{}", e);
return Collections.emptyList();
}
}
use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class SenderManagerTest method testSenderManager.
@Test
public void testSenderManager() {
HostPort hostPort = new HostPort("192.168.1.10", 6379);
Map<ALERT_TYPE, Set<AlertEntity>> alerts = new ConcurrentHashMap<>();
AlertEntity alert = new AlertEntity(hostPort, dcNames[0], "cluster-test", "shard-test", "", ALERT_TYPE.XREDIS_VERSION_NOT_VALID);
Set<AlertEntity> set = new ConcurrentSet<>();
set.add(alert);
alerts.put(ALERT_TYPE.XREDIS_VERSION_NOT_VALID, set);
new Thread(new Runnable() {
@Override
public void run() {
alerts.get(ALERT_TYPE.XREDIS_VERSION_NOT_VALID).remove(alert);
}
}).start();
List<Map<ALERT_TYPE, Set<AlertEntity>>> result = senderManager.getGroupedAlerts(alerts);
logger.info("result: {}", result.get(0));
if (!result.isEmpty()) {
Set<AlertEntity> alertEntities = result.get(0).getOrDefault(alert.getAlertType(), null);
if (alertEntities != null) {
Assert.assertFalse(alertEntities.isEmpty());
}
}
}
use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class DiskLessCollectorTest method testCheckRedisVersion.
@Test
public void testCheckRedisVersion() {
RedisConf redisConf = new RedisConf(new HostPort(host, port), clusterId, shardId);
redisConf.setRedisVersion("3.0.7");
redisConf.setXredisVersion("0.0.4");
when(confManager.findOrCreateConfig(host, port)).thenReturn(redisConf);
when(config.getReplDisklessMinRedisVersion()).thenReturn("2.8.22");
HostPort hostPort = new HostPort(host, port);
Assert.assertTrue(collector.isReplDiskLessSync(diskLess));
Assert.assertFalse(collector.versionMatches(hostPort));
}
use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class DefaultSentinelCollectorTest method beforeDefaultSentinelCollectorTest.
@Before
public void beforeDefaultSentinelCollectorTest() {
sentinelCollector = new DefaultSentinelCollector();
sentinelCollector.setSessionManager(new DefaultRedisSessionManager(1, Executors.newFixedThreadPool(1), Executors.newFixedThreadPool(1)));
masterSentinels = Sets.newHashSet(new HostPort("127.0.0.1", 5000), new HostPort("127.0.0.1", 5001), new HostPort("127.0.0.1", 5002), new HostPort("127.0.0.1", 5003), new HostPort("127.0.0.1", 5004));
}
use of com.ctrip.xpipe.endpoint.HostPort in project x-pipe by ctripcorp.
the class SentinelHelloTest method testFormat.
@Test
public void testFormat() {
SentinelHello sentinelHello = SentinelHello.fromString("10.15.95.133,33322," + "642d5452b3ffd243fdfc31a2ccf5b0b5963c161f,1942," + "FlightIntlGDSCacheGroup1," + "10.15.94.178,6379,0");
Assert.assertEquals(new HostPort("10.15.95.133", 33322), sentinelHello.getSentinelAddr());
Assert.assertEquals(new HostPort("10.15.94.178", 6379), sentinelHello.getMasterAddr());
Assert.assertEquals("FlightIntlGDSCacheGroup1", sentinelHello.getMonitorName());
}
Aggregations