Search in sources :

Example 1 with Sentinels

use of com.ctrip.xpipe.redis.core.protocal.cmd.AbstractSentinelCommand.Sentinels in project x-pipe by ctripcorp.

the class DefaultSentinelManager method getRealSentinels.

private List<Sentinel> getRealSentinels(List<InetSocketAddress> sentinels, String sentinelMonitorName, ExecutionLog executionLog) {
    List<Sentinel> realSentinels = null;
    for (InetSocketAddress sentinelAddress : sentinels) {
        SimpleObjectPool<NettyClient> clientPool = keyedClientPool.getKeyPool(sentinelAddress);
        Sentinels sentinelsCommand = new Sentinels(clientPool, sentinelMonitorName, scheduled);
        try {
            realSentinels = sentinelsCommand.execute().get();
            executionLog.info(String.format("get sentinels from %s : %s", sentinelAddress, realSentinels));
            if (realSentinels.size() > 0) {
                realSentinels.add(new Sentinel(sentinelAddress.toString(), sentinelAddress.getHostString(), sentinelAddress.getPort()));
                break;
            }
        } catch (InterruptedException | ExecutionException e) {
            logger.warn("[getRealSentinels]get sentinels from " + sentinelAddress, e);
            executionLog.warn("[getRealSentinels]get sentinels from " + sentinelAddress + "," + e.getMessage());
        }
    }
    return realSentinels;
}
Also used : NettyClient(com.ctrip.xpipe.netty.commands.NettyClient) Sentinel(com.ctrip.xpipe.redis.core.protocal.pojo.Sentinel) InetSocketAddress(java.net.InetSocketAddress) ExecutionException(java.util.concurrent.ExecutionException) Sentinels(com.ctrip.xpipe.redis.core.protocal.cmd.AbstractSentinelCommand.Sentinels)

Aggregations

NettyClient (com.ctrip.xpipe.netty.commands.NettyClient)1 Sentinels (com.ctrip.xpipe.redis.core.protocal.cmd.AbstractSentinelCommand.Sentinels)1 Sentinel (com.ctrip.xpipe.redis.core.protocal.pojo.Sentinel)1 InetSocketAddress (java.net.InetSocketAddress)1 ExecutionException (java.util.concurrent.ExecutionException)1