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.
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_scriptbatch_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.