本文整理汇总了Java中javax.batch.operations.JobOperator.getStepExecutions方法的典型用法代码示例。如果您正苦于以下问题:Java JobOperator.getStepExecutions方法的具体用法?Java JobOperator.getStepExecutions怎么用?Java JobOperator.getStepExecutions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.batch.operations.JobOperator
的用法示例。
在下文中一共展示了JobOperator.getStepExecutions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testEndNormallyExecuteBoth
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Test
public void testEndNormallyExecuteBoth() throws Exception {
JobOperator jo = BatchRuntime.getJobOperator();
Properties props = new Properties();
props.put("forceFailure", "true");
long exec1Id = jo.start("nextOnStep1Failure", props);
Thread.sleep(normalSleepTime);
JobExecution je = jo.getJobExecution(exec1Id);
Map<String, StepExecution> steps = new HashMap<String,StepExecution>();
for (StepExecution se : jo.getStepExecutions(exec1Id)) { steps.put(se.getStepName(), se); }
assertEquals("Job batch status", BatchStatus.COMPLETED, je.getBatchStatus());
assertEquals("exit status", "COMPLETED", je.getExitStatus());
assertEquals("Steps executed", 2, steps.size());
assertEquals("Step failed", BatchStatus.FAILED, steps.get("step1").getBatchStatus());
assertEquals("Step failed", BatchStatus.COMPLETED, steps.get("step2").getBatchStatus());
}
示例2: testBatchChunkSimpleNoBeans
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Test
public void testBatchChunkSimpleNoBeans() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("myJob", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
BatchTestHelper.keepTestAlive(jobExecution);
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
for (StepExecution stepExecution : stepExecutions) {
if (stepExecution.getStepName().equals("myStep")) {
Map<Metric.MetricType, Long> metricsMap = BatchTestHelper.getMetricsMap(stepExecution.getMetrics());
assertEquals(10L, metricsMap.get(Metric.MetricType.READ_COUNT).longValue());
assertEquals(10L / 2L, metricsMap.get(Metric.MetricType.WRITE_COUNT).longValue());
assertEquals(10L / 3 + (10L % 3 > 0 ? 1 : 0), metricsMap.get(Metric.MetricType.COMMIT_COUNT).longValue());
}
}
assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
}
示例3: testBatchFlow
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Test
public void testBatchFlow() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("myJob", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
BatchTestHelper.keepTestAlive(jobExecution);
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
List<String> executedSteps = new ArrayList<>();
for (StepExecution stepExecution : stepExecutions) {
executedSteps.add(stepExecution.getStepName());
if (stepExecution.getStepName().equals("step2")) {
Map<Metric.MetricType, Long> metricsMap = BatchTestHelper.getMetricsMap(stepExecution.getMetrics());
System.out.println(metricsMap);
assertEquals(5L, metricsMap.get(Metric.MetricType.READ_COUNT).longValue());
assertEquals(5L, metricsMap.get(Metric.MetricType.WRITE_COUNT).longValue());
assertEquals(5L / 3 + (5 % 3 > 0 ? 1 : 0), metricsMap.get(Metric.MetricType.COMMIT_COUNT).longValue());
}
}
assertEquals(3, stepExecutions.size());
assertArrayEquals(new String[]{"step1", "step2", "step3"}, executedSteps.toArray());
assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
}
示例4: testBatchListeners
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Test
public void testBatchListeners() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("myJob", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
BatchTestHelper.keepTestAlive(jobExecution);
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
for (StepExecution stepExecution : stepExecutions) {
if (stepExecution.getStepName().equals("myStep")) {
Map<Metric.MetricType, Long> metricsMap = BatchTestHelper.getMetricsMap(stepExecution.getMetrics());
assertEquals(10L, metricsMap.get(Metric.MetricType.READ_COUNT).longValue());
assertEquals(10L / 2L, metricsMap.get(Metric.MetricType.WRITE_COUNT).longValue());
assertEquals(10L / 3 + (10L % 3 > 0 ? 1 : 0), metricsMap.get(Metric.MetricType.COMMIT_COUNT).longValue());
}
}
assertTrue(BatchListenerRecorder.batchListenersCountDownLatch.await(0, TimeUnit.SECONDS));
assertEquals(jobExecution.getBatchStatus(), BatchStatus.COMPLETED);
}
示例5: testBatchChunkCheckpoint
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Test
public void testBatchChunkCheckpoint() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("myJob", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
BatchTestHelper.keepTestAlive(jobExecution);
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
for (StepExecution stepExecution : stepExecutions) {
if (stepExecution.getStepName().equals("myStep")) {
Map<Metric.MetricType, Long> metricsMap = BatchTestHelper.getMetricsMap(stepExecution.getMetrics());
assertEquals(10L, metricsMap.get(Metric.MetricType.READ_COUNT).longValue());
assertEquals(10L / 2L, metricsMap.get(Metric.MetricType.WRITE_COUNT).longValue());
assertEquals(10L / 5L + 1, metricsMap.get(Metric.MetricType.COMMIT_COUNT).longValue());
}
}
assertTrue(MyCheckpointAlgorithm.checkpointCountDownLatch.await(0, TimeUnit.SECONDS));
assertEquals(jobExecution.getBatchStatus(), BatchStatus.COMPLETED);
}
示例6: testBatchMultipleSteps
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Test
public void testBatchMultipleSteps() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("myJob", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
BatchTestHelper.keepTestAlive(jobExecution);
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
List<String> executedSteps = new ArrayList<>();
for (StepExecution stepExecution : stepExecutions) {
executedSteps.add(stepExecution.getStepName());
if (stepExecution.getStepName().equals("step1")) {
Map<Metric.MetricType, Long> metricsMap = BatchTestHelper.getMetricsMap(stepExecution.getMetrics());
System.out.println(metricsMap);
assertEquals(10L, metricsMap.get(Metric.MetricType.READ_COUNT).longValue());
assertEquals(10L / 2, metricsMap.get(Metric.MetricType.WRITE_COUNT).longValue());
assertEquals(10L / 3 + (10L % 3 > 0 ? 1 : 0), metricsMap.get(Metric.MetricType.COMMIT_COUNT).longValue());
}
}
assertEquals(2, stepExecutions.size());
assertArrayEquals(new String[]{"step1", "step2"}, executedSteps.toArray());
assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
}
示例7: testBatchCSVDatabase
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Test
public void testBatchCSVDatabase() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("myJob", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
BatchTestHelper.keepTestAlive(jobExecution);
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
for (StepExecution stepExecution : stepExecutions) {
if (stepExecution.getStepName().equals("myStep")) {
Map<Metric.MetricType, Long> metricsMap = BatchTestHelper.getMetricsMap(stepExecution.getMetrics());
assertEquals(7L, metricsMap.get(Metric.MetricType.READ_COUNT).longValue());
assertEquals(7L, metricsMap.get(Metric.MetricType.WRITE_COUNT).longValue());
assertEquals(3L, metricsMap.get(Metric.MetricType.COMMIT_COUNT).longValue());
}
}
Query query = entityManager.createNamedQuery("Person.findAll");
@SuppressWarnings("unchecked")
List<Person> persons = query.getResultList();
assertEquals(7L, persons.size());
assertEquals(jobExecution.getBatchStatus(), BatchStatus.COMPLETED);
}
示例8: testBatchDecision
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Test
public void testBatchDecision() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("myJob", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
BatchTestHelper.keepTestAlive(jobExecution);
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
List<String> executedSteps = new ArrayList<>();
for (StepExecution stepExecution : stepExecutions) {
executedSteps.add(stepExecution.getStepName());
}
assertEquals(2, stepExecutions.size());
assertArrayEquals(new String[] {"step1", "step3"}, executedSteps.toArray());
assertFalse(executedSteps.contains("step2"));
assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
}
示例9: testBatchChunkException
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Test
public void testBatchChunkException() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("myJob", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
BatchTestHelper.keepTestAlive(jobExecution);
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
for (StepExecution stepExecution : stepExecutions) {
if (stepExecution.getStepName().equals("myStep")) {
Map<Metric.MetricType, Long> metricsMap = BatchTestHelper.getMetricsMap(stepExecution.getMetrics());
assertEquals(1L, metricsMap.get(Metric.MetricType.READ_SKIP_COUNT).longValue());
assertEquals(1L, metricsMap.get(Metric.MetricType.PROCESS_SKIP_COUNT).longValue());
assertEquals(1L, metricsMap.get(Metric.MetricType.WRITE_SKIP_COUNT).longValue());
}
}
assertTrue(ChunkExceptionRecorder.chunkExceptionsCountDownLatch.await(0, TimeUnit.SECONDS));
assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
}
示例10: testBatchChunkPartition
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Test
public void testBatchChunkPartition() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("myJob", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
BatchTestHelper.keepTestAlive(jobExecution);
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
for (StepExecution stepExecution : stepExecutions) {
if (stepExecution.getStepName().equals("myStep")) {
Map<Metric.MetricType, Long> metricsMap = BatchTestHelper.getMetricsMap(stepExecution.getMetrics());
assertEquals(20L, metricsMap.get(Metric.MetricType.READ_COUNT).longValue());
assertEquals(10L, metricsMap.get(Metric.MetricType.WRITE_COUNT).longValue());
// Number of elements by the item count value on myJob.xml, plus an additional transaction for the
// remaining elements by each partition.
long commitCount = 20L / 3 + (20 % 3 > 0 ? 1 : 0) * 2;
assertEquals(commitCount, metricsMap.get(Metric.MetricType.COMMIT_COUNT).longValue());
}
}
assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
}
示例11: testBatchChunkOptionalProcessor
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Test
public void testBatchChunkOptionalProcessor() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("myJob", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
BatchTestHelper.keepTestAlive(jobExecution);
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
for (StepExecution stepExecution : stepExecutions) {
if (stepExecution.getStepName().equals("myStep")) {
Map<Metric.MetricType, Long> metricsMap = BatchTestHelper.getMetricsMap(stepExecution.getMetrics());
assertEquals(10L, metricsMap.get(Metric.MetricType.READ_COUNT).longValue());
assertEquals(10L, metricsMap.get(Metric.MetricType.WRITE_COUNT).longValue());
assertEquals(10L / 3 + (10L % 3 > 0 ? 1 : 0), metricsMap.get(Metric.MetricType.COMMIT_COUNT).longValue());
}
}
assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
}
示例12: testChunkSimple
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Test
public void testChunkSimple() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("myJob", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
BatchTestHelper.keepTestAlive(jobExecution);
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
for (StepExecution stepExecution : stepExecutions) {
if (stepExecution.getStepName().equals("myStep")) {
Map<Metric.MetricType, Long> metricsMap = BatchTestHelper.getMetricsMap(stepExecution.getMetrics());
assertEquals(10L, metricsMap.get(Metric.MetricType.READ_COUNT).longValue());
assertEquals(10L / 2L, metricsMap.get(Metric.MetricType.WRITE_COUNT).longValue());
assertEquals(10L / 3 + (10L % 3 > 0 ? 1 : 0), metricsMap.get(Metric.MetricType.COMMIT_COUNT).longValue());
}
}
assertEquals(jobExecution.getBatchStatus(), BatchStatus.COMPLETED);
}
示例13: testBatchChunkMapper
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Test
public void testBatchChunkMapper() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("myJob", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
BatchTestHelper.keepTestAlive(jobExecution);
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
for (StepExecution stepExecution : stepExecutions) {
if (stepExecution.getStepName().equals("myStep")) {
Map<Metric.MetricType, Long> metricsMap = BatchTestHelper.getMetricsMap(stepExecution.getMetrics());
assertEquals(20L, metricsMap.get(Metric.MetricType.READ_COUNT).longValue());
assertEquals(10L, metricsMap.get(Metric.MetricType.WRITE_COUNT).longValue());
// Number of elements by the item count value on myJob.xml, plus an additional transaction for the
// remaining elements by each partition.
long commitCount = 20L / 3 + (20 % 3 > 0 ? 1 : 0) * 2;
assertEquals(commitCount, metricsMap.get(Metric.MetricType.COMMIT_COUNT).longValue());
}
}
assertEquals(2L, MyItemReader.totalReaders);
assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
}
示例14: testBatchSplit
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Test
public void testBatchSplit() throws Exception {
JobOperator jobOperator = BatchRuntime.getJobOperator();
Long executionId = jobOperator.start("myJob", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
BatchTestHelper.keepTestAlive(jobExecution);
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
List<String> executedSteps = new ArrayList<>();
for (StepExecution stepExecution : stepExecutions) {
executedSteps.add(stepExecution.getStepName());
}
assertEquals(3, stepExecutions.size());
assertTrue(executedSteps.contains("step1"));
assertTrue(executedSteps.contains("step2"));
assertTrue(executedSteps.contains("step3"));
assertTrue(executedSteps.get(0).equals("step1") || executedSteps.get(0).equals("step2"));
assertTrue(executedSteps.get(1).equals("step1") || executedSteps.get(1).equals("step2"));
assertTrue(executedSteps.get(2).equals("step3"));
assertEquals(BatchStatus.COMPLETED, jobExecution.getBatchStatus());
}
示例15: testRolledBackDuringWork
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Test
public void testRolledBackDuringWork() {
final JobOperator jobOperator = BatchRuntime.getJobOperator();
long executionId = jobOperator.start("txtest1", null);
BatchStatus batchStatus = Batches.waitFor(jobOperator, executionId);
Assert.assertEquals(batchStatus, BatchStatus.FAILED);
Assert.assertEquals(TxErrorWriter1.written.intValue(), 3);
List<StepExecution> stepExecutions = jobOperator.getStepExecutions(executionId);
Assert.assertEquals(stepExecutions.size(), 1);
StepExecution stepExecution = stepExecutions.get(0);
Metric[] metrics = stepExecution.getMetrics();
assertMetric(Metric.MetricType.READ_COUNT, 2, metrics);
assertMetric(Metric.MetricType.WRITE_COUNT, 2, metrics);
assertMetric(Metric.MetricType.ROLLBACK_COUNT, 1, metrics);
}