Merge the ServerInvoker stuff into PresentsInvoker because the PresentsInvoker

is only ever used by the PresentsServer. Also determined that we need to
explicitly let Guice know that CrowdServer provides the PresentsServer
"interface" and so on down the line.

I also think that each concrete class needs to be marked as @Singleton though I
need to confirm that. Based on how annotations work, that's how it would be
easiest to implement, so we'll assume they're not doing extra work on the
backend to make our life easier.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5154 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2008-06-07 18:39:19 +00:00
parent 3aefc93838
commit c568204bbb
5 changed files with 45 additions and 36 deletions
@@ -30,13 +30,15 @@ import com.samskivert.util.StringUtil;
import com.threerings.util.MessageBundle;
import com.threerings.presents.dobj.RootDObjectManager;
import static com.threerings.presents.Log.log;
/**
* 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.
* 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.
*/
public abstract class RebootManager
{
@@ -60,15 +62,6 @@ public abstract class RebootManager
public void shutdownPlanned (int warningsLeft, long msLeft);
}
/**
* Creates a reboot manager that will shutdown the supplied server when the
* time comes.
*/
public RebootManager (PresentsServer server)
{
_server = server;
}
/**
* Finish initialization of the manager.
*/
@@ -154,7 +147,7 @@ public abstract class RebootManager
// should issue the first pre-reboot warning
_rebootSoon = false;
long firstWarnTime = (_nextReboot - (WARNINGS[0] * 60 * 1000)) - now;
_interval = new Interval(PresentsServer.omgr) {
_interval = new Interval(_omgr) {
public void expired () {
doWarning(0);
}
@@ -187,6 +180,15 @@ public abstract class RebootManager
}
}
/**
* Provides us with our dependencies.
*/
protected RebootManager (PresentsServer server, RootDObjectManager omgr)
{
_server = server;
_omgr = omgr;
}
/**
* Broadcasts a message to everyone on the server. The following
* messages will be broadcast:
@@ -239,7 +241,7 @@ public abstract class RebootManager
new Interval() { // Note: This interval does not run on the dobj thread
public void expired () {
// ...but we then post a LongRunnable...
PresentsServer.omgr.postRunnable(new PresentsDObjectMgr.LongRunnable() {
_omgr.postRunnable(new PresentsDObjectMgr.LongRunnable() {
public void run () {
_server.shutdown();
}
@@ -263,7 +265,7 @@ public abstract class RebootManager
}
// schedule the next warning
_interval = new Interval(PresentsServer.omgr) {
_interval = new Interval(_omgr) {
public void expired () {
doWarning(level + 1);
}
@@ -285,7 +287,7 @@ public abstract class RebootManager
log.info("Reboot delayed due to outstanding locks: " +
StringUtil.toString(_rebootLocks.elements()));
broadcast("m.reboot_delayed");
_interval = new Interval(PresentsServer.omgr) {
_interval = new Interval(_omgr) {
public void expired () {
doWarning(WARNINGS.length);
}
@@ -313,6 +315,9 @@ public abstract class RebootManager
/** The server we will reboot. */
protected PresentsServer _server;
/** Our distributed object manager. */
protected RootDObjectManager _omgr;
/** The time at which our next reboot is scheduled or 0L. */
protected long _nextReboot;
@@ -326,9 +331,7 @@ public abstract class RebootManager
protected Interval _interval;
/** A list of PendingShutdownObservers. */
protected ObserverList<PendingShutdownObserver> _observers =
new ObserverList<PendingShutdownObserver>(
ObserverList.FAST_UNSAFE_NOTIFY);
protected ObserverList<PendingShutdownObserver> _observers = ObserverList.newFastUnsafe();
/** The next reboot lock id. */
protected int _nextRebootLockId = 0;