refreshCluster();
this.topology.addListener(this);
}
private boolean connectTo(Integer partitionId) {
ClusterNode clusterNode = partitionNodeMap.get(partitionId);
if (clusterNode == null) {
logger.error("No ClusterNode exists for partitionId " + partitionId);
refreshCluster();
return false;
}
try {
ChannelFuture connectFuture = this.bootstrap.connect(new InetSocketAddress(clusterNode.getMachineName(),
clusterNode.getPort()));
connectFuture.await();
if (connectFuture.isSuccess()) {
channels.add(connectFuture.getChannel());
partitionChannelMap.forcePut(partitionId, connectFuture.getChannel());
return true;
}
} catch (InterruptedException ie) {
logger.error(String.format("Interrupted while connecting to %s:%d", clusterNode.getMachineName(),
clusterNode.getPort()));
Thread.currentThread().interrupt();
}
return false;
}