@Override
public boolean add(Channel channel) {
if (channel instanceof ServerChannel)
return super.add(channel);
else {
final NodeInfo node = ChannelNodeInfo.nodeInfo.get(channel);
if (node == null) {
LOG.warn("Received connection from an unknown address {}.", channel.getRemoteAddress());
throw new RuntimeException("Unknown node for address " + channel.getRemoteAddress());
}
final short nodeId = node.getNodeId();
if (channels.containsKey(nodeId)) {
LOG.warn("Received connection from address {} of node {}, but this node is already connected.", channel.getRemoteAddress(), nodeId);
throw new RuntimeException("Node " + nodeId + " already connected.");
}
final boolean added = super.add(channel);