use of com.ctrip.xpipe.redis.core.protocal.cmd.AbstractSentinelCommand.SentinelRemove in project x-pipe by ctripcorp.
the class DefaultSentinelManager method removeSentinel.
@Override
public void removeSentinel(String clusterId, String shardId, ExecutionLog executionLog) {
String sentinelMonitorName = dcMetaCache.getSentinelMonitorName(clusterId, shardId);
String allSentinels = dcMetaCache.getSentinel(clusterId, shardId).getAddress();
executionLog.info(String.format("removeSentinel cluster:%s, shard:%s, masterName:%s, sentinelAddress:%s", clusterId, shardId, sentinelMonitorName, allSentinels));
if (checkEmpty(sentinelMonitorName, allSentinels, executionLog)) {
return;
}
List<InetSocketAddress> sentinels = IpUtils.parse(allSentinels);
List<Sentinel> realSentinels = getRealSentinels(sentinels, sentinelMonitorName, executionLog);
if (realSentinels == null) {
executionLog.warn("get real sentinels null");
return;
}
executionLog.info(String.format("removeSentinel realSentinels:%s", realSentinels));
for (Sentinel sentinel : realSentinels) {
SimpleObjectPool<NettyClient> clientPool = keyedClientPool.getKeyPool(new InetSocketAddress(sentinel.getIp(), sentinel.getPort()));
SentinelRemove sentinelRemove = new SentinelRemove(clientPool, sentinelMonitorName, scheduled);
try {
String result = sentinelRemove.execute().get();
executionLog.info(String.format("removeSentinel %s from %s : %s", sentinelMonitorName, sentinel, result));
} catch (InterruptedException | ExecutionException e) {
executionLog.info(String.format("removeSentinel %s from %s : %s", sentinelMonitorName, sentinel, e.getMessage()));
logger.warn("[removeSentinel]" + sentinel, e);
}
}
}
use of com.ctrip.xpipe.redis.core.protocal.cmd.AbstractSentinelCommand.SentinelRemove in project x-pipe by ctripcorp.
the class SentinelCommandTest method testSentinelMaster.
@Test
public void testSentinelMaster() throws InterruptedException, ExecutionException {
try {
String addResult = new SentinelAdd(clientPool, masterName, "127.0.0.1", 6379, 3, scheduled).execute().get();
logger.info("{}", addResult);
} catch (Exception ignore) {
}
try {
HostPort master = new AbstractSentinelCommand.SentinelMaster(clientPool, scheduled, masterName).execute().get();
logger.info("[master]{}", master);
Assert.assertEquals("127.0.0.1", master.getHost());
Assert.assertEquals(6379, master.getPort());
} catch (Exception e) {
logger.error("[testSentinelMaster]", e);
}
try {
new SentinelRemove(clientPool, masterName, scheduled).execute().get();
} catch (Exception e) {
logger.error("[testRemove]", e);
}
}
Aggregations