本文整理汇总了Java中javax.batch.runtime.JobExecution.getExitStatus方法的典型用法代码示例。如果您正苦于以下问题:Java JobExecution.getExitStatus方法的具体用法?Java JobExecution.getExitStatus怎么用?Java JobExecution.getExitStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.batch.runtime.JobExecution
的用法示例。
在下文中一共展示了JobExecution.getExitStatus方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: testChunkTimeBased10Seconds
import javax.batch.runtime.JobExecution; //导入方法依赖的package包/类
@Test
@org.junit.Test
public void testChunkTimeBased10Seconds() throws Exception {
String METHOD = "testChunkTimeBased10Seconds";
String DEFAULT_SLEEP_TIME = "500";
try {
Properties jobParams = new Properties();
jobParams.put("execution.number", "1");
jobParams.put("readrecord.fail", "31");
jobParams.put("app.arraysize", "30");
jobParams.put("app.sleeptime", System.getProperty("ChunkTests.testChunkTimeBased10Seconds.sleep",DEFAULT_SLEEP_TIME));
JobExecution execution1 = jobOp.startJobAndWaitForResult("chunkTimeBasedCheckpoint", jobParams);
assertWithMessage("Testing execution #1", BatchStatus.COMPLETED, execution1.getBatchStatus());
String exitStatus = execution1.getExitStatus();
assertWithMessage("Testing execution #1", (exitStatus.equals("TRUE: 9") || exitStatus.equals("TRUE: 10") || exitStatus.equals("TRUE: 11")));
Reporter.log("exit status = " + execution1.getExitStatus() + "<p>");
} catch (Exception e) {
handleException(METHOD, e);
}
}
示例3: testChunkTimeBasedDefaultCheckpoint
import javax.batch.runtime.JobExecution; //导入方法依赖的package包/类
@Test
@org.junit.Test
public void testChunkTimeBasedDefaultCheckpoint() throws Exception {
String METHOD = "testChunkTimeBasedDefaultCheckpoint";
String DEFAULT_SLEEP_TIME = "500";
try {
Reporter.log("Create job parameters for execution #1:<p>");
Properties jobParams = new Properties();
Reporter.log("execution.number=1<p>");
Reporter.log("readrecord.fail=31<p>");
Reporter.log("app.arraysize=30<p>");
jobParams.put("execution.number", "1");
jobParams.put("readrecord.fail", "31");
jobParams.put("app.arraysize", "30");
jobParams.put("app.sleeptime", System.getProperty("ChunkTests.testChunkTimeBasedDefaultCheckpoint.sleep",DEFAULT_SLEEP_TIME));
Reporter.log("Locate job XML file: chunkTimeBasedDefaultCheckpoint.xml<p>");
Reporter.log("Invoke startJobAndWaitForResult for execution #1<p>");
JobExecution execution1 = jobOp.startJobAndWaitForResult("chunkTimeBasedDefaultCheckpoint", jobParams);
Reporter.log("execution #1 JobExecution getBatchStatus()=" + execution1.getBatchStatus() + "<p>");
Reporter.log("execution #1 JobExecution getExitStatus()=" + execution1.getExitStatus() + "<p>");
assertWithMessage("Testing execution #1", BatchStatus.COMPLETED, execution1.getBatchStatus());
String exitStatus = execution1.getExitStatus();
assertWithMessage("Testing execution #1", (exitStatus.equals("TRUE: 0") || exitStatus.equals("TRUE: 1")));
} catch (Exception e) {
handleException(METHOD, e);
}
}
示例4: testChunkTimeBasedTimeLimit0
import javax.batch.runtime.JobExecution; //导入方法依赖的package包/类
@Test
@org.junit.Test
public void testChunkTimeBasedTimeLimit0() throws Exception {
String METHOD = "testChunkTimeBasedDefaultCheckpoint";
String DEFAULT_SLEEP_TIME = "500";
try {
Reporter.log("Create job parameters for execution #1:<p>");
Properties jobParams = new Properties();
Reporter.log("execution.number=1<p>");
Reporter.log("readrecord.fail=31<p>");
Reporter.log("app.arraysize=30<p>");
jobParams.put("execution.number", "1");
jobParams.put("readrecord.fail", "31");
jobParams.put("app.arraysize", "30");
jobParams.put("app.sleeptime", System.getProperty("ChunkTests.testChunkTimeBasedTimeLimit0.sleep",DEFAULT_SLEEP_TIME));
Reporter.log("Locate job XML file: chunkTimeLimit0.xml<p>");
Reporter.log("Invoke startJobAndWaitForResult for execution #1<p>");
JobExecution execution1 = jobOp.startJobAndWaitForResult("chunkTimeLimit0", jobParams);
Reporter.log("execution #1 JobExecution getBatchStatus()=" + execution1.getBatchStatus() + "<p>");
Reporter.log("execution #1 JobExecution getExitStatus()=" + execution1.getExitStatus() + "<p>");
assertWithMessage("Testing execution #1", BatchStatus.COMPLETED, execution1.getBatchStatus());
String exitStatus = execution1.getExitStatus();
assertWithMessage("Testing execution #1", (exitStatus.equals("TRUE: 0") || exitStatus.equals("TRUE: 1")));
} catch (Exception e) {
handleException(METHOD, e);
}
}
示例5: values
import javax.batch.runtime.JobExecution; //导入方法依赖的package包/类
@TCKTest(
versions={"1.1.WORKING"},
assertions={"The values of JobContext and StepContext can be accessed from an artifact running in a partition."},
specRefs={
@SpecRef(version="1.0", section="10.9.1", notes={"API for JobContext"}),
@SpecRef(version="1.0", section="10.9.2", notes={"API for StepContext"}),
},
apiRefs={
@APIRef(className="javax.batch.runtime.context.JobContext", methodNames={"getProperties","getJobName","getExecutionId","getInstanceId"}),
@APIRef(className="javax.batch.runtime.context.StepContext", methodNames={"getStepExecutionId","getProperties"}),
},
issueRefs={"https://java.net/bugzilla/show_bug.cgi?id=5164"},
strategy= "First, certain JobContext and StepContext values (properties, names, ids, etc.) are checked against hard-coded values "
+ "within the executing batchlet. Then, a PartitionCollector formats some of the values into a String, which is passed to "
+ "a PartitionAnalyzer. The PartitionAnalyzer sets the job exit status to this formatted String. Finally, we check that the "
+ "values obtained by parsing the job exit status correspond with the values obtained from the JobExecution and StepExecution.",
notes={"There is no particular place in the spec that says that partitions share the same values for the getters tested as the top-level JobContext/StepContext."}
)
@Test
@org.junit.Test
public void testPartitionContextPropagation() throws Exception {
JobExecution je = jobOp.startJobAndWaitForResult("partitionCtxPropagation", null);
// Check job COMPLETED since some validation is crammed into the execution.
assertWithMessage("Test successful completion", "COMPLETED", je.getBatchStatus().toString());
// Get the correct exec id and instance id
long theExecId = je.getExecutionId();
long theInstanceId = jobOp.getJobInstance(theExecId).getInstanceId();
// Get the correct step execution id
List<StepExecution> se = jobOp.getStepExecutions(theExecId);
assertWithMessage("Number StepExecutions", 1, se.size());
long theStepExecId = se.get(0).getStepExecutionId();
// Now parse the exit status to view the partitions' own views of the job execution id, job instance id,
// and step execution ids, via JobContext and StepContext.
String status = je.getExitStatus();
String[] statusIDs = status.split(":");
int numberOfPartitions = statusIDs.length - 1;
String[] jobExecIDs = new String[numberOfPartitions];
String[] jobInstanceIDs = new String[numberOfPartitions];
String[] stepExecIDs = new String[numberOfPartitions];
//before the first ":" is unimportant, so use a 1-index.
for (int i = 1; i <= numberOfPartitions; i++) {
jobExecIDs[i - 1] = statusIDs[i].substring(statusIDs[i].indexOf("J") + 1, statusIDs[i].indexOf("I"));
jobInstanceIDs[i - 1] = statusIDs[i].substring(statusIDs[i].indexOf("I") + 1, statusIDs[i].indexOf("S"));
stepExecIDs[i - 1] = statusIDs[i].substring(statusIDs[i].indexOf("S") + 1);
}
// Back to 0-indexed counting
for (int i = 0; i < numberOfPartitions; i++) {
assertWithMessage("For partition # " + i + ", check job execution id", theExecId, Long.parseLong(jobExecIDs[i]));
assertWithMessage("For partition # " + i + ", check job instance id", theInstanceId, Long.parseLong(jobInstanceIDs[i]));
assertWithMessage("For partition # " + i + ", check step exec id", theStepExecId, Long.parseLong(stepExecIDs[i]));
}
}
示例6: StepExecution
import javax.batch.runtime.JobExecution; //导入方法依赖的package包/类
@TCKTest(
versions = {"1.1.WORKING"},
assertions = {"A Decider that follows a single step is passed the most recent StepExecution of the step."},
specRefs = {
@SpecRef(
version = "1.0", section = "9.6",
citations = "The decide method sets a new exit status for a job. It receives an array of StepExecution objects as input. These "
+ "StepExecution objects represent the execution element that transitions to this decider as follows: [...] Step [...] "
+ "When the transition is from a step, the decide method receives the StepExecution corresponding to the step as input.",
notes = "API for Decider"
),
@SpecRef(
version = "1.0RevA", section = "10.8.4",
citations = "The Decider's \"decide\" method is passed a StepExecution array as a parameter. This array "
+ "will be populated with the most-recently completed StepExecution(s) for each corresponding step.",
notes = "See 3.d."
)
},
apiRefs = { @APIRef(className="javax.batch.api.Decider", methodNames={"decide"}) },
issueRefs = {"https://github.com/WASdev/standards.jsr352.tck/issues/33", "https://java.net/bugzilla/show_bug.cgi?id=5780"},
strategy = "JobExecution1: step1 completes, Decider receives this StepExecution, and the job is forced to stop. "
+ "JobExecution2: step1 does not re-execute (allow-start-if-complete=false), verify that the Decider receives "
+ "the same StepExecution as in JobExecution1, and force the job to stop. "
+ "JobExecution3: step1 re-executes (allow-start-if-complete=true), verify that the Decider receives a new StepExecution "
+ "for step1, and check that the job completes. "
)
@Test
@org.junit.Test
public void testDeciderReceivesCorrectStepExecutionAfterStep() throws Exception {
String METHOD = "testDeciderReceivesCorrectStepExecutionAfterStep";
try {
/* Note: The Job Exit Status on each execution is the Decider return value,
* which is set up to indicate which steps and step executions it received */
final String NEW_STEP_EXECUTION_ID = "\\d+;?"; //to be used in regex matching
//Job Execution 1
Reporter.log("Build job parameters for job execution 1.<p>");
Properties executionParameters = new Properties();
executionParameters.setProperty("allow.start.if.complete", "false");
executionParameters.setProperty("decider.stop.on", "*");
Reporter.log("Invoke startJobAndWaitForResult<p>");
JobExecution jobExec1 = jobOp.startJobAndWaitForResult("decider_receives_correct_step_execution_after_step", executionParameters);
String jobExec1Step1Exec = jobExec1.getExitStatus();
assertWithMessage("Expected Exit Status to be set by Decider", jobExec1Step1Exec.matches("step1:" + NEW_STEP_EXECUTION_ID));
assertWithMessage("Expected job to be STOPPED after first execution", BatchStatus.STOPPED, jobExec1.getBatchStatus());
//Job Execution 2
Reporter.log("Don't change job parameters for job execution 2.<p>");
JobExecution jobExec2 = jobOp.restartJobAndWaitForResult(jobExec1.getExecutionId(), executionParameters);
String jobExec2Step1Exec = jobExec2.getExitStatus();
assertWithMessage("Execution for step1 should be the same in jobExec2 as in jobExec1", jobExec1Step1Exec, jobExec2Step1Exec);
assertWithMessage("Expected job to be STOPPED after second execution", BatchStatus.STOPPED, jobExec2.getBatchStatus());
//Job Execution 3
Reporter.log("Build job parameters for job execution 3.<p>");
executionParameters.setProperty("allow.start.if.complete", "true");
executionParameters.setProperty("decider.stop.on", "NONE");
JobExecution jobExec3 = jobOp.restartJobAndWaitForResult(jobExec2.getExecutionId(), executionParameters);
String jobExec3Step1Exec = jobExec3.getExitStatus();
assertWithMessage("Execution for step1 should be different in jobExec3 than in jobExec2", !jobExec2Step1Exec.equals(jobExec3Step1Exec));
assertWithMessage("Expected Exit Status to be set by Decider", jobExec3Step1Exec.matches("step1:" + NEW_STEP_EXECUTION_ID));
assertWithMessage("Expected job to be COMPLETED after third execution", BatchStatus.COMPLETED, jobExec3.getBatchStatus());
} catch(Exception e) {
handleException(METHOD, e);
}
}