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 Summary
Fields 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 Summary
Constructors Constructor Description DefaultPerChannelBookieClientPool(ClientConfiguration conf, PerChannelBookieClientFactory factory, BookieId address, int coreSize)
-
Method Summary
All 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
-
LOG
static final org.slf4j.Logger LOG
-
factory
final PerChannelBookieClientFactory factory
-
address
final BookieId address
-
clients
final PerChannelBookieClient[] clients
-
clientsV3Enforced
final PerChannelBookieClient[] clientsV3Enforced
-
conf
final ClientConfiguration conf
-
shFactory
SecurityHandlerFactory shFactory
-
counter
final java.util.concurrent.atomic.AtomicInteger counter
-
errorCounter
final java.util.concurrent.atomic.AtomicLong errorCounter
-
-
Constructor Detail
-
DefaultPerChannelBookieClientPool
DefaultPerChannelBookieClientPool(ClientConfiguration conf, PerChannelBookieClientFactory factory, BookieId address, int coreSize) throws SecurityException
- Throws:
SecurityException
-
-
Method Detail
-
operationComplete
public void operationComplete(int rc, PerChannelBookieClient pcbc)- Specified by:
operationCompletein interfaceBookkeeperInternalCallbacks.GenericCallback<PerChannelBookieClient>
-
initialize
public void initialize()
Description copied from interface:PerChannelBookieClientPoolinitialize the pool. the implementation should not be blocked.- Specified by:
initializein interfacePerChannelBookieClientPool
-
obtain
public void obtain(BookkeeperInternalCallbacks.GenericCallback<PerChannelBookieClient> callback, long key)
Description copied from interface:PerChannelBookieClientPoolObtain a channel from channel pool to execute operations.- Specified by:
obtainin interfacePerChannelBookieClientPool- Parameters:
callback- callback to return channel from channel pool.
-
obtain
public 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 interfacePerChannelBookieClientPool- Parameters:
callback- callback to return channel from channel poolforceUseV3- whether or not use v3 protocol for connection
-
isWritable
public 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 interfacePerChannelBookieClientPool- Returns:
-
checkTimeoutOnPendingOperations
public 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 interfacePerChannelBookieClientPool
-
recordError
public void recordError()
Description copied from interface:PerChannelBookieClientPoolrecord any read/write error onPerChannelBookieClientPool.- Specified by:
recordErrorin interfacePerChannelBookieClientPool
-
disconnect
public void disconnect(boolean wait)
Description copied from interface:PerChannelBookieClientPoolDisconnect the connections in the pool.- Specified by:
disconnectin interfacePerChannelBookieClientPool- Parameters:
wait- whether need to wait until pool disconnected.
-
close
public void close(boolean wait)
Description copied from interface:PerChannelBookieClientPoolClose the pool.- Specified by:
closein interfacePerChannelBookieClientPool- Parameters:
wait- whether need to wait until pool closed.
-
getNumPendingCompletionRequests
public long getNumPendingCompletionRequests()
Description copied from interface:PerChannelBookieClientPoolGet the number of pending completion requests in the channel.- Specified by:
getNumPendingCompletionRequestsin interfacePerChannelBookieClientPool
-
-