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.
|
protected boolean |
initialized
Flag indicating if the pool has initialized.
|
private static CentralLogger |
LOG
Anonymous log instance.
|
private long |
nextSessionId
The session ID generator.
|
private int |
poolSize
The number of
workers started in this pool. |
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 |
|---|---|
void |
broadcast(LegacyAppServerWork work)
Broadcast a task to all the workers.
|
boolean |
dispatch(java.lang.String connectionID,
LegacyAppServerWork work,
java.lang.String target)
Code to process appserver requests.
|
private void |
doInitialize()
Initialize this pool.
|
java.lang.String |
getAppserver()
Get the target appserver name.
|
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. |
protected boolean |
isSessionFree()
Check if the appserver connection must be in session-free mode.
|
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.
|
int |
size()
Get the size of the pool.
|
void |
terminateWorkers()
Terminate the service worker threads.
|
protected volatile boolean initialized
private static final CentralLogger 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 forWebService
private int poolSize
workers started in this pool.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 void broadcast(LegacyAppServerWork work)
work - The work to perform the request.public boolean dispatch(java.lang.String connectionID,
LegacyAppServerWork 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.public int size()
size.public java.lang.String getAppserver()
protected boolean isSessionFree()
protected void registerWorker(java.lang.String connectionID,
LegacyServiceWorker worker)
connectionID - The connection ID.worker - The service worker.