当前位置: 首页>>代码示例>>Java>>正文


Java JobOperator类代码示例

本文整理汇总了Java中javax.batch.operations.JobOperator的典型用法代码示例。如果您正苦于以下问题:Java JobOperator类的具体用法?Java JobOperator怎么用?Java JobOperator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JobOperator类属于javax.batch.operations包,在下文中一共展示了JobOperator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: open

import javax.batch.operations.JobOperator; //导入依赖的package包/类
@Override
public void open(Serializable prevCheckpointInfo) throws Exception {
	JobOperator jobOperator = getJobOperator();
	Properties jobParameters = jobOperator.getParameters(jobContext.getExecutionId());
	String resourceName = (String) jobParameters.get(INPUT_DATA_FILE_NAME);
	InputStream inputStream = new FileInputStream(resourceName);
	br = new BufferedReader(new InputStreamReader(inputStream));

	Stream<String> lines = br.lines();
	if (prevCheckpointInfo != null)
		recordNumber = (Integer) prevCheckpointInfo;
	else
		recordNumber = 0;
	stringLines = lines.toArray();
	logger.info("[SimpleItemReader] Opened Payroll file for reading from record number: " + recordNumber);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:17,代码来源:PayrollItemReader.java

示例2: 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

示例3: 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);
}
 
开发者ID:RWTH-i5-IDSG,项目名称:xsharing-services-router,代码行数:20,代码来源:BatchManagerBean.java

示例4: 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()));
}
 
开发者ID:RWTH-i5-IDSG,项目名称:xsharing-services-router,代码行数:23,代码来源:BatchManagerBean.java

示例5: 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);
}
 
开发者ID:RWTH-i5-IDSG,项目名称:xsharing-services-router,代码行数:18,代码来源:BatchManagerBean.java

示例6: 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);
}
 
开发者ID:RWTH-i5-IDSG,项目名称:xsharing-services-router,代码行数:17,代码来源:BatchManagerBean.java

示例7: doWorkWithJobOperator

import javax.batch.operations.JobOperator; //导入依赖的package包/类
public <T> T doWorkWithJobOperator(JobOperatorWork<T> w, String applicationName) throws NamingException {
    if (operationMode == OperationMode.DIRECT) {
        return w.doWorkWithJobOperator(BatchRuntime.getJobOperator());
    }

    final String lookupName = getLookupName(applicationName);
    log.log(Level.FINE, "lookupName={0}, applicationName={1}", new Object[]{lookupName, applicationName});
    InitialContext ic = null;
    try {
        ic = new InitialContext();
        JobOperator jobOperator = (JobOperator) ic.lookup(lookupName);
        return w.doWorkWithJobOperator(jobOperator);
    } finally {
        if (ic != null) {
            ic.close();
        }
    }
}
 
开发者ID:lbtc-xxx,项目名称:jberetweb,代码行数:19,代码来源:JBeretWebSingleton.java

示例8: 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();
}
 
开发者ID:WASdev,项目名称:sample.batch.sleepybatchlet,代码行数:24,代码来源:JobOperatorServlet.java

示例9: status

import javax.batch.operations.JobOperator; //导入依赖的package包/类
/**
 * Get status for the job identified by the 'executionId' query parm.
 * 
 * @response instance + execs
 */
protected void status(HttpServletRequest request, HttpServletResponse response) throws IOException {

    long execId = getLongParm(request, "executionId");

    JobOperator jobOperator = getJobOperator();
    JobInstance jobInstance = jobOperator.getJobInstance(execId);
    List<JobExecution> jobExecutions = jobOperator.getJobExecutions(jobInstance);

    getResponseWriter().setHttpServletResponse( response )
                       .beginResponse(HttpServletResponse.SC_OK)
                       .println( "status(executionId=" + execId + "): ")
                       .printJobInstance( jobInstance )
                       .printJobExecutions( jobExecutions )
                       .endResponse();
}
 
开发者ID:WASdev,项目名称:sample.batch.sleepybatchlet,代码行数:21,代码来源:JobOperatorServlet.java

示例10: 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());
}
 
开发者ID:WASdev,项目名称:standards.jsr352.jbatch,代码行数:18,代码来源:StepFailureTest.java

示例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());
}
 
开发者ID:ftomassetti,项目名称:JavaIncrementalParser,代码行数:22,代码来源:BatchChunkSimpleNoBeansTest.java

示例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());
}
 
开发者ID:ftomassetti,项目名称:JavaIncrementalParser,代码行数:27,代码来源:BatchFlowTest.java

示例13: 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);
}
 
开发者ID:ftomassetti,项目名称:JavaIncrementalParser,代码行数:23,代码来源:BatchListenersTest.java

示例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);
}
 
开发者ID:ftomassetti,项目名称:JavaIncrementalParser,代码行数:23,代码来源:BatchChunkCheckpointTest.java

示例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());
}
 
开发者ID:ftomassetti,项目名称:JavaIncrementalParser,代码行数:26,代码来源:BatchMultipleStepsTest.java


注:本文中的javax.batch.operations.JobOperator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。