zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "raghul@yahoo.com" <rag...@yahoo.com>
Subject Incorrect implementation of QuorumCnxManager.haveDelivered()?
Date Thu, 26 Mar 2009 02:28:12 GMT


I am a ZooKeeper newbie, so pardon me if I am repeating questions that have been raised before.

I believe the implementation of QuorumCnxManager.haveDelivered() is incorrect. If I understand
correctly, queueSendMap contains a queue of messages for each peer to which the local peer
is trying to send election messages. When FastLeaderElection notices a timeout while polling
for inbound messages, it checks to see if all the messages have been delivered by calling
this function. So shouldn't this function actually check each queue in the hash map and return
true if all of them are empty? This method is rather returning true the if just one of the
queues is empty?

     * Check if all queues are empty, indicating that all messages have been delivered.
    boolean haveDelivered() {
        for (ArrayBlockingQueue<ByteBuffer> queue : queueSendMap.values()) {
            LOG.debug("Queue size: " + queue.size());
            if (queue.size() == 0)
                return true;

        return false;

Also, could someone expain the reason behind maitaining a queue of messages for each peer
in queueSendMap? Why do we need a per peer queue here? Since this is used during election,
the local peer is not sending more than one message at a time to the remote peer. So the hash
map needs to store just one message per remote peer?



View raw message