public class LegacyServiceWorker extends java.lang.Object implements java.lang.Runnable, java.lang.Comparable<LegacyServiceWorker>
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
appserver
The appserver name.
|
private AppServerHelper |
helper
The connection to the remote appserver executing the requests.
|
private static java.util.logging.Logger |
LOG
Anonymous log instance.
|
private int |
numTasks
The number of pending tasks.
|
private boolean |
pasoe
Flag indicating if the target appserver is PASOE.
|
private AppServerConnectionPool |
pool
The service pool.
|
private java.util.Map<java.lang.Long,java.util.Set<ProxyProcedureWrapper>> |
remoteProcedures
The remote procedures currently created by this worker, per each session ID.
|
private boolean |
running
Flag indicating if the task worker is running.
|
private boolean |
sessionFree
Flag indicating if the target appserver is in Session-free mode.
|
private static ValuesCounter |
TASK_COUNTER
A counter of all tasks done by all workers.
|
private java.util.LinkedList<java.lang.Runnable> |
tasks
The tasks to be ran.
|
private java.lang.String |
threadName
The thread name where this instance runs.
|
Constructor and Description |
---|
LegacyServiceWorker(AppServerConnectionPool pool,
java.lang.String appserver,
boolean pasoe,
boolean sessionFree)
Initialize this worker.
|
Modifier and Type | Method and Description |
---|---|
void |
addProcedure(long sessionID,
ProxyProcedureWrapper proc)
Register this procedure in the specified session, as it was created by this worker's connection.
|
void |
addWork(java.lang.Runnable work)
Post a new work to the
queue . |
int |
compareTo(LegacyServiceWorker o)
Comparator to sort the workers by their load.
|
AppServerHelper |
getHelper()
Get the
AppServerHelper for this worker. |
java.util.Set<ProxyProcedureWrapper> |
getProcedures(long sessionID)
Get all the proxy remote procedures created by the given session.
|
boolean |
isPasoe()
Get the
pasoe flag. |
void |
removeProcedure(long sessionID,
ProxyProcedureWrapper proc)
Remove the specified procedure from the given session.
|
void |
removeProcedures(long sessionID)
Remove the remote procedures for the given session ID.
|
void |
run()
Main processing loop - waits for task to be posted.
|
void |
stop()
Stop the worker thread.
|
private static final java.util.logging.Logger LOG
private volatile boolean running
private static final ValuesCounter TASK_COUNTER
private final java.util.LinkedList<java.lang.Runnable> tasks
private volatile int numTasks
private AppServerHelper helper
private final java.lang.String appserver
private final boolean pasoe
private final boolean sessionFree
private AppServerConnectionPool pool
private final java.util.Map<java.lang.Long,java.util.Set<ProxyProcedureWrapper>> remoteProcedures
private java.lang.String threadName
public LegacyServiceWorker(AppServerConnectionPool pool, java.lang.String appserver, boolean pasoe, boolean sessionFree)
pool
- The service pool.appserver
- The appserver name.pasoe
- Flag indicating if the appserver is PASOE.sessionFree
- Flag indicating if the appserver is Session-free.public void addProcedure(long sessionID, ProxyProcedureWrapper proc)
sessionID
- The client session which created the proxy remote procedure.proc
- The proxy remote procedure.public void removeProcedure(long sessionID, ProxyProcedureWrapper proc)
sessionID
- The client session which created the proxy remote procedure.proc
- The proxy remote procedure.public java.util.Set<ProxyProcedureWrapper> getProcedures(long sessionID)
sessionID
- The client session which created the proxy remote procedure.remoteProcedures
.public void removeProcedures(long sessionID)
sessionID
- public boolean isPasoe()
pasoe
flag.public AppServerHelper getHelper()
AppServerHelper
for this worker.public void addWork(java.lang.Runnable work)
queue
.work
- The work to execute.public void stop()
public void run()
run
in interface java.lang.Runnable
public int compareTo(LegacyServiceWorker o)
compareTo
in interface java.lang.Comparable<LegacyServiceWorker>