public class AppServerConnectionPool
extends java.lang.Object
workers
, which have a FWD context as configured in the
client's type (directory's soap, rest, web app node).
The workers are automatically connected when the first task is received. The workers should have a 1-to-1 mapping between them and the agents, and the pool size should never be configured larger than the number of agents available.
Modifier and Type | Field and Description |
---|---|
private boolean |
forWebService
Flag indicating if this worker pool is for web services managed by FWD.
|
private boolean |
initialized
Flag indicating if the pool has initialized.
|
private static java.util.logging.Logger |
LOG
Anonymous log instance.
|
private long |
nextSessionId
The session ID generator.
|
private int |
timeout
The timeout for a service call, defaults to 10 seconds.
|
private java.lang.String |
type
The directory node from where to read the configuration (rest, soap, WebHandler, someWebApp).
|
private java.util.concurrent.PriorityBlockingQueue<LegacyServiceWorker> |
workers
The pool of workers dedicated to executing legacy services.
|
private java.util.Map<java.lang.String,LegacyServiceWorker> |
workersByConnection
Mapping of workers by their connection ID.
|
Constructor and Description |
---|
AppServerConnectionPool(java.lang.String type)
Create a new pool.
|
Modifier and Type | Method and Description |
---|---|
boolean |
dispatch(java.lang.String connectionID,
java.util.function.Consumer<LegacyServiceWorker> work,
java.lang.String target)
Code to process appserver requests.
|
private void |
doInitialize()
Initialize this pool.
|
int |
getTimeout()
Get the
timeout . |
java.lang.String |
getType()
Get the service handler's
type . |
void |
initialize()
Initialize the connection pool, in a separate thread.
|
boolean |
isInitialized()
Get the state of the
initialized flag. |
boolean |
isWebService()
Check if this pool is for web services ran from within FWD.
|
long |
nextSessionId()
Get the next session ID.
|
protected void |
registerWorker(java.lang.String connectionID,
LegacyServiceWorker worker)
Register the worker with the specified connection ID.
|
void |
setWebService()
Mark this pool as used internally by FWD, for web services.
|
void |
terminateWorkers()
Terminate the service worker threads.
|
private static final java.util.logging.Logger LOG
private java.util.concurrent.PriorityBlockingQueue<LegacyServiceWorker> workers
private java.util.Map<java.lang.String,LegacyServiceWorker> workersByConnection
private volatile int timeout
private final java.lang.String type
private long nextSessionId
private volatile boolean initialized
private volatile boolean forWebService
public AppServerConnectionPool(java.lang.String type)
type
- The directory node from where to read the configuration.public long nextSessionId()
public void setWebService()
public boolean isWebService()
public boolean isInitialized()
initialized
flag.public boolean dispatch(java.lang.String connectionID, java.util.function.Consumer<LegacyServiceWorker> work, java.lang.String target)
connectionID
- When not-null, force to use the worker with the specified connection ID.work
- The work to perform the request.target
- The target path.true
if the request was processed by a worker
.public void terminateWorkers()
public void initialize()
private void doInitialize()
public java.lang.String getType()
type
.public int getTimeout()
timeout
.protected void registerWorker(java.lang.String connectionID, LegacyServiceWorker worker)
connectionID
- The connection ID.worker
- The service worker.