* @return the {@link JobExecution} for the final state of the job
* @throws java.util.concurrent.TimeoutException if the timeout occurs
*/
public static JobExecution restartJob(long executionId, Properties properties, long timeout) throws TimeoutException {
long restartId = operator.restart(executionId, properties);
JobExecution execution = operator.getJobExecution(restartId);
Date curDate = new Date();
BatchStatus curBatchStatus = execution.getBatchStatus();
while(true) {
if(curBatchStatus == BatchStatus.STOPPED || curBatchStatus == BatchStatus.COMPLETED || curBatchStatus == BatchStatus.FAILED) {
break;
}
if(new Date().getTime() - curDate.getTime() > timeout) {
throw new TimeoutException("Job processing did not complete in time");
}
execution = operator.getJobExecution(restartId);
curBatchStatus = execution.getBatchStatus();
}
return execution;
}