interface submitJob:BeanContextChild

submitting a job on a local host

void submitLocally(in string commandLine);
creates String array outputLine
creates boolean array waitForRead
creates and starts a new thread runIt of type jobThreadLocal

Thread jobThreadLocal
submits the job (Process p=Runtime.getRuntime().exec(command);)
creates and starts a new thread writeThread of type writeStdout

Thread writeStdout
opens InputDataStream piped to the process standard output
instantiates BufferedReader connected to the InputDataStream
reads standard output line after line, and puts it into outputLine array maintained by submitLocally by calling its method setOLine. While setting i-th element of outputLine it also sets (i+1)-th element to "wait" and i-th element of waitForRead array to "true". The size of outputLine is 20, and the output lines are stored in the round robin fashion. If an element waitForRead is "true", it means that the front end client have not read it, so it cannot be overwritten. If this happens (the producer is faster than the consumer), the tread sleeps untill the client change the value to "false". The oposite case, when the client is faster than the producer, is handled by setting the value of the line to be read to "wait". The client thread blocks until the writeStdout overwrites that value by a newly read line from the standard output.

void setOLine(in long i, in string s); (used with submitLocally)
sets value of i-th element of outputLine array
string getOLine(in long i); (used with submitLocally)
returns value of i-th element of outputLine array
void setLineRead(in long i); (used with submitLocally)
sets value of i-th element of waitForRead array to false
see an example client

submitting a job on a remote host

void submitRsh(in string host, in string user, in string commandLine);
prefixes the commanLine with "rsh -l user host
calls submitLocally

void submitGlobus(in string GramKeeper, in string RSL, in string user);
generates globusrun command and calls submitLocally

submitting a job to NQS batch

string submitNQS(in string commandLine);
creates and starts a new thread runIt of type jobThread
waits one second
retrieves job id returned by the NQS bach system getJobId()
adds the job id into jobTable, and marks it as not completed
returns the job id

Thread jobThread submits the job (Process p=Runtime.getRuntime().exec(command))
where command is currently fixed to be

  rsh -l user host /usr/craysoft/nqe/bin/qsub batch_script
          
batch_script is the method argument commandLine, while user and host are fixed. It is easy to remove these restrictions. More important are providing support for automatic generation of batch scripts and submiting jobs through Globus (instead of rsh).

The standard output of the process is piped to the Java InputDataStream, which in turn is connected to the Java BufferedReader. The thread waits till the second line of the output is available. The thread parses it to extract the job id. The jobid is made available through public method String getJobId()

Once the jobid is known, the tread waits until the code is completed. Every 5 seconds it check the status of the job issuing NQS qstat command (again through rsh), and parsing the response. As soon as the job is completed, the thread calls setJobCompleted (jobTable entry is set to true) and dies.

jobTable is a submitJob variable of type java.util.hashtable. The job is entered by directly invoking its method put. Currently, the job status has only two (boolean) value: true if completed, otherwise false.

void setJobCompleted(in string jobid);
sets the entry corresponding to jobid to true
boolean getJobCompleted(in string jobid);
returns value of jobTable corresponding to jobid

utilities

void exportFile(in string src, in string dst, in string rh, in string u);
invokes rcp command
void importFile(in string src, in string dst, in string rh, in string u);
invokes rcp command
void to_unix(in string dos, in string unix);
invoke utility to convert a DOS text file to Unix text file