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


Java JobExecution类代码示例

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


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

示例1: checkpointAlgorithm

import javax.batch.runtime.JobExecution; //导入依赖的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: 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);
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:26,代码来源:BatchArquillianTest.java

示例3: stopJobAndWaitForResult

import javax.batch.runtime.JobExecution; //导入依赖的package包/类
public JobExecution stopJobAndWaitForResult(JobExecution jobExecution) throws NoSuchJobExecutionException, JobExecutionNotRunningException, JobSecurityException, JobExecutionTimeoutException {
	
	JobExecution terminatedJobExecution = null;
	jobOp.stop(jobExecution.getExecutionId());

	JobExecutionWaiter waiter = waiterFactory.createWaiter(jobExecution.getExecutionId(), jobOp, sleepTime);

	try {
		terminatedJobExecution = waiter.awaitTermination();
	} catch (JobExecutionTimeoutException e) {
		logger.severe(TIMEOUT_MSG);
		Reporter.log(TIMEOUT_MSG);
		throw e;
	}									

	return new TCKJobExecutionWrapper(terminatedJobExecution, jobOp);
}
 
开发者ID:WASdev,项目名称:standards.jsr352.tck,代码行数:18,代码来源:JobOperatorBridge.java

示例4: 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;
}
 
开发者ID:WASdev,项目名称:standards.jsr352.tck,代码行数:19,代码来源:TCKPollingExecutionWaiterFactory.java

示例5: testAbandoned

import javax.batch.runtime.JobExecution; //导入依赖的package包/类
@Test
@org.junit.Test
public void testAbandoned() throws Exception {

	String METHOD = "testAbandoned";
	begin(METHOD);

	try {
		Reporter.log("Locate job XML file: job_batchlet_4steps.xml<p>");

		Reporter.log("Invoke startJobAndWaitForResult for execution #1<p>");
		JobExecution jobExec = jobOp.startJobAndWaitForResult("job_batchlet_4steps");
		assertObjEquals(BatchStatus.COMPLETED, jobExec.getBatchStatus());

		jobOp.abandonJobExecution(jobExec.getExecutionId());

		JobExecution jobExec2 = jobOp.getJobExecution(jobExec.getExecutionId());
		assertObjEquals(BatchStatus.ABANDONED, jobExec2.getBatchStatus());

	} catch (Exception e) {
		handleException(METHOD, e);
	}
}
 
开发者ID:WASdev,项目名称:standards.jsr352.tck,代码行数:24,代码来源:JobOperatorTests.java

示例6: testSplitTransitionToStep

import javax.batch.runtime.JobExecution; //导入依赖的package包/类
/**
 * @testName: testSplitTransitionToStep
 * @assertion: Section 5.4 Split
 * @test_Strategy: 1. setup a job consisting of one split (w/ 2 flows) and one step
 * 				   2. start job 
 * 				   3. add step id from step context to job context exit status
 * 				   4. verify that the split indeed transitioned to the step
 * 
 * @throws JobStartException
 * @throws FileNotFoundException
 * @throws IOException
 * @throws InterruptedException
 */
@Test @org.junit.Test
public void testSplitTransitionToStep() throws Exception {

	String METHOD = "testSplitTransitionToStep";

	try {
		Reporter.log("starting job");
		JobExecution jobExec = jobOp.startJobAndWaitForResult("split_transition_to_step", null);
		Reporter.log("Job Status = " + jobExec.getBatchStatus());

		assertWithMessage("Split transitioned to step", "step1", jobExec.getExitStatus());

		assertWithMessage("Job completed", BatchStatus.COMPLETED, jobExec.getBatchStatus());
		Reporter.log("job completed");
	} catch (Exception e) {
		handleException(METHOD, e); 
	}
}
 
开发者ID:WASdev,项目名称:standards.jsr352.tck,代码行数:32,代码来源:SplitTransitioningTests.java

示例7: testStepContextGetId

import javax.batch.runtime.JobExecution; //导入依赖的package包/类
/**
 * @testName: testStepContextGetId
 * @assertion: Section 7.7.2 StepContext
 * @test_Strategy: 1. setup a simple job with one step
 * 				   2. start job 
 * 				   3. set job exit status equals step id from StepContext in batchlet
 * 				   4. compare step id 'step1' to job exit status
 * 
 * 	<job id="job1" xmlns="http://xmlns.jcp.org/xml/ns/javaee">
 * 		<step id="step1">
 *			<batchlet ref="contextsGetIdStepContextTestBatchlet"/>
 *		</step>
 *	</job>
 *
 * @throws Exception
 */
@Test
@org.junit.Test
public void testStepContextGetId() throws Exception {

	String METHOD = "testStepContextGetId";

	try {
		String stepId = "step1";

		Reporter.log("starting job");
		JobExecution jobExec = jobOp.startJobAndWaitForResult("contexts_getid_stepcontext", null);
		Reporter.log("Job Status = " + jobExec.getBatchStatus());

		assertWithMessage("job id equals job1", stepId, jobExec.getExitStatus());

		assertWithMessage("Job completed", BatchStatus.COMPLETED, jobExec.getBatchStatus());
		Reporter.log("job completed");
	} catch (Exception e) {
		handleException(METHOD, e);
	}
}
 
开发者ID:WASdev,项目名称:standards.jsr352.tck,代码行数:38,代码来源:ContextsGetIdTests.java

示例8: testInvokeJobWithOneBatchletStep

import javax.batch.runtime.JobExecution; //导入依赖的package包/类
@Test
@org.junit.Test  
public void testInvokeJobWithOneBatchletStep() throws Exception {
	String METHOD = "testInvokeJobWithOneBatchletStep";
	begin(METHOD);

	try {
		Reporter.log("Locate job XML file: job_batchlet_1step.xml<p>");

		Reporter.log("Invoking startJobAndWaitForResult for Execution #1<p>");
		JobExecution jobExec = jobOp.startJobAndWaitForResult("job_batchlet_1step");

		Reporter.log("execution #1 JobExecution getBatchStatus()="+jobExec.getBatchStatus()+"<p>");
		assertObjEquals(BatchStatus.COMPLETED, jobExec.getBatchStatus());
		Reporter.log("execution #1 JobExecution getExitStatus()="+jobExec.getExitStatus()+"<p>");
		assertObjEquals("STEP 1 COMPLETED", jobExec.getExitStatus());
	} catch (Exception e) {
		handleException(METHOD, e);
	}
}
 
开发者ID:WASdev,项目名称:standards.jsr352.tck,代码行数:21,代码来源:ExecutionTests.java

示例9: testInvokeJobWithTwoStepSequenceOfBatchlets

import javax.batch.runtime.JobExecution; //导入依赖的package包/类
@Test
@org.junit.Test
public void testInvokeJobWithTwoStepSequenceOfBatchlets() throws Exception {
	String METHOD = "testInvokeJobWithTwoStepSequenceOfBatchlets";
	begin(METHOD);

	try {
		Reporter.log("Locate job XML file: job_batchlet_2steps.xml<p>");

		Reporter.log("Invoking startJobAndWaitForResult for Execution #1<p>");
		JobExecution jobExec = jobOp.startJobAndWaitForResult("job_batchlet_2steps");

		Reporter.log("execution #1 JobExecution getBatchStatus()="+jobExec.getBatchStatus()+"<p>");
		assertObjEquals(BatchStatus.COMPLETED, jobExec.getBatchStatus());
		Reporter.log("execution #1 JobExecution getExitStatus()="+jobExec.getExitStatus()+"<p>");
		assertObjEquals("STEP 2 COMPLETED", jobExec.getExitStatus());
	} catch (Exception e) {
		handleException(METHOD, e);
	}
}
 
开发者ID:WASdev,项目名称:standards.jsr352.tck,代码行数:21,代码来源:ExecutionTests.java

示例10: testInvokeJobWithFourStepSequenceOfBatchlets

import javax.batch.runtime.JobExecution; //导入依赖的package包/类
@Test
@org.junit.Test
public void testInvokeJobWithFourStepSequenceOfBatchlets() throws Exception {
	String METHOD = "testInvokeJobWithFourStepSequenceOfBatchlets";
	begin(METHOD);

	try {
		Reporter.log("Locate job XML file: job_batchlet_4steps.xml<p>");

		Reporter.log("Invoking startJobAndWaitForResult for Execution #1<p>");
		JobExecution jobExec = jobOp.startJobAndWaitForResult("job_batchlet_4steps");

		Reporter.log("execution #1 JobExecution getBatchStatus()="+jobExec.getBatchStatus()+"<p>");
		assertObjEquals(BatchStatus.COMPLETED, jobExec.getBatchStatus());
		Reporter.log("execution #1 JobExecution getExitStatus()="+jobExec.getExitStatus()+"<p>");
		assertObjEquals("STEP 3 COMPLETED", jobExec.getExitStatus());
	} catch (Exception e) {
		handleException(METHOD, e);
	}
}
 
开发者ID:WASdev,项目名称:standards.jsr352.tck,代码行数:21,代码来源:ExecutionTests.java

示例11: testInvokeJobWithNextElement

import javax.batch.runtime.JobExecution; //导入依赖的package包/类
@Test
@org.junit.Test  
public void testInvokeJobWithNextElement() throws Exception {
	String METHOD = "testInvokeJobWithNextElement";
	begin(METHOD);

	try {
		Reporter.log("Locate job XML file: job_batchlet_nextElement.xml<p>");

		Reporter.log("Invoking startJobAndWaitForResult for Execution #1<p>");
		JobExecution jobExec = jobOp.startJobAndWaitForResult("job_batchlet_nextElement");

		Reporter.log("execution #1 JobExecution getBatchStatus()="+jobExec.getBatchStatus()+"<p>");
		assertObjEquals(BatchStatus.COMPLETED, jobExec.getBatchStatus());
		Reporter.log("execution #1 JobExecution getExitStatus()="+jobExec.getExitStatus()+"<p>");
		assertObjEquals("STEP 2 COMPLETED", jobExec.getExitStatus());
	} catch (Exception e) {
		handleException(METHOD, e);
	}
}
 
开发者ID:WASdev,项目名称:standards.jsr352.tck,代码行数:21,代码来源:ExecutionTests.java

示例12: testInvokeJobWithFailElement

import javax.batch.runtime.JobExecution; //导入依赖的package包/类
@Test
@org.junit.Test  
public void testInvokeJobWithFailElement() throws Exception {
	String METHOD = "testInvokeJobWithFailElement";
	begin(METHOD);

	try {
		Reporter.log("Locate job XML file: job_batchlet_failElement.xml<p>");

		Reporter.log("Invoking startJobAndWaitForResult for Execution #1<p>");
		JobExecution jobExec = jobOp.startJobAndWaitForResult("job_batchlet_failElement");

		Reporter.log("execution #1 JobExecution getExitStatus()="+jobExec.getExitStatus()+"<p>");
		Reporter.log("execution #1 JobExecution getBatchStatus()="+jobExec.getBatchStatus()+"<p>");
		assertObjEquals("TEST_FAIL", jobExec.getExitStatus());
		assertObjEquals(BatchStatus.FAILED, jobExec.getBatchStatus());
	} catch (Exception e) {
		handleException(METHOD, e);
	}
}
 
开发者ID:WASdev,项目名称:standards.jsr352.tck,代码行数:21,代码来源:ExecutionTests.java

示例13: testInvokeJobWithStopElement

import javax.batch.runtime.JobExecution; //导入依赖的package包/类
@Test
@org.junit.Test  
public void testInvokeJobWithStopElement() throws Exception {
	String METHOD = "testInvokeJobWithStopElement";
	begin(METHOD);

	try {
		Reporter.log("Locate job XML file: job_batchlet_stopElement.xml<p>");

		Reporter.log("Invoking startJobAndWaitForResult for Execution #1<p>");
		JobExecution jobExec = jobOp.startJobAndWaitForResult("job_batchlet_stopElement");

		Reporter.log("execution #1 JobExecution getBatchStatus()="+jobExec.getBatchStatus()+"<p>");
		assertObjEquals(BatchStatus.STOPPED, jobExec.getBatchStatus());
		Reporter.log("execution #1 JobExecution getExitStatus()="+jobExec.getExitStatus()+"<p>");
		assertObjEquals("TEST_STOPPED", jobExec.getExitStatus());
	} catch (Exception e) {
		handleException(METHOD, e);
	}
}
 
开发者ID:WASdev,项目名称:standards.jsr352.tck,代码行数:21,代码来源:ExecutionTests.java

示例14: testInvokeJobWithEndElement

import javax.batch.runtime.JobExecution; //导入依赖的package包/类
@Test
@org.junit.Test  
public void testInvokeJobWithEndElement() throws Exception {
	String METHOD = "testInvokeJobWithEndElement";
	begin(METHOD);

	try {
		Reporter.log("Locate job XML file: job_batchlet_endElement.xml<p>");

		Reporter.log("Invoking startJobAndWaitForResult for Execution #1<p>");
		JobExecution jobExec = jobOp.startJobAndWaitForResult("job_batchlet_endElement");

		Reporter.log("execution #1 JobExecution getExitStatus()="+jobExec.getExitStatus()+"<p>");
		Reporter.log("execution #1 JobExecution getBatchStatus()="+jobExec.getBatchStatus()+"<p>");
		assertObjEquals("TEST_ENDED", jobExec.getExitStatus());
		assertObjEquals(BatchStatus.COMPLETED, jobExec.getBatchStatus());
	} catch (Exception e) {
		handleException(METHOD, e);
	}
}
 
开发者ID:WASdev,项目名称:standards.jsr352.tck,代码行数:21,代码来源:ExecutionTests.java

示例15: testInvokeJobSimpleChunk

import javax.batch.runtime.JobExecution; //导入依赖的package包/类
@Test
@org.junit.Test
public void testInvokeJobSimpleChunk() throws Exception {
	String METHOD = "testInvokeJobSimpleChunk";
	begin(METHOD);

	try {
		Reporter.log("Locate job XML file: job_chunk_simple.xml<p>");

		Reporter.log("Invoking startJobAndWaitForResult for Execution #1<p>");
		JobExecution jobExec = jobOp.startJobAndWaitForResult("job_chunk_simple");

		Reporter.log("execution #1 JobExecution getBatchStatus()="+jobExec.getBatchStatus()+"<p>");
		assertObjEquals(BatchStatus.COMPLETED, jobExec.getBatchStatus());
		Reporter.log("execution #1 JobExecution getExitStatus()="+jobExec.getExitStatus()+"<p>");
		assertObjEquals("STEP 2 COMPLETED", jobExec.getExitStatus());
	} catch (Exception e) {
		handleException(METHOD, e);
	}
}
 
开发者ID:WASdev,项目名称:standards.jsr352.tck,代码行数:21,代码来源:ExecutionTests.java


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