jist.runtime
Class RemoteJist.JobQueueServer

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by jist.runtime.RemoteJist.JobQueueServer
All Implemented Interfaces:
java.io.Serializable, java.rmi.Remote, RemoteJist.JobQueueServerRemote
Enclosing class:
RemoteJist

public static class RemoteJist.JobQueueServer
extends java.rmi.server.UnicastRemoteObject
implements RemoteJist.JobQueueServerRemote

Job queue server.

See Also:
Serialized Form

Field Summary
static java.lang.String JIST_JOBSERVER_RMI_NAME
          RMI name of job queue server.
private  java.util.Vector jobs
          job queue.
private  RemoteIO.RemoteOutputStreamReceiver rout
          local server output stream.
private  int serversWaiting
          number of server in wait lock.
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
RemoteJist.JobQueueServer(int port, java.io.PrintStream out)
          Start new job queue server.
 
Method Summary
 void addJob(RemoteJist.Job job, boolean front)
          Add job to queue.
 RemoteJist.Job getJob(long maxMem)
          Return next job from queue, or null if queue is empty.
static RemoteJist.JobQueueServerRemote getRemote(Node n)
          Return stub of remote job queue server.
 RemoteIO.RemoteOutputStreamRemote getStdOut()
          Return RMI handle to queue standard output stream.
private  int numJobsConstraints(long maxMem)
          Return number of queued jobs that satisfy server constraints.
private  boolean satisfyConstraint(RemoteJist.Job j, long maxMem)
          Determine whether server resources satisfy job constraints.
private  void showJobs()
          Show list of currently queued simulation jobs.
 void waitForJob(long maxMem)
          Wait for job.
private  void writeln(java.lang.String s)
          Write line to output (appending newline).
 
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, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

JIST_JOBSERVER_RMI_NAME

public static final java.lang.String JIST_JOBSERVER_RMI_NAME
RMI name of job queue server.

See Also:
Constant Field Values

jobs

private java.util.Vector jobs
job queue.


serversWaiting

private int serversWaiting
number of server in wait lock.


rout

private RemoteIO.RemoteOutputStreamReceiver rout
local server output stream.

Constructor Detail

RemoteJist.JobQueueServer

public RemoteJist.JobQueueServer(int port,
                                 java.io.PrintStream out)
                          throws java.rmi.RemoteException
Start new job queue server.

Parameters:
port - rmi listen port
out - local server output stream
Throws:
java.rmi.RemoteException - rpc failure
Method Detail

getRemote

public static RemoteJist.JobQueueServerRemote getRemote(Node n)
                                                 throws java.rmi.NotBoundException,
                                                        java.net.MalformedURLException,
                                                        java.rmi.RemoteException
Return stub of remote job queue server.

Parameters:
n - node (host:port) of remote job queue server
Returns:
stub of remote job queue server
Throws:
java.rmi.NotBoundException - when jist not bound (started) on remote server
java.net.MalformedURLException - never
java.rmi.RemoteException - rpc failure

showJobs

private void showJobs()
               throws java.rmi.RemoteException
Show list of currently queued simulation jobs.

Throws:
java.rmi.RemoteException - rpc failure

writeln

private void writeln(java.lang.String s)
              throws java.rmi.RemoteException
Write line to output (appending newline).

Parameters:
s - text to output
Throws:
java.rmi.RemoteException - rpc failure

numJobsConstraints

private int numJobsConstraints(long maxMem)
Return number of queued jobs that satisfy server constraints.

Parameters:
maxMem - maximum available server memory
Returns:
number of queued jobs that satisfy server constraints

satisfyConstraint

private boolean satisfyConstraint(RemoteJist.Job j,
                                  long maxMem)
Determine whether server resources satisfy job constraints.

Parameters:
j - job to verify against constraints
maxMem - maximum available server memory
Returns:
whether server resources satisfy job constraints

addJob

public void addJob(RemoteJist.Job job,
                   boolean front)
            throws java.rmi.RemoteException
Add job to queue.

Specified by:
addJob in interface RemoteJist.JobQueueServerRemote
Parameters:
job - job to enqueue
front - whether job should be added to the front of the queue
Throws:
java.rmi.RemoteException - rpc failure

waitForJob

public void waitForJob(long maxMem)
                throws java.rmi.RemoteException
Wait for job. Returns when there might be a job available.

Specified by:
waitForJob in interface RemoteJist.JobQueueServerRemote
Parameters:
maxMem - maximum available server memory
Throws:
java.rmi.RemoteException - rpc failure

getJob

public RemoteJist.Job getJob(long maxMem)
                      throws java.rmi.RemoteException
Return next job from queue, or null if queue is empty.

Specified by:
getJob in interface RemoteJist.JobQueueServerRemote
Parameters:
maxMem - maximum available server memory
Returns:
next job from queue; null if none exists
Throws:
java.rmi.RemoteException - rpc failure

getStdOut

public RemoteIO.RemoteOutputStreamRemote getStdOut()
                                            throws java.rmi.RemoteException
Return RMI handle to queue standard output stream.

Specified by:
getStdOut in interface RemoteJist.JobQueueServerRemote
Returns:
remote output stream RMI handle
Throws:
java.rmi.RemoteException - rpc failure