public class QuorumCnxManager extends Object
Modifier and Type | Class and Description |
---|---|
static class |
QuorumCnxManager.InitialMessage |
class |
QuorumCnxManager.Listener
Thread to listen on some port
|
static class |
QuorumCnxManager.Message |
Modifier and Type | Field and Description |
---|---|
QuorumCnxManager.Listener |
listener |
static int |
maxBuffer |
static long |
PROTOCOL_VERSION |
ArrayBlockingQueue<QuorumCnxManager.Message> |
recvQueue |
Constructor and Description |
---|
QuorumCnxManager(QuorumPeer self,
long mySid,
Map<Long,QuorumPeer.QuorumServer> view,
QuorumAuthServer authServer,
QuorumAuthLearner authLearner,
int socketTimeout,
boolean listenOnAllIPs,
int quorumCnxnThreadsSize,
boolean quorumSaslAuthEnabled) |
Modifier and Type | Method and Description |
---|---|
void |
addToRecvQueue(QuorumCnxManager.Message msg)
Inserts an element in the
recvQueue . |
void |
connectAll()
Try to establish a connection with each server if one
doesn't exist.
|
boolean |
connectedToPeer(long peerSid) |
long |
getConnectionThreadCount()
Return number of connection processing threads.
|
long |
getThreadCount()
Return number of worker threads
|
void |
halt()
Flag that it is time to wrap up all activities and interrupt the listener.
|
void |
initiateConnection(Socket sock,
Long sid)
If this server has initiated the connection, then it gives up on the
connection if it loses challenge.
|
void |
initiateConnectionAsync(Socket sock,
Long sid)
Server will initiate the connection request to its peer server
asynchronously via separate connection thread.
|
QuorumCnxManager.Message |
pollRecvQueue(long timeout,
TimeUnit unit)
Retrieves and removes a message at the head of this queue,
waiting up to the specified wait time if necessary for an element to
become available.
|
void |
receiveConnection(Socket sock)
If this server receives a connection request, then it gives up on the new
connection if it wins.
|
void |
receiveConnectionAsync(Socket sock)
Server receives a connection request and handles it asynchronously via
separate thread.
|
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.
|
public static final long PROTOCOL_VERSION
public static final int maxBuffer
public final ArrayBlockingQueue<QuorumCnxManager.Message> recvQueue
public final QuorumCnxManager.Listener listener
public QuorumCnxManager(QuorumPeer self, long mySid, Map<Long,QuorumPeer.QuorumServer> view, QuorumAuthServer authServer, QuorumAuthLearner authLearner, int socketTimeout, boolean listenOnAllIPs, int quorumCnxnThreadsSize, boolean quorumSaslAuthEnabled)
public void testInitiateConnection(long sid) throws Exception
sid
- Exception
public void initiateConnection(Socket sock, Long sid)
public void initiateConnectionAsync(Socket sock, Long sid)
public void receiveConnection(Socket sock)
public void receiveConnectionAsync(Socket sock)
public void toSend(Long sid, ByteBuffer b)
public void connectAll()
public void halt()
public void softHalt()
public long getThreadCount()
public long getConnectionThreadCount()
public void addToRecvQueue(QuorumCnxManager.Message msg)
recvQueue
. If the Queue is full, this
methods removes an element from the head of the Queue and then inserts
the element at the tail of the queue.
This method is synchronized to achieve fairness between two threads that
are trying to insert an element in the queue. Each thread checks if the
queue is full, then removes the element at the head of the queue, and
then inserts an element at the tail. This three-step process is done to
prevent a thread from blocking while inserting an element in the queue.
If we do not synchronize the call to this method, then a thread can grab
a slot in the queue created by the second thread. This can cause the call
to insert by the second thread to fail.
Note that synchronizing this method does not block another thread
from polling the queue since that synchronization is provided by the
queue itself.msg
- Reference to the message to be inserted in the queuepublic QuorumCnxManager.Message pollRecvQueue(long timeout, TimeUnit unit) throws InterruptedException
ArrayBlockingQueue.poll(long, java.util.concurrent.TimeUnit)
InterruptedException
public boolean connectedToPeer(long peerSid)
Copyright © 2008–2019 The Apache Software Foundation. All rights reserved.