|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.zookeeper.server.quorum.QuorumCnxManager
public class QuorumCnxManager
This class implements a connection manager for leader election using TCP. It maintains one coonection for every pair of servers. The tricky part is to guarantee that there is exactly one connection for every pair of servers that are operating correctly and that can communicate over the network. If two servers try to start a connection concurrently, then the connection manager uses a very simple tie-breaking mechanism to decide which connection to drop based on the IP addressed of the two parties. For every peer, the manager maintains a queue of messages to send. If the connection to any particular peer drops, then the sender thread puts the message back on the list. As this implementation currently uses a queue implementation to maintain messages to send to another peer, we add the message to the tail of the queue, thus changing the order of messages. Although this is not a problem for the leader election, it could be a problem when consolidating peer communication. This is to be verified, though.
Nested Class Summary | |
---|---|
class |
QuorumCnxManager.Listener
Thread to listen on some port |
static class |
QuorumCnxManager.Message
|
Field Summary | |
---|---|
QuorumCnxManager.Listener |
listener
|
ArrayBlockingQueue<QuorumCnxManager.Message> |
recvQueue
|
Constructor Summary | |
---|---|
QuorumCnxManager(QuorumPeer self)
|
Method Summary | |
---|---|
void |
connectAll()
Try to establish a connection with each server if one doesn't exist. |
void |
halt()
Flag that it is time to wrap up all activities and interrupt the listener. |
boolean |
initiateConnection(SocketChannel s,
Long sid)
If this server has initiated the connection, then it gives up on the connection if it loses challenge. |
void |
softHalt()
A soft halt simply finishes workers. |
void |
testInitiateConnection(long sid)
Invokes initiateConnection for testing purposes |
void |
toSend(Long sid,
ByteBuffer b)
Processes invoke this message to queue a message to send. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public ArrayBlockingQueue<QuorumCnxManager.Message> recvQueue
public QuorumCnxManager.Listener listener
Constructor Detail |
---|
public QuorumCnxManager(QuorumPeer self)
Method Detail |
---|
public void testInitiateConnection(long sid) throws Exception
sid
-
Exception
public boolean initiateConnection(SocketChannel s, Long sid)
public void toSend(Long sid, ByteBuffer b)
public void connectAll()
public void halt()
public void softHalt()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |