Submitting and Monitoring a Job

Once the RunInfo object is configured appropriately, you can submit the job to execute using the PSE (Problem Solving Environment) interface, the main interface for managing job execution.

Do the following to create and configure a RunInfo object:

  • Obtain a PSE instance:
    PSE pse = SysPSE.getPSE();
    
  • Create a JobInfoValue object to represent the job:
    JobInfoValue jobDetails = pse.createJob(runInfo);
    
  • Obtain the Job ID so that it can be used to query information about the job:
    String jobId = jobDetails.getId();
    

You can create and add a JobMonitorListener to get notified of the job's progress, including when it completes using the call:

JobMonitorListener jobListener = new JobMonitorListener() {
public void jobEvent(JobMonitorEvent event) {
if ((event.getEventType() == 
JobMonitorEvent.TYPE_WORKITEM) 
&& (event.getStatus() == PSEUtils.WORK_DONE)) {
//do something
}
}
}
pse.addJobMonitorListener(jobId, jobListener);

Ultimately, run the job:

pse.runJob(jobId);

This step is an asynchronous call that returns immediately; thus, you need some way to know when the job completes. If you have attached a listener to the job, you can be listening for events to let you know when work items complete and when the entire job completes (among other events). Review the javadocs for the JobMonitorEvent interface and the PSEUtils interface for event types and status codes that may be of use.

An alternative brute-force approach for knowing when the job completes is to poll the job status until it is done using a loop over some period of time that should be longer than the job:

JobInfoValue jobDetails = null;
int maxWaitSeconds = 600;
for (int i=0; i<maxWaitSeconds; i++) {
Thread.sleep(1000); // Pause 1 second

// Get updated job details. Note this is much faster than
// pse.getJobStatus() because it does not have detailed
// progress information (workitems started/completed, etc).

jobDetails = SysPSE.getPSE().getJob(jobId, false);
if (jobDetails.getStatus() == PSEUtils.JOB_DONE) {
break;
}
}

If you are running a job on a SIMULIA Execution Engine, your program can exit and the job will continue to run. If you are running a job locally, the job will be aborted when your program exits. If you need to start a job executing locally and then let it run independent of your program, save the model to a file and execute the command fipercmd start file:FileName in a separate process.