本文整理汇总了Java中javax.batch.operations.JobOperator.start方法的典型用法代码示例。如果您正苦于以下问题:Java JobOperator.start方法的具体用法?Java JobOperator.start怎么用?Java JobOperator.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.batch.operations.JobOperator
的用法示例。
在下文中一共展示了JobOperator.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkpointAlgorithm
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Test
public void checkpointAlgorithm() throws Exception {
logger.info("starting checkpoint test");
CountDownLatch latch = new CountDownLatch(1);
JobOperator jobOperator = getJobOperator();
Properties props = new Properties();
long executionId = jobOperator.start(JOB_NAME, props);
latch.await(10, SECONDS);
JobInstance jobInstance = jobInstance(jobOperator.getJobInstance(executionId), JOB_NAME);
JobExecution jobExecution = jobOperator.getJobExecutions(jobInstance).get(0);
Properties jobProperties = jobExecution.getJobParameters();
assertEquals("properties are: ", 0, jobProperties.size());
assertEquals("batch failed because a NoRollbackException is throwed", FAILED, jobExecution.getBatchStatus());
StepExecution stepExecution = jobOperator.getStepExecutions(executionId).get(0);
PersistentCheckpointUserData persistentCheckpointUserData = (PersistentCheckpointUserData) stepExecution
.getPersistentUserData();
assertNull("persistent user data after step", persistentCheckpointUserData.getStartedAfterStep());
Metric[] stepMetrics = stepExecution.getMetrics();
stepMetrics(stepMetrics, 3, 10, 12, 2, 1);
}
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:22,代码来源:CheckpointJobTestCase.java
示例2: startCartesianMatrixJob
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Override
public void startCartesianMatrixJob(List<EsriPointFeature> sourcePoints, LegType legType) {
if (checkNullOrEmpty(sourcePoints)) {
log.error("Will not start Cartesian Matrix job with invalid sourcePoints for leg type {}", legType);
return;
}
JobOperator jo = BatchRuntime.getJobOperator();
Properties properties = new Properties();
properties.setProperty(BatchConstants.PATH_TYPE, legType.toString());
// assume here that the size of both sets is roughly equivalent!
properties.setProperty(BatchConstants.BATCH_SIZE, String.valueOf(sourcePoints.size()));
properties.setProperty(BatchConstants.PARTITIONING, String.valueOf(false));
properties.setProperty(BatchConstants.CARTESIAN, String.valueOf(true));
Long jobId = jo.start(BatchConstants.MATRIX_JOB, properties);
log.info("Dispatched Cartesian Matrix job with id {}", jobId);
sourcePointStash.put(jobId, sourcePoints);
}
示例3: startIVMatrixJob
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Override
public void startIVMatrixJob(IVRequestTuple request, LegType legType) {
if (checkNullOrEmpty(request.getTargets())) {
log.error("Will not start IV Matrix job with invalid targets for leg type {}", legType);
return;
}
JobOperator jo = BatchRuntime.getJobOperator();
Properties properties = new Properties();
properties.setProperty(BatchConstants.PATH_TYPE, legType.toString());
// assume here that the size of both sets is roughly equivalent!
properties.setProperty(BatchConstants.BATCH_SIZE, String.valueOf(request.getTargets().size()));
properties.setProperty(BatchConstants.PARTITIONING, String.valueOf(true));
properties.setProperty(BatchConstants.IVROUTE, String.valueOf(true));
Long jobId = jo.start(BatchConstants.MATRIX_JOB, properties);
List<EsriPointFeature> source = new ArrayList<>();
source.add(request.getSource());
log.info("Dispatched IV Matrix job with id {}", jobId);
sourcePointStash.put(jobId, source);
carTargetStash.put(jobId, new ArrayList<>(request.getTargets()));
}
示例4: startMatrixJob
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Override
public void startMatrixJob(List<IVRequestTuple> points, LegType legType) {
if (checkNullOrEmpty(points)) {
log.error("Will not start Matrix job with invalid points for leg type {}", legType);
return;
}
JobOperator jo = BatchRuntime.getJobOperator();
Properties properties = new Properties();
properties.setProperty(BatchConstants.PATH_TYPE, legType.toString());
properties.setProperty(BatchConstants.BATCH_SIZE, String.valueOf(points.size()));
properties.setProperty(BatchConstants.PARTITIONING, String.valueOf(true));
Long jobId = jo.start(BatchConstants.MATRIX_JOB, properties);
log.info("Dispatched Matrix job with id {}", jobId);
matrixStash.put(jobId, points);
}
示例5: startNeighborsJob
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@Override
public void startNeighborsJob(List<RasterPoint> rasterPoints) {
if (checkNullOrEmpty(rasterPoints)) {
log.error("Will not start Neighbors job with invalid rasterPoints.");
return;
}
JobOperator jo = BatchRuntime.getJobOperator();
Properties properties = new Properties();
properties.setProperty(BatchConstants.BATCH_SIZE, String.valueOf(rasterPoints.size()));
properties.setProperty(BatchConstants.MAX_WALK, String.valueOf(maxWalk));
Long jobId = jo.start(BatchConstants.NEIGHBORS_JOB, properties);
log.info("Dispatched Neighbors job with id {}", jobId);
rasterStash.put(jobId, rasterPoints);
}
示例6: start
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
/**
* Start the job.
*
* @response the JobInstance + JobExecution record of the newly started job.
*/
protected void start(HttpServletRequest request, HttpServletResponse response) throws IOException {
String jobXMLName = getRequiredParm(request, "jobXMLName");
Properties jobParameters = getJobParameters(request, "jobParameters");
JobOperator jobOperator = getJobOperator();
long execId = jobOperator.start(jobXMLName, jobParameters);
JobInstance jobInstance = jobOperator.getJobInstance(execId);
JobExecution jobExecution = jobOperator.getJobExecution(execId);
getResponseWriter().setHttpServletResponse( response )
.beginResponse(HttpServletResponse.SC_OK)
.println( "start(jobXMLName=" + jobXMLName + ", jobParameters=" + jobParameters + "): Job started!" )
.printJobInstance( jobInstance )
.printJobExecution( jobExecution )
.endResponse();
}
示例7: 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());
}
示例8: 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());
}
示例9: 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());
}
示例10: setup
import javax.batch.operations.JobOperator; //导入方法依赖的package包/类
@PostCreated
@PostRecovery
@PostConfig
public void setup()
{
_batchDataConsumer = new BatchDataConsumer(this);
BatchDataConsumerMap.getBatchDataConsumerMap().add(_batchDataConsumer);
JobOperator jobOperator = BatchRuntime.getJobOperator();
Properties jobParameters = new Properties();
jobParameters.setProperty(BatchDataConsumerMap.ID_PROPERTYNAME, _batchDataConsumer.getId());
long execId = jobOperator.start(_properties.get(JOBID_PROPERTYNAME), jobParameters);
logger.log(Level.FINE, "BatchDataService: " + execId);
}
示例11: 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());
}
示例12: 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());
}
示例13: 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());
}
示例14: 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);
}
示例15: 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());
}