biz.chitec.quarterback.gjsa.server
Class Killer
java.lang.Object
java.lang.Thread
biz.chitec.quarterback.util.StoppableThread
biz.chitec.quarterback.gjsa.server.Killer
- All Implemented Interfaces:
- java.lang.Runnable
- public class Killer
- extends StoppableThread
Fierce object to kill the server.
GJSA servers can be prevented by their connection handlers to be shut down at
an inconvenient time. So, after an exit request, the server does not shut down
itself immideatly, but it instanciates a Killer object which checks the open
connections in regular intervalls (evers 5 seconds) until all of them give their ok
to shut down. But the connection handlers should hurry - after 30 seconds,
armageddon is there.
Killer can be setup to wait a certain time before actually starting the killing job.
In this case, it sends every five seconds a WAITTOKILL message. Interested clients
can take these messages and show them. The killer can be stopped during this "prekill time".
- Version:
- $Id: d8ffa72415c2777fdb699bf708589606e5e2a5a6 $
- Author:
- Dirk Hillbrecht 1997-1999, chitec/Dirk Hillbrecht 2000.
Distributed under the terms of the GNU LGPL.
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary |
Killer(GJSAServer s,
int ec)
Creates a killer which does not send TIMETOKILL messages |
Killer(GJSAServer s,
int ec,
java.lang.String configloggername)
Creates killer.
|
Method Summary |
void |
run()
Runs the killer |
void |
setKillMessage(java.lang.String messagex)
Sets a message which is sent to logger if killer starts and prekill time is set |
void |
setPrekillTime(int seconds)
Sets the time to wait until actually killing the server |
void |
stopGracefully()
Stops the killer if it is in prekill time.
|
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
maximumwait
private static final long maximumwait
- See Also:
- Constant Field Values
server
protected GJSAServer server
exitcode
protected int exitcode
mess
protected Logger mess
config
protected Logger config
prekilltime
protected int prekilltime
prekillphase
protected boolean prekillphase
killmessage
protected java.lang.String killmessage
Killer
public Killer(GJSAServer s,
int ec,
java.lang.String configloggername)
- Creates killer.
The killer is not started yet after initialization. start() must be called additionally.
- Parameters:
s
- Server to killec
- Exitcode to send with System.exit()configloggername
- Name of a logging receiver which receives the TIMETOKILL messages
Killer
public Killer(GJSAServer s,
int ec)
- Creates a killer which does not send TIMETOKILL messages
- Parameters:
s
- Server to killec
- Exitcode to send with System.exit()
setPrekillTime
public void setPrekillTime(int seconds)
- Sets the time to wait until actually killing the server
- Parameters:
seconds
- Seconds to wait.
setKillMessage
public void setKillMessage(java.lang.String messagex)
- Sets a message which is sent to logger if killer starts and prekill time is set
- Parameters:
messagex
- Message sent through config logger
stopGracefully
public void stopGracefully()
- Stops the killer if it is in prekill time.
If the killer is already in real killing phase, stopping is not possible any more. In this case a CommandException is thrown.
It is possible but unlikely that the exception is thrown but the killer is stopped anyway. The opposite race condition
cannot occur.
- Overrides:
stopGracefully
in class StoppableThread
- Throws:
CommandException
- if the killer cannot be killed any more
run
public void run()
- Runs the killer