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 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
FieldsModifier and TypeFieldDescription(package private) final BookieId(package private) final PerChannelBookieClient[](package private) final PerChannelBookieClient[](package private) final ClientConfiguration(package private) final AtomicInteger(package private) final AtomicLong(package private) final PerChannelBookieClientFactory(package private) static final org.slf4j.Logger(package private) SecurityHandlerFactory -
Constructor Summary
ConstructorsConstructorDescriptionDefaultPerChannelBookieClientPool(ClientConfiguration conf, PerChannelBookieClientFactory factory, BookieId address, int coreSize) -
Method Summary
Modifier and TypeMethodDescriptionvoidCheck 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.longGet the number of pending completion requests in the channel.voidinitialize 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) voidrecord any read/write error onPerChannelBookieClientPool.
-
Field Details
-
LOG
static final org.slf4j.Logger LOG -
factory
-
address
-
clients
-
clientsV3Enforced
-
conf
-
shFactory
SecurityHandlerFactory shFactory -
counter
-
errorCounter
-
-
Constructor Details
-
DefaultPerChannelBookieClientPool
DefaultPerChannelBookieClientPool(ClientConfiguration conf, PerChannelBookieClientFactory factory, BookieId address, int coreSize) throws SecurityException - Throws:
SecurityException
-
-
Method Details
-
operationComplete
- 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
-