Description
Function for sending out the notification message to corresponding peer for leader election
private void processMessages() throws Exception {
try {
ByteBuffer b = getLastMessageSent(sid);
if (b != null)
} catch (IOException e) { LOG.error("Failed to send last message to " + sid, e); throw e; }
try {
ArrayBlockingQueue<ByteBuffer> bq = queueSendMap.get(sid);
if (bq == null) { dumpQueueSendMap(); throw new Exception("No queue for incoming messages for " + "sid=" + sid); }
while (running && !shutdown && sock != null) {
ByteBuffer b = null;
try {
b = bq.poll(1000, TimeUnit.MILLISECONDS);
if(b != null){ recordLastMessageSent(sid, b); send(b); }
} catch (InterruptedException e) { LOG.warn("Interrupted while waiting for message on " + "queue", e); }
}
} catch (Exception e) { LOG.warn("Exception when using channel: for id " + sid + " my id = " + self.getId() + " error = ", e); throw e; }
}
This is the code taken from zookeeper patch 932.
Here we are adding the message to be sent in current round to lastMessageSent. But in next round that message will still be there. So when we try to send a new message to server it will again do
ByteBuffer b = getLastMessageSent(sid);
if (b != null) { send(b); }
and it will again send back that old message to that server. So in this way it will send back every message twice. Though it will not affect the correctness of FLE but sending message twice it create an extra overhead and slow down the election process.