return;
}
//3. get the BatchProcessing system that's notified
TestbedBatchProcessorManager batchManager = TestbedBatchProcessorManager.getInstance();
BatchProcessor bp = batchManager.getBatchProcessor(batchProcessorID);
//check rollback and if batch processor has persistent jobs
if((bp.getJob(ticket)==null) || (bp.getJobStatus(ticket).equals(TestbedBatchJob.NO_SUCH_JOB ))){
log.debug("EJBTransactionRollback - BatchProcessor no persistent job - dropp job: "+ticket);
return;
}
//4. check for updates and store extracted information in experiment
long t0 = System.currentTimeMillis();
long t1 = System.currentTimeMillis();
boolean bInfomredStarted = false;
//do until we have reached our time-out time or completed
while(t1-t0<timeOutMillis){
//a) check started
//use batchProcessor specific implementation for checking on this.
boolean bStarted = bp.isStarted(ticket);
if(bStarted){
if(!bInfomredStarted){
//callback: inform once about started
bp.notifyStart(ticket, bp.getJob(ticket));
log.debug("BatchExecutionListener: notify STARTED for: "+ticket);
bInfomredStarted=true;
}
if(bp.isRunning(ticket)){
TestbedBatchJob job = bp.getJob(ticket);
job.setStatus(TestbedBatchJob.RUNNING);
bp.notifyRunning(ticket, job);
log.debug("BatchExecutionListener: notify RUNNING for: "+ticket);
}
if(bp.isUpdated(ticket)){
bp.notifyUpdate(ticket, bp.getJob(ticket));
log.debug("BatchExecutionListener: notify UPDATE for: "+ticket);
}
if(bp.isFailed(ticket)){
TestbedBatchJob job = bp.getJob(ticket);
job.setStatus(TestbedBatchJob.FAILED);
bp.notifyFailed(ticket, job);
log.debug("BatchExecutionListener: notify FAILED for: "+ticket);
}
//check if completed
if(bp.isCompleted(ticket)){
TestbedBatchJob job = bp.getJob(ticket);
job.setStatus(TestbedBatchJob.DONE);
bp.notifyComplete(ticket, job);
log.debug("BatchExecutionListener: notify COMPLETE for: "+ticket);
return;
}
}
//status is: still no completed - sleep and repoll
try {
Thread.sleep(sleep);
} catch (InterruptedException e) {
log.debug("Error while waiting for ticket: "+ticket, e);
TestbedBatchJob job = bp.getJob(ticket);
job.setStatus(TestbedBatchJob.FAILED);
bp.notifyFailed(ticket, job);
return;
}
t1 = System.currentTimeMillis();
}
//b) in this case a time-out occurred
TestbedBatchJob job = bp.getJob(ticket);
job.setStatus(TestbedBatchJob.FAILED);
job.setWorkflowFailureReport(new String("BatchExperimentListener with timeout of "+timeOutMillis/1000+" Sec. has timed-out. This normally indicates a failure within the remote workflow execution processor"));
bp.notifyFailed(ticket, job);
log.debug("BatchExecutionListener: notify FAILED due to time-out for: "+ticket);
}