This interface represents a template to be used for the creation of a job. The properties set on a JobTemplate instance are used to create a new job and set up the new job's environment.
There is a 1:n relationship between JobTemplate instances and jobs. A single JobTemplate instance can be used to submit any number of jobs. Once a job has been submitted, e.g. via Session.runJob(), the JobTemplate instance no longer has any affect on that job. Changes made to the JobTemplate instance will have no affect on already running jobs. Deleting the JobTemplate instance (via Session.deleteJobTemplate()) also has no effect on running jobs.
Once a JobTemplate instance has been created (via Session.createJobTemplate()), it is the responsibility of the developer to delete it when no longer needed (via Session.deleteJobTemplate ()). Failure to do so may result in a memory leak.
Example:
public static void main(String[] args) { SessionFactory factory = SessionFactory.getFactory(); Session session = factory.getSession(); try { session.init(""); JobTemplate jt = session.createJobTemplate(); jt.setRemoteCommand("sleeper.sh"); jt.setWorkingDirectory(":" + HOME_DIRECTORY + "/jobs"); jt.setArgs(Collections.singletonList("5")); String id = session.runJob(jt); session.deleteJobTemplate(jt); session.exit(); } catch (DrmaaException e) { System.out.println("Error: " + e.getMessage ()); } }
@author dan.templeton@sun.com
@see Session
@since 0.4.2
@version 1.0