|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.presents.server.RebootManager
public abstract class RebootManager
Handles scheduling and execution of automated server reboots. Note that this service simply shuts down the server and assumes it will be automatically restarted by some external entity. It is generally useful to run a server from a script that automatically restarts it when it terminates.
| Nested Class Summary | |
|---|---|
static interface |
RebootManager.PendingShutdownObserver
An interface for receiving notifications about pending automated shutdowns. |
| Field Summary | |
|---|---|
protected String |
_initiator
The entity that scheduled the reboot. |
protected Interval |
_interval
The interval scheduled to perform the next step the reboot process. |
protected long |
_nextReboot
The time at which our next reboot is scheduled or 0L. |
protected int |
_nextRebootLockId
The next reboot lock id. |
protected ObserverList<RebootManager.PendingShutdownObserver> |
_observers
A list of PendingShutdownObservers. |
protected RootDObjectManager |
_omgr
Our distributed object manager. |
protected HashIntMap<String> |
_rebootLocks
Things that can delay the reboot. |
protected boolean |
_rebootSoon
True if the reboot is coming soon, within the earliest warning. |
protected PresentsServer |
_server
The server that we're going to reboot. |
protected static String |
AUTOMATIC_INITIATOR
|
static int[] |
DEFAULT_WARNINGS
The default warning times. |
| Constructor Summary | |
|---|---|
protected |
RebootManager(PresentsServer server,
RootDObjectManager omgr)
Provides us with our dependencies. |
| Method Summary | |
|---|---|
void |
addObserver(RebootManager.PendingShutdownObserver observer)
Add an observer to the observer list. |
void |
allowReboot(int lockId)
Release a reboot lock. |
protected abstract void |
broadcast(String message)
Broadcasts a message to everyone on the server. |
protected boolean |
checkLocks()
Check to see if there are outstanding reboot locks that may delay the reboot, returning false if there are none. |
protected void |
doWarning(int level)
Do a warning, schedule the next. |
protected abstract String |
getCustomRebootMessage()
Returns a custom message to be used when broadcasting a pending reboot. |
protected abstract int |
getDayFrequency()
Returns the frequency in days of our automatic reboots, or -1 to disable automatically scheduled reboots. |
protected abstract int |
getRebootHour()
Returns the desired hour at which to perform our reboot. |
protected String |
getRebootMessage(String key,
int minutes)
Composes the given reboot message with the minutes and either the custom or standard details about the pending reboot. |
protected abstract boolean |
getSkipWeekends()
Returns true if the reboot manager should avoid scheduling automated reboots on the weekends. |
int[] |
getWarnings()
Returns the minutes at which we give warnings. |
void |
init()
Finishes initialization of the manager. |
protected void |
notifyObservers(int level)
Notify all PendingShutdownObservers of the pending shutdown! |
int |
preventReboot(String whereFrom)
Called by an entity that would like to prevent a reboot. |
void |
scheduleReboot(long rebootTime,
String initiator)
Schedules a reboot for the specified time. |
boolean |
scheduleRegularReboot()
Schedules our next regularly scheduled reboot. |
boolean |
willShutdownSoon()
Is the manager planning a shutdown in the near future? |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int[] DEFAULT_WARNINGS
protected PresentsServer _server
protected RootDObjectManager _omgr
protected long _nextReboot
protected String _initiator
protected boolean _rebootSoon
protected Interval _interval
protected ObserverList<RebootManager.PendingShutdownObserver> _observers
protected int _nextRebootLockId
protected HashIntMap<String> _rebootLocks
protected static final String AUTOMATIC_INITIATOR
| Constructor Detail |
|---|
protected RebootManager(PresentsServer server,
RootDObjectManager omgr)
| Method Detail |
|---|
public void init()
public boolean scheduleRegularReboot()
public boolean willShutdownSoon()
public void addObserver(RebootManager.PendingShutdownObserver observer)
public void scheduleReboot(long rebootTime,
String initiator)
public int preventReboot(String whereFrom)
public void allowReboot(int lockId)
public int[] getWarnings()
protected abstract void broadcast(String message)
protected abstract int getDayFrequency()
protected abstract int getRebootHour()
protected abstract boolean getSkipWeekends()
protected abstract String getCustomRebootMessage()
protected String getRebootMessage(String key,
int minutes)
protected void doWarning(int level)
protected boolean checkLocks()
protected void notifyObservers(int level)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||