}
private void submit(Entry entry)
{
JobControlEntry jce;
Transaction txn;
try {
txn = createTransaction(5 * 1000);
try {
jce = (JobControlEntry)
space.takeIfExists(entry, txn, JavaSpace.NO_WAIT);
JobInfo ji = jce.jobInfo;
JobParams jp = (JobParams)
space.takeIfExists(new JobParams(ji),
txn, JavaSpace.NO_WAIT);
if(jp != null) {
if(jp.submissionID != null) {
deleteFiles(jp);
}
String subName = ji.name.substring(ji.name.lastIndexOf('/') + 1);
subName = "jam_" + jobCount + "_" + ji.userID + "_" + subName;
String script = cwd + "/" + subName;
BufferedWriter writer = new BufferedWriter(new
FileWriter(script));
writer.write(jp.script, 0, jp.script.length());
writer.flush();
writer.close();
jp.jobID = new Integer(jobCount);
jp.input = new URL("file:" + script + ".in");
jp.output = new URL("file:" + script + ".out");
jp.error = new URL("file:" + script + ".err");
jp.submissionName = subName;
jp.submissionID = new Integer(nativeSubmission(jp));
jce.jobAction = JobAction.NONE;
SingleJobStatusTracer tracer = new
SingleJobStatusTracer(nativeSGERMAdapter, space,
ji, jp.submissionID.intValue(),
jp.submissionName);
// SingleJobStatusTracer tracer = new
// SingleJobStatusTracer(nativeSGERMAdapter, space,
// ji, jp.submissionID.intValue(),
// jp.submissionName, txnMgr);
tracer.start();
tracerTable.put(jp.jobID, tracer);
jobCount++;
space.write(jp, txn, Lease.FOREVER);
space.write(jce, txn, Lease.FOREVER);
}
} catch(Exception ex) {
ex.printStackTrace();
txn.abort();
return;
}
txn.commit();
} catch(Exception e) {
System.out.println("-- RMAdapter --:Exception in submitting job: "
+ jobCount);
e.printStackTrace();
}