本文整理汇总了Java中javax.batch.runtime.JobExecution.getBatchStatus方法的典型用法代码示例。如果您正苦于以下问题:Java JobExecution.getBatchStatus方法的具体用法?Java JobExecution.getBatchStatus怎么用?Java JobExecution.getBatchStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.batch.runtime.JobExecution
的用法示例。
在下文中一共展示了JobExecution.getBatchStatus方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: waitForCompletion
import javax.batch.runtime.JobExecution; //导入方法依赖的package包/类
private void waitForCompletion(final long executionId, final int timeout, final TimeUnit unit) {
final JobExecution jobExecution = BatchRuntime.getJobOperator().getJobExecution(executionId);
long time = unit.toMillis(timeout);
long sleep = 100;
boolean complete = false;
while (!complete && time > 0) {
switch (jobExecution.getBatchStatus()) {
case STARTED:
case STARTING:
case STOPPING:
try {
TimeUnit.MILLISECONDS.sleep(sleep);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
time -= sleep;
sleep = Math.max(sleep / 2, 100L);
break;
default:
complete = true;
break;
}
}
Assert.assertTrue("Batch job did not complete withing allotted time.", complete);
}
示例2: isTerminated
import javax.batch.runtime.JobExecution; //导入方法依赖的package包/类
private boolean isTerminated(JobExecution jobExecution) {
boolean retVal = false;
BatchStatus bs = jobExecution.getBatchStatus();
if (terminatedStatuses.contains(bs)) {
logger.fine("Found terminating batch status of: " + jobExecution.getBatchStatus().name());
if (jobExecution.getExitStatus() != null) {
logger.fine("Found exit status of: " + jobExecution.getExitStatus());
retVal = true;
} else {
logger.fine("Exit status is still 'null'. Poll again.");
retVal = false;
}
} else {
logger.finer("Found non-terminating batch status of: " + jobExecution.getBatchStatus().name());
retVal = false;
}
return retVal;
}