/*
* Wait to receive the replica's version, decide which protocol version
* to use ourselves, and then reply with our version.
*/
ReplicaProtocolVersion message =
(ReplicaProtocolVersion) defaultProtocol.read(namedChannel);
replicaNameIdPair = message.getNameIdPair();
Feeder dup =
repNode.feederManager().getFeeder(replicaNameIdPair.getName());
if ((dup != null) ||
(message.getNameIdPair().getName().
equals(feederNameIdPair.getName()))) {
/* Reject the connection. */
defaultProtocol.write(defaultProtocol.new DuplicateNodeReject
("This node: " + replicaNameIdPair +
" is already in active use at the feeder "),
namedChannel);
SocketAddress dupAddress =
namedChannel.getChannel().socket().getRemoteSocketAddress();
throw new ExitException
("A replica with the id: " + replicaNameIdPair +
" is already active with this feeder. " +
" The duplicate replica resides at: " +
dupAddress);
}
/*
* If the Replica's version is acceptable, use it, otherwise return the
* default protocol at this node, in case the Replica can support it.
*/
final int replicaVersion = message.getVersion();
Protocol protocol = Protocol.get(repNode, replicaVersion);
/*
* If no suitable protocol was found, simply use the default protocol
* at the feeder, it will be rejected by the Replica.