ServerCommunicatorAdminpublic abstract class ServerCommunicatorAdmin extends Object
Fields Summary |
---|
private long | timestamp | private final int[] | lock | private int | currentJobs | private long | timeout | private boolean | terminated | private static final ClassLogger | logger | private static final ClassLogger | timelogger |
Constructors Summary |
---|
public ServerCommunicatorAdmin(long timeout)
if (logger.traceOn()) {
logger.trace("Constructor",
"Creates a new ServerCommunicatorAdmin object "+
"with the timeout "+timeout);
}
this.timeout = timeout;
timestamp = 0;
if (timeout < Long.MAX_VALUE) {
Runnable timeoutTask = new Timeout();
final Thread t = new Thread(timeoutTask);
t.setName("JMX server connection timeout " + t.getId());
// If you change this name you will need to change a unit test
// (NoServerTimeoutTest)
t.setDaemon(true);
t.start();
}
|
Methods Summary |
---|
protected abstract void | doStop()Called by this class to tell an implementation to do stop.
| private void | logtime(java.lang.String desc, long time)
timelogger.trace("synchro",desc+time);
| public boolean | reqIncoming()Tells that a new request message is received.
A caller of this method should always call the method
rspOutgoing to inform that a response is sent out
for the received request.
if (logger.traceOn()) {
logger.trace("reqIncoming", "Receive a new request.");
}
synchronized(lock) {
if (terminated) {
logger.warning("reqIncoming",
"The server has decided to close " +
"this client connection.");
}
++currentJobs;
return terminated;
}
| public boolean | rspOutgoing()Tells that a response is sent out for a received request.
if (logger.traceOn()) {
logger.trace("reqIncoming", "Finish a request.");
}
synchronized(lock) {
if (--currentJobs == 0) {
timestamp = System.currentTimeMillis();
logtime("Admin: Timestamp=",timestamp);
// tells the adminor to restart waiting with timeout
lock.notify();
}
return terminated;
}
| public void | terminate()Terminates this object.
Called only by outside, so do not need to call doStop
if (logger.traceOn()) {
logger.trace("terminate",
"terminate the ServerCommunicatorAdmin object.");
}
synchronized(lock) {
if (terminated) {
return;
}
terminated = true;
// tell Timeout to terminate
lock.notify();
}
|
|