lima.distribution
Class DServer

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--lima.distribution.DServer
All Implemented Interfaces:
Observable, java.rmi.Remote, java.lang.Runnable, java.io.Serializable, WorkUnitProcessor, WorkUnitServer

public class DServer
extends java.rmi.server.UnicastRemoteObject
implements WorkUnitProcessor, WorkUnitServer, java.lang.Runnable, Observable

DServer is the magic that is a Combined WorkUnit Processor and Server. TODO Call alldone at the right time. TODO: What happens if a wu is given up on, then comes back before/after being sent back a (second time) Tested by dc

See Also:
Serialized Form

Nested Class Summary
 class DServer.ClientSpeedUpdateEvent
          An event indicating that the speed measurement of a client has been updated.
 class DServer.ClientWorkUnitRequestAcceptedEvent
          An event indicating that a request for a work unit was accepted.
 class DServer.ClientWorkUnitRequestEvent
          An event indicating that a work unit has been requested.
 class DServer.ClientWorkUnitSubmissionAcceptedEvent
          An event indicating that a submitted work unit was accepted.
 class DServer.ClientWorkUnitSubmissionEvent
          An event indicating that a work unit has been submitted.
 class DServer.JobCompletionEvent
          An event indicating that a job has been completed.
 class DServer.JobCreationEvent
          An event indicating that a job has been created.
 class DServer.JobFailureEvent
          An event indicating that a job has failed.
 class DServer.MemoryUsageEvent
          An event describing the current memory usage.
 class DServer.WorkUnitCountersEvent
          An event indicating the current work unit counter values.
 
Field Summary
static int BESTTIME
          We aim for clients to turn around a wu in this time The system will try to create cwus that thake this long in real time on a client.
static boolean DEBUG
          Set do we want to debug.
static java.lang.String serverName
          The name for this server when bound in the RMI Registry.
static boolean VERBOSE
          We can also be more verbose about what we are doing.
static int WAITTIME
          The longest time to wait for a workunit to be send back If a client takes more than this time before sending the wu back, then we assume that the client has crashed, and schedule it to be resent.
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
DServer()
          This constructor is needed since the default constructor must throw RemoteException
 
Method Summary
 void clearObservers()
          Unregister all observers for an observable object.
static void main(java.lang.String[] args)
          Start up a standalone DServer.This is the normal way to create a DServer.
 void notifyObservers(lima.observation.Event event)
          Notify all registered observers of the specified event.
 void process(lima.distribution.WorkUnitSink sink, lima.distribution.WorkUnitSource source)
          Do the job defined by source and sink.
 void registerObserver(lima.observation.Observer observer)
          Register the specified observer with an observable object.
 lima.distribution.WorkUnit requestWorkUnit()
          Called by the client when it wants more work.
 void run()
          Implementation provided for clients that require a runnable interface.
 void submitWorkUnit(lima.distribution.WorkUnit u)
          Called by the client to send back a finished work unit.
 java.lang.String toString()
          Produce a status string.
 void unregisterObserver(lima.observation.Observer observer)
          Unregister the specified observer with an observable object.
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEBUG

public static final boolean DEBUG
Set do we want to debug. Yes here will do extra (silent) tests to check sanity

See Also:
Constant Field Values

VERBOSE

public static final boolean VERBOSE
We can also be more verbose about what we are doing. With this on more data is printed to stdout.

See Also:
Constant Field Values

BESTTIME

public static final int BESTTIME
We aim for clients to turn around a wu in this time The system will try to create cwus that thake this long in real time on a client.

See Also:
Constant Field Values

WAITTIME

public static final int WAITTIME
The longest time to wait for a workunit to be send back If a client takes more than this time before sending the wu back, then we assume that the client has crashed, and schedule it to be resent. Note that this can cause a dupe to be received if the client is just very slow.

See Also:
Constant Field Values

serverName

public static final java.lang.String serverName
The name for this server when bound in the RMI Registry.

See Also:
Constant Field Values
Constructor Detail

DServer

public DServer()
        throws java.rmi.RemoteException
This constructor is needed since the default constructor must throw RemoteException

Method Detail

process

public void process(lima.distribution.WorkUnitSink sink,
                    lima.distribution.WorkUnitSource source)
             throws java.rmi.RemoteException
Do the job defined by source and sink.

Specified by:
process in interface WorkUnitProcessor
Parameters:
source - - Provides WorkUnits
sink - - Callback to flush finished workunits.
java.rmi.RemoteException
See Also:
WorkUnitProcessor.process(WorkUnitSink, WorkUnitSource)

requestWorkUnit

public lima.distribution.WorkUnit requestWorkUnit()
                                           throws java.rmi.RemoteException,
                                                  NoWorkException
Called by the client when it wants more work. Returns a wu that will take a roughtly constant time to run.

Specified by:
requestWorkUnit in interface WorkUnitServer
Returns:
WorkUnit - A WorkUnit that needs processing (call run() on it)
java.rmi.RemoteException
NoWorkException
See Also:
WorkUnitServer.requestWorkUnit()

submitWorkUnit

public void submitWorkUnit(lima.distribution.WorkUnit u)
                    throws java.rmi.RemoteException
Called by the client to send back a finished work unit. This is (and all other public methods are synchronized. This means there should only be two threads in this code at one time (the main thread and either a client or a cruncher thread.

Specified by:
submitWorkUnit in interface WorkUnitServer
Parameters:
u - - The finished WorkUnit.
java.rmi.RemoteException
See Also:
WorkUnitServer.submitWorkUnit(lima.distribution.WorkUnit)

toString

public java.lang.String toString()
Produce a status string.

Overrides:
toString in class java.rmi.server.RemoteObject
See Also:
Object.toString()

main

public static void main(java.lang.String[] args)
Start up a standalone DServer.This is the normal way to create a DServer. It should be possible to run DServer in the process of the system that creates the wus. This is not as good as providing a standalone server that supports multiple clients. Note that the processing is FCFS batch.

Parameters:
args -

run

public void run()
Implementation provided for clients that require a runnable interface.

Specified by:
run in interface java.lang.Runnable

registerObserver

public void registerObserver(lima.observation.Observer observer)
Register the specified observer with an observable object.

Specified by:
registerObserver in interface Observable

unregisterObserver

public void unregisterObserver(lima.observation.Observer observer)
Unregister the specified observer with an observable object.

Specified by:
unregisterObserver in interface Observable

clearObservers

public void clearObservers()
Unregister all observers for an observable object.

Specified by:
clearObservers in interface Observable

notifyObservers

public void notifyObservers(lima.observation.Event event)
Notify all registered observers of the specified event.

Specified by:
notifyObservers in interface Observable