@Deprecated public abstract class BaseHelper<T extends Connector> extends ConnectorHelper<T>
Parameter name | Value type | Default value | Description |
---|---|---|---|
controllerDaemon | boolean | true (client), false (server) | Indicates if the controller thread should be a daemon (not blocking JVM exit). |
controllerSleepTimeMs | int | 60 000 | Time for the controller thread to sleep between each control. A value strictly superior to 0 is required. |
minThreads | int | 1 | Minimum number of worker threads waiting to service calls, even if they are idle. Technically speaking, this is a core number of threads that are pre-started. |
lowThreads | int | 8 | Number of worker threads determining when the connector is considered overloaded. This triggers some protection actions such as not accepting new connections. |
maxThreads | int | 10 | Maximum number of worker threads that can service calls. If this number is reached then additional calls are queued if the "maxQueued" value hasn't been reached. |
maxQueued | int | 0 | Maximum number of calls that can be queued if there aren't any worker
thread available to service them. If the value is '0', then no queue is used
and calls are rejected if no worker thread is immediately available. If the
value is '-1', then an unbounded queue is used and calls are never rejected. Note: make sure that this value is consistent with getMinThreads()
and the behavior of the ThreadPoolExecutor configured internally. |
maxIoIdleTimeMs | int | 60 000 | Maximum time for an idle IO connection or request to wait for an operation before being closed. For an unlimited wait, use '0' as value. |
maxThreadIdleTimeMs | int | 300 000 | Time for an idle thread to wait for an operation before being collected. |
tracing | boolean | false | Indicates if all messages should be printed on the standard console. |
workerThreads | boolean | true | Indicates if the processing of calls should be done via threads provided by a worker service (i.e. a pool of worker threads). Note that if set to false, calls will be processed a single IO selector thread, which should never block, otherwise the other connections would hang. |
inboundBufferSize | int | 16 * 1024 | Size of the content buffer for receiving messages. |
outboundBufferSize | int | 32 * 1024 | Size of the content buffer for sending messages. |
directBuffers | boolean | false | Indicates if direct NIO buffers should be allocated instead of regular buffers. See NIO's ByteBuffer Javadocs. Note that tracing must be disabled to use direct buffers. |
throttleTimeMs | int | 0 | Time to wait between socket write operations in milliseconds. Can prevent TCP buffer overflows. |
transport | String | TCP | Indicates the transport protocol such as TCP or UDP. |
Modifier and Type | Field and Description |
---|---|
protected boolean |
clientSide
Deprecated.
Indicates if it is helping a client connector.
|
protected org.restlet.ext.nio.internal.controller.ConnectionController |
controller
Deprecated.
The controller task.
|
protected java.util.Queue<Response> |
inboundMessages
Deprecated.
The queue of inbound messages.
|
protected java.util.Queue<Response> |
outboundMessages
Deprecated.
The queue of outbound messages.
|
Constructor and Description |
---|
BaseHelper(T connector,
boolean clientSide)
Deprecated.
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
control()
Deprecated.
Controls the helper for inbound or outbound messages to handle.
|
protected abstract org.restlet.ext.nio.internal.controller.ConnectionController |
createController()
Deprecated.
Creates a new controller.
|
protected java.util.concurrent.ExecutorService |
createControllerService()
Deprecated.
Creates the connector controller service.
|
protected Request |
createRequest()
Deprecated.
Creates the request object.
|
protected java.util.concurrent.ThreadPoolExecutor |
createWorkerService()
Deprecated.
Creates the handler service.
|
protected void |
doFinishStop()
Deprecated.
Finish stopping the helper.
|
protected void |
doGracefulStop()
Deprecated.
Do a graceful stop first.
|
abstract void |
doHandleInbound(Response response)
Deprecated.
Effectively handles an inbound message.
|
abstract void |
doHandleOutbound(Response response)
Deprecated.
Effectively handles an outbound message.
|
protected void |
execute(java.lang.Runnable task)
Deprecated.
Executes the next task in a separate thread provided by the worker
service, only if the worker service isn't busy.
|
org.restlet.ext.nio.internal.controller.ConnectionController |
getController()
Deprecated.
Returns the controller task.
|
int |
getControllerSleepTimeMs()
Deprecated.
Returns the time for the controller thread to sleep between each control.
|
int |
getInboundBufferSize()
Deprecated.
Returns the size of the content buffer for receiving messages.
|
java.util.Queue<Response> |
getInboundMessages()
Deprecated.
Returns the queue of inbound messages pending for handling.
|
int |
getLowThreads()
Deprecated.
Returns the number of threads for the overload state.
|
int |
getMaxIoIdleTimeMs()
Deprecated.
Returns the time for an idle IO connection or request to wait for an
operation before being closed.
|
int |
getMaxQueued()
Deprecated.
Returns the maximum number of calls that can be queued if there aren't
any worker thread available to service them.
|
int |
getMaxThreadIdleTimeMs()
Deprecated.
Returns the time for an idle thread to wait for an operation before being
collected.
|
int |
getMaxThreads()
Deprecated.
Returns the maximum threads that will service requests.
|
int |
getMinThreads()
Deprecated.
Returns the minimum threads waiting to service requests.
|
int |
getOutboundBufferSize()
Deprecated.
Returns the size of the content buffer for sending responses.
|
protected java.util.Queue<Response> |
getOutboundMessages()
Deprecated.
Returns the queue of outbound messages pending for handling.
|
Request |
getRequest(Response response)
Deprecated.
Returns the parent request of this response.
|
int |
getThrottleTimeMs()
Deprecated.
Returns the time to wait between socket write operations in milliseconds.
|
java.io.OutputStream |
getTraceStream()
Deprecated.
Returns the trace output stream to use if tracing is enabled.
|
java.lang.String |
getTransport()
Deprecated.
Returns the transport protocol.
|
java.util.concurrent.ThreadPoolExecutor |
getWorkerService()
Deprecated.
Returns the connection handler service.
|
protected abstract void |
handleInbound(Response response)
Deprecated.
Handle the given inbound message.
|
protected void |
handleInbound(Response response,
boolean synchronous)
Deprecated.
Handle the given inbound message.
|
protected abstract void |
handleOutbound(Response response)
Deprecated.
Handle the given outbound message.
|
protected void |
handleOutbound(Response response,
boolean synchronous)
Deprecated.
Handle the given outbound message.
|
boolean |
hasWorkerThreads()
Deprecated.
Indicates if the worker service (pool of worker threads) is enabled.
|
boolean |
isClientSide()
Deprecated.
Indicates if it is helping a client connector.
|
abstract boolean |
isControllerDaemon()
Deprecated.
Indicates if the controller thread should be a daemon (not blocking JVM
exit).
|
boolean |
isDirectBuffers()
Deprecated.
Indicates if direct NIO buffers should be used.
|
boolean |
isServerSide()
Deprecated.
Indicates if it is helping a server connector.
|
boolean |
isTracing()
Deprecated.
Indicates if console tracing is enabled.
|
boolean |
isWorkerServiceOverloaded()
Deprecated.
Indicates if the worker service is busy.
|
void |
onInboundError(Status status,
Response message)
Deprecated.
Called on error.
|
void |
onOutboundError(Status status,
Response message)
Deprecated.
Called on error.
|
void |
start()
Deprecated.
|
void |
stop()
Deprecated.
|
void |
traceWorkerService()
Deprecated.
Adds traces on the worker service.
|
getConnectorService, getContext, getProtocols, update
getAttributes, getHelped, getHelpedParameters, getLogger, getMetadataService, handle, setHelped
protected final boolean clientSide
protected final org.restlet.ext.nio.internal.controller.ConnectionController controller
protected final java.util.Queue<Response> inboundMessages
protected final java.util.Queue<Response> outboundMessages
public BaseHelper(T connector, boolean clientSide)
connector
- The helped connector.clientSide
- True if it is helping a client connector.public boolean control()
protected abstract org.restlet.ext.nio.internal.controller.ConnectionController createController()
protected java.util.concurrent.ExecutorService createControllerService()
protected Request createRequest()
protected java.util.concurrent.ThreadPoolExecutor createWorkerService()
protected void doFinishStop()
protected void doGracefulStop()
public abstract void doHandleInbound(Response response)
response
- The response to handle.public abstract void doHandleOutbound(Response response)
response
- The response to handle.protected void execute(java.lang.Runnable task)
task
- The next task to execute.public org.restlet.ext.nio.internal.controller.ConnectionController getController()
public int getControllerSleepTimeMs()
public int getInboundBufferSize()
public java.util.Queue<Response> getInboundMessages()
public int getLowThreads()
public int getMaxIoIdleTimeMs()
public int getMaxQueued()
getMinThreads()
and the behavior of the
ThreadPoolExecutor
configured internally.public int getMaxThreadIdleTimeMs()
public int getMaxThreads()
public int getMinThreads()
public int getOutboundBufferSize()
protected java.util.Queue<Response> getOutboundMessages()
public Request getRequest(Response response)
response
- The response to analyze.public int getThrottleTimeMs()
public java.io.OutputStream getTraceStream()
public java.lang.String getTransport()
public java.util.concurrent.ThreadPoolExecutor getWorkerService()
protected abstract void handleInbound(Response response)
response
- The message to handle.protected void handleInbound(Response response, boolean synchronous)
response
- The message to handle.synchronous
- True if the current thread should be used.protected abstract void handleOutbound(Response response)
response
- The message to handle.protected void handleOutbound(Response response, boolean synchronous)
response
- The message to handle.synchronous
- True if the current thread should be used.public boolean hasWorkerThreads()
public boolean isClientSide()
public abstract boolean isControllerDaemon()
public boolean isDirectBuffers()
public boolean isServerSide()
public boolean isTracing()
public boolean isWorkerServiceOverloaded()
public void onInboundError(Status status, Response message)
status
- The error status to set on the responses.message
- The message to unblock.public void onOutboundError(Status status, Response message)
status
- The error status to set on the responses.message
- The message to unblock.public void start() throws java.lang.Exception
start
in class ConnectorHelper<T extends Connector>
java.lang.Exception
public void stop() throws java.lang.Exception
stop
in class ConnectorHelper<T extends Connector>
java.lang.Exception
public void traceWorkerService()
Copyright © 2005-2020 Restlet.