voldemort.store.socket.clientrequest
Class ClientRequestExecutorPool

java.lang.Object
  extended by voldemort.store.socket.clientrequest.ClientRequestExecutorPool
All Implemented Interfaces:
SocketStoreFactory

public class ClientRequestExecutorPool
extends java.lang.Object
implements SocketStoreFactory

A pool of ClientRequestExecutor keyed off the SocketDestination. This is a wrapper around QueuedKeyedResourcePool that translates exceptions, provides some JMX access, and handles asynchronous requests for SocketDestinations.

Upon successful construction of this object, a new Thread is started. It is terminated upon calling close().


Constructor Summary
ClientRequestExecutorPool(int maxConnectionsPerNode, int connectionTimeoutMs, int soTimeoutMs, int socketBufferSize)
           
ClientRequestExecutorPool(int selectors, int maxConnectionsPerNode, int connectionTimeoutMs, int soTimeoutMs, int socketBufferSize, boolean socketKeepAlive)
           
ClientRequestExecutorPool(int selectors, int maxConnectionsPerNode, int connectionTimeoutMs, int soTimeoutMs, int socketBufferSize, boolean socketKeepAlive, boolean jmxEnabled, int jmxId)
           
 
Method Summary
 void checkin(SocketDestination destination, ClientRequestExecutor clientRequestExecutor)
          Check the socket back into the pool.
 ClientRequestExecutor checkout(SocketDestination destination)
          Checkout a socket from the pool
 void close()
          Permanently close the ClientRequestExecutor pool.
 void close(SocketDestination destination)
          Reset the pool of resources for a specific destination.
 SocketStore create(java.lang.String storeName, java.lang.String hostName, int port, RequestFormatType requestFormatType, RequestRoutingType requestRoutingType)
          Create a new socket store to talk to a given server for a specific store Note: IGNORE_CHECKS will only be honored for Protobuf request format
 ClientRequestExecutorFactory getFactory()
           
 ClientSocketStats getStats()
           
<T> void
submitAsync(SocketDestination destination, ClientRequest<T> delegate, NonblockingStoreCallback callback, long timeoutMs, java.lang.String operationName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientRequestExecutorPool

public ClientRequestExecutorPool(int selectors,
                                 int maxConnectionsPerNode,
                                 int connectionTimeoutMs,
                                 int soTimeoutMs,
                                 int socketBufferSize,
                                 boolean socketKeepAlive,
                                 boolean jmxEnabled,
                                 int jmxId)

ClientRequestExecutorPool

public ClientRequestExecutorPool(int selectors,
                                 int maxConnectionsPerNode,
                                 int connectionTimeoutMs,
                                 int soTimeoutMs,
                                 int socketBufferSize,
                                 boolean socketKeepAlive)

ClientRequestExecutorPool

public ClientRequestExecutorPool(int maxConnectionsPerNode,
                                 int connectionTimeoutMs,
                                 int soTimeoutMs,
                                 int socketBufferSize)
Method Detail

getFactory

public ClientRequestExecutorFactory getFactory()

create

public SocketStore create(java.lang.String storeName,
                          java.lang.String hostName,
                          int port,
                          RequestFormatType requestFormatType,
                          RequestRoutingType requestRoutingType)
Create a new socket store to talk to a given server for a specific store Note: IGNORE_CHECKS will only be honored for Protobuf request format

Specified by:
create in interface SocketStoreFactory
Parameters:
storeName -
hostName -
port -
requestFormatType - protocol to use
requestRoutingType - routed/ignore checks/normal
Returns:
New SocketStore

checkout

public ClientRequestExecutor checkout(SocketDestination destination)
Checkout a socket from the pool

Parameters:
destination - The socket destination you want to connect to
Returns:
The socket

checkin

public void checkin(SocketDestination destination,
                    ClientRequestExecutor clientRequestExecutor)
Check the socket back into the pool.

Parameters:
destination - The socket destination of the socket
clientRequestExecutor - The request executor wrapper

close

public void close(SocketDestination destination)
Reset the pool of resources for a specific destination. Idle resources will be destroyed. Checked out resources that are subsequently checked in will be destroyed. Newly created resources can be checked in to reestablish resources for the specific destination.

Specified by:
close in interface SocketStoreFactory
Parameters:
destination - SocketDestination representing the host name, port, etc. for a remote host

close

public void close()
Permanently close the ClientRequestExecutor pool. Resources subsequently checked in will be destroyed.

Specified by:
close in interface SocketStoreFactory

getStats

public ClientSocketStats getStats()

submitAsync

public <T> void submitAsync(SocketDestination destination,
                            ClientRequest<T> delegate,
                            NonblockingStoreCallback callback,
                            long timeoutMs,
                            java.lang.String operationName)


Jay Kreps, Roshan Sumbaly, Alex Feinberg, Bhupesh Bansal, Lei Gao, Chinmay Soman, Vinoth Chandar, Zhongjie Wu