Package org.apache.bookkeeper.proto
Class DefaultPerChannelBookieClientPool
- java.lang.Object
- 
- org.apache.bookkeeper.proto.DefaultPerChannelBookieClientPool
 
- 
- All Implemented Interfaces:
- BookkeeperInternalCallbacks.GenericCallback<PerChannelBookieClient>,- PerChannelBookieClientPool
 
 class DefaultPerChannelBookieClientPool extends java.lang.Object implements PerChannelBookieClientPool, BookkeeperInternalCallbacks.GenericCallback<PerChannelBookieClient> Provide a simple round-robin style channel pool. We could improve it later to do more fantastic things.
- 
- 
Field SummaryFields Modifier and Type Field Description (package private) BookieIdaddress(package private) PerChannelBookieClient[]clients(package private) PerChannelBookieClient[]clientsV3Enforced(package private) ClientConfigurationconf(package private) java.util.concurrent.atomic.AtomicIntegercounter(package private) java.util.concurrent.atomic.AtomicLongerrorCounter(package private) PerChannelBookieClientFactoryfactory(package private) static org.slf4j.LoggerLOG(package private) SecurityHandlerFactoryshFactory
 - 
Constructor SummaryConstructors Constructor Description DefaultPerChannelBookieClientPool(ClientConfiguration conf, PerChannelBookieClientFactory factory, BookieId address, int coreSize)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckTimeoutOnPendingOperations()Check if any ops on any channel needs to be timed out.voidclose(boolean wait)Close the pool.voiddisconnect(boolean wait)Disconnect the connections in the pool.longgetNumPendingCompletionRequests()Get the number of pending completion requests in the channel.voidinitialize()initialize the pool.booleanisWritable(long key)Returns status of a client.voidobtain(BookkeeperInternalCallbacks.GenericCallback<PerChannelBookieClient> callback, long key)Obtain a channel from channel pool to execute operations.voidobtain(BookkeeperInternalCallbacks.GenericCallback<PerChannelBookieClient> callback, long key, boolean forceUseV3)Obtain a channel from channel pool by version to execute operations.voidoperationComplete(int rc, PerChannelBookieClient pcbc)voidrecordError()record any read/write error onPerChannelBookieClientPool.
 
- 
- 
- 
Field Detail- 
LOGstatic final org.slf4j.Logger LOG 
 - 
factoryfinal PerChannelBookieClientFactory factory 
 - 
addressfinal BookieId address 
 - 
clientsfinal PerChannelBookieClient[] clients 
 - 
clientsV3Enforcedfinal PerChannelBookieClient[] clientsV3Enforced 
 - 
conffinal ClientConfiguration conf 
 - 
shFactorySecurityHandlerFactory shFactory 
 - 
counterfinal java.util.concurrent.atomic.AtomicInteger counter 
 - 
errorCounterfinal java.util.concurrent.atomic.AtomicLong errorCounter 
 
- 
 - 
Constructor Detail- 
DefaultPerChannelBookieClientPoolDefaultPerChannelBookieClientPool(ClientConfiguration conf, PerChannelBookieClientFactory factory, BookieId address, int coreSize) throws SecurityException - Throws:
- SecurityException
 
 
- 
 - 
Method Detail- 
operationCompletepublic void operationComplete(int rc, PerChannelBookieClient pcbc)- Specified by:
- operationCompletein interface- BookkeeperInternalCallbacks.GenericCallback<PerChannelBookieClient>
 
 - 
initializepublic void initialize() Description copied from interface:PerChannelBookieClientPoolinitialize the pool. the implementation should not be blocked.- Specified by:
- initializein interface- PerChannelBookieClientPool
 
 - 
obtainpublic void obtain(BookkeeperInternalCallbacks.GenericCallback<PerChannelBookieClient> callback, long key) Description copied from interface:PerChannelBookieClientPoolObtain a channel from channel pool to execute operations.- Specified by:
- obtainin interface- PerChannelBookieClientPool
- Parameters:
- callback- callback to return channel from channel pool.
 
 - 
obtainpublic void obtain(BookkeeperInternalCallbacks.GenericCallback<PerChannelBookieClient> callback, long key, boolean forceUseV3) Description copied from interface:PerChannelBookieClientPoolObtain a channel from channel pool by version to execute operations.- Specified by:
- obtainin interface- PerChannelBookieClientPool
- Parameters:
- callback- callback to return channel from channel pool
- forceUseV3- whether or not use v3 protocol for connection
 
 - 
isWritablepublic boolean isWritable(long key) Description copied from interface:PerChannelBookieClientPoolReturns status of a client. It is suggested to delay/throttle requests to this channel if isWritable is false.- Specified by:
- isWritablein interface- PerChannelBookieClientPool
- Returns:
 
 - 
checkTimeoutOnPendingOperationspublic void checkTimeoutOnPendingOperations() Description copied from interface:PerChannelBookieClientPoolCheck if any ops on any channel needs to be timed out. This is called on all channels, even if the channel is not yet connected.- Specified by:
- checkTimeoutOnPendingOperationsin interface- PerChannelBookieClientPool
 
 - 
recordErrorpublic void recordError() Description copied from interface:PerChannelBookieClientPoolrecord any read/write error onPerChannelBookieClientPool.- Specified by:
- recordErrorin interface- PerChannelBookieClientPool
 
 - 
disconnectpublic void disconnect(boolean wait) Description copied from interface:PerChannelBookieClientPoolDisconnect the connections in the pool.- Specified by:
- disconnectin interface- PerChannelBookieClientPool
- Parameters:
- wait- whether need to wait until pool disconnected.
 
 - 
closepublic void close(boolean wait) Description copied from interface:PerChannelBookieClientPoolClose the pool.- Specified by:
- closein interface- PerChannelBookieClientPool
- Parameters:
- wait- whether need to wait until pool closed.
 
 - 
getNumPendingCompletionRequestspublic long getNumPendingCompletionRequests() Description copied from interface:PerChannelBookieClientPoolGet the number of pending completion requests in the channel.- Specified by:
- getNumPendingCompletionRequestsin interface- PerChannelBookieClientPool
 
 
- 
 
-