|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.flat502.rox.processing.ResourcePool com.flat502.rox.client.ClientResourcePool
public class ClientResourcePool
Constructor Summary | |
---|---|
ClientResourcePool()
|
Method Summary | |
---|---|
protected void |
detach(HttpRpcClient client)
|
java.lang.Object |
getNotifierMutex()
|
long |
getRequestTimeout()
|
com.flat502.rox.client.SharedSocketChannelPool |
getSocketChannelPool()
|
protected java.lang.Thread |
newProcessingThread(java.lang.Runnable target)
A factory method for creating the central HTTP processing thread. |
protected com.flat502.rox.client.SharedSocketChannelPool |
newSharedSocketChannelPool(java.lang.Object mutex,
int limit,
long timeout)
|
protected HttpMessageHandler |
newWorker()
|
protected void |
notifyUnownedChannelClosure(java.nio.channels.SocketChannel channel)
|
void |
registerProfiler(Profiler p)
|
void |
setConnectionPoolLimit(int limit)
Configure a limit on the number of active connections provided at any given time by the underlying connection pool. |
void |
setConnectionPoolTimeout(long timeout)
Configure a timeout value for the underlying connection pool. |
void |
setRequestTimeout(long timeout)
Configure a default timeout value for RPC method calls. |
void |
shutdown()
|
Methods inherited from class com.flat502.rox.processing.ResourcePool |
---|
addWorker, addWorkers, detach, getChannelSelector, getProfilers, getQueue, getTimer, getWorkerCount, newChannelSelector, newQueue, removeWorker, startProcessingThread |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ClientResourcePool()
Method Detail |
---|
public void registerProfiler(Profiler p)
registerProfiler
in class ResourcePool
public java.lang.Object getNotifierMutex()
public void setConnectionPoolLimit(int limit)
If a non-zero limit is configured, any thread requesting a new connection
that would cause this limit to be exceeded will be blocked
until an existing connection is returned or until a timeout
occurs (if a timeout has been set
).
Care should be taken when using the asynchronous execution API without a limit on the connection pool. It's very easy to consume all available local connections like this.
If a non-zero limit is placed on the connection pool then you
must be sure to set a timeout
on the pool. Failure to do so will result in threads blocking
indefinitely when the connection pool is exhausted.
limit
- The maximum number of active connections allowed at any given moment.
A value of 0 indicates no limit should be enforced (this is the default value).
java.lang.IllegalArgumentException
- If the timeout provided is negative.
java.lang.IllegalStateException
- If any of the execute
methods were invoked before
this method was invoked.public void setConnectionPoolTimeout(long timeout)
This timeout only applies if a limit has been set on the number
of active connections (using setConnectionPoolLimit(int)
.
If a limit is configured this timeout controls how long a thread
will be blocked waiting for a new connection before a
ConnectionPoolTimeoutException
is raised.
timeout
- The timeout (in milliseconds). A value of 0 indicates no timeout should be
enforced (this is the default value).
java.lang.IllegalArgumentException
- If the timeout provided is negative.
java.lang.IllegalStateException
- If any of the execute
methods were invoked before
this method was invoked.public void setRequestTimeout(long timeout)
All HttpRpcClient
instances sharing a resource pool
"inherit" this timeout as their initial timeout value.
timeout
- The timeout (in milliseconds). A value of 0 indicates no timeout should be
enforced.
java.lang.IllegalArgumentException
- If the timeout provided is negative.HttpRpcClient.setRequestTimeout(long)
public long getRequestTimeout()
public com.flat502.rox.client.SharedSocketChannelPool getSocketChannelPool()
protected com.flat502.rox.client.SharedSocketChannelPool newSharedSocketChannelPool(java.lang.Object mutex, int limit, long timeout)
public void shutdown()
shutdown
in class ResourcePool
protected HttpMessageHandler newWorker()
newWorker
in class ResourcePool
protected java.lang.Thread newProcessingThread(java.lang.Runnable target)
ResourcePool
Sub-classes may override this method if an alternative
implementation is required, or to alter properties of
the thread that is created by default, but they should
not invoke the Thread.start()
method.
newProcessingThread
in class ResourcePool
HttpRpcProcessor
.protected void detach(HttpRpcClient client) throws java.io.IOException
java.io.IOException
protected void notifyUnownedChannelClosure(java.nio.channels.SocketChannel channel)
notifyUnownedChannelClosure
in class ResourcePool
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |