本文整理汇总了Java中javax.batch.runtime.BatchRuntime.getJobOperator方法的典型用法代码示例。如果您正苦于以下问题:Java BatchRuntime.getJobOperator方法的具体用法?Java BatchRuntime.getJobOperator怎么用?Java BatchRuntime.getJobOperator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.batch.runtime.BatchRuntime
的用法示例。
在下文中一共展示了BatchRuntime.getJobOperator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startCartesianMatrixJob
import javax.batch.runtime.BatchRuntime; //导入方法依赖的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);
}
示例2: startIVMatrixJob
import javax.batch.runtime.BatchRuntime; //导入方法依赖的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()));
}
示例3: startMatrixJob
import javax.batch.runtime.BatchRuntime; //导入方法依赖的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);
}
示例4: startNeighborsJob
import javax.batch.runtime.BatchRuntime; //导入方法依赖的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);
}
示例5: setup
import javax.batch.runtime.BatchRuntime; //导入方法依赖的package包/类
@PostCreated
@PostRecovery
@PostConfig
public void setup()
{
_batchDataProvider = new BatchDataProvider(this);
BatchDataProviderMap.getBatchDataProviderMap().add(_batchDataProvider);
JobOperator jobOperator = BatchRuntime.getJobOperator();
Properties jobParameters = new Properties();
jobParameters.setProperty(BatchDataProviderMap.ID_PROPERTYNAME, _batchDataProvider.getId());
long execId = jobOperator.start(_properties.get(JOBID_PROPERTYNAME), jobParameters);
logger.log(Level.FINE, "BatchDataSource: " + execId);
}
示例6: testEndNormallyExecuteBoth
import javax.batch.runtime.BatchRuntime; //导入方法依赖的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());
}
示例7: startBatches
import javax.batch.runtime.BatchRuntime; //导入方法依赖的package包/类
public void startBatches() throws JobSecurityException, JobStartException, NoSuchJobExecutionException {
JobOperator jobOperator = BatchRuntime.getJobOperator();
logger.log(Level.INFO, "starting simple");
Long executionId = jobOperator.start("simple", new Properties());
JobExecution jobExecution = jobOperator.getJobExecution(executionId);
logger.log(Level.INFO, "Started simple job with id {0}", jobExecution.getExecutionId());
logger.log(Level.INFO, "Status simple {0}", jobExecution.getBatchStatus());
// logger.log(Level.INFO, "starting chunk");
// Long chunkExecutionId = jobOperator.start("chunk", new Properties());
// JobExecution chunkJobExecution = jobOperator.getJobExecution(chunkExecutionId);
//
// logger.log(Level.INFO, "Status chunk {0}", chunkJobExecution.getBatchStatus());
// logger.log(Level.INFO, "Started chunk job with id {0}", chunkJobExecution.getExecutionId());
}
示例8: testRolledBackDuringWork
import javax.batch.runtime.BatchRuntime; //导入方法依赖的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);
}
示例9: instances
import javax.batch.runtime.BatchRuntime; //导入方法依赖的package包/类
@Test
public void instances() {
// ensure we have at least one thing to print
final JobOperator jobOperator = BatchRuntime.getJobOperator();
final long id = jobOperator.start("sample", null);
main(new String[]{"instances", "-name", "sample"});
// output looks like:
// sample has 3 job instances
//
// instance id
// -----------
// 0
// 1
assertThat(stdout.getLog(), containsString("sample has"));
assertThat(stdout.getLog(), containsString("instance id"));
Batches.waitForEnd(jobOperator, id);
}
示例10: read
import javax.batch.runtime.BatchRuntime; //导入方法依赖的package包/类
@Test
public void read() throws Exception {
final String path = "target/work/JSefaXmlReader.txt";
final Properties jobParams = new Properties();
jobParams.setProperty("input", path);
final JobOperator jobOperator = BatchRuntime.getJobOperator();
IOs.write(path, "<Records><Record><value1>v11</value1><value2>v12</value2></Record><Record><value1>v21</value1><value2>v22</value2></Record><Record><value1>v31</value1><value2>v32</value2></Record></Records>");
Batches.waitForEnd(jobOperator, jobOperator.start("jsefa-xml-reader", jobParams));
final int size = StoreItems.ITEMS.size();
assertEquals(size, 3);
for (int i = 1; i <= size; i++) {
final Record Record = StoreItems.ITEMS.get(i - 1);
assertEquals(Record.getValue1(), "v" + i + "1");
assertEquals(Record.getValue2(), "v" + i + "2");
}
}
示例11: testPartitionPropertyResolverForMapper
import javax.batch.runtime.BatchRuntime; //导入方法依赖的package包/类
@Test
public void testPartitionPropertyResolverForMapper() throws Exception {
final JobOperator op = BatchRuntime.getJobOperator();
Properties jobParams = new Properties();
jobParams.setProperty(STEP_PROP, STEP_PROP_VAL);
final long id = op.start("partition-propertyResolver", jobParams);
Batches.waitForEnd(op, id);
assertEquals(op.getJobExecution(id).getBatchStatus(), BatchStatus.COMPLETED);
String exitStatus = op.getJobExecution(id).getExitStatus();
Properties props = PropertyHelper.stringToProperties(exitStatus);
String valFromStepProp = props.getProperty(STEP_CONTEXT_PROPERTY);
String valFromSubstitution = props.getProperty(SUBSTITUTION_PROPERTY);
assertEquals(valFromStepProp, STEP_PROP_VAL, "Compare values from step-level property with param used in substitution");
assertEquals(valFromSubstitution, STEP_PROP_VAL, "Compare values from step-level property with a collector-property using this step-level property via a 'jobProperties' substitution.");
}
示例12: run
import javax.batch.runtime.BatchRuntime; //导入方法依赖的package包/类
@Test
public void run() {
final JobOperator op = BatchRuntime.getJobOperator();
final long id = op.start("partition-metrics", null);
Batches.waitForEnd(op, id);
final List<StepExecution> steps = op.getStepExecutions(id);
assertEquals(1, steps.size());
final StepExecution exec = steps.iterator().next();
final Metric[] metrics = exec.getMetrics();
int checked = 0;
for (final Metric metric : metrics) {
if (Metric.MetricType.ROLLBACK_COUNT == metric.getType()) {
assertEquals(metric.getValue(), 1);
checked++;
} else if (Metric.MetricType.READ_SKIP_COUNT == metric.getType()) {
assertEquals(metric.getValue(), 1);
checked++;
}
}
assertEquals(checked, 2);
}
示例13: read
import javax.batch.runtime.BatchRuntime; //导入方法依赖的package包/类
@Test
public void read() throws Exception {
final String path = "target/work/CommonsCsvReaderTest.txt";
final Properties jobParams = new Properties();
jobParams.setProperty("input", path);
final JobOperator jobOperator = BatchRuntime.getJobOperator();
IOs.write(path, "v11,v12\nv21,v22\nv31,v32");
Batches.waitForEnd(jobOperator, jobOperator.start("csv-reader", jobParams));
final int size = StoreItems.ITEMS.size();
assertEquals(size, 3);
for (int i = 1; i <= size; i++) {
final CSVRecord record = StoreItems.ITEMS.get(i - 1);
assertEquals("v" + i + "1", record.get(0));
assertEquals("v" + i + "2", record.get(1));
}
}
示例14: testRead
import javax.batch.runtime.BatchRuntime; //导入方法依赖的package包/类
@Test
public void testRead() throws Exception {
String path = "target/work/JSefaFlrReaderWithConverter.csv";
IOs.write(path,
"string1 123 1 201007161200\n" +
"string2 345 2 199004041350\n" +
"string3 9876543211 197905072358");
Properties props = new Properties();
props.setProperty("input", path);
JobOperator operator = BatchRuntime.getJobOperator();
Batches.waitForEnd(operator, operator.start("jsefa-flr-reader-converter", props));
Set<RecordWithConverter> expectedItems = new HashSet<RecordWithConverter>();
expectedItems.add(new RecordWithConverter("string1", 123L, RecordWithConverter.RecordEnum.ONE, new GregorianCalendar(2010, Calendar.JULY, 16, 12, 0).getTime()));
expectedItems.add(new RecordWithConverter("string2", 345L, RecordWithConverter.RecordEnum.TWO, new GregorianCalendar(1990, Calendar.APRIL, 4, 13, 50).getTime()));
expectedItems.add(new RecordWithConverter("string3", 987654321L, RecordWithConverter.RecordEnum.ONE, new GregorianCalendar(1979, Calendar.MAY, 7, 23, 58).getTime()));
Assert.assertEquals(Storage.STORAGE.size(), expectedItems.size());
Assert.assertTrue(Storage.STORAGE.containsAll(expectedItems));
}
示例15: write
import javax.batch.runtime.BatchRuntime; //导入方法依赖的package包/类
@Test
public void write() throws Exception {
final JobOperator jobOperator = BatchRuntime.getJobOperator();
Batches.waitForEnd(jobOperator, jobOperator.start("jpa-writer", new Properties()));
final Connection c = DriverManager.getConnection("jdbc:derby:memory:jpa;create=true", "app", "app");
final PreparedStatement select = c.prepareStatement("select name from Person");
final ResultSet set = select.executeQuery();
final Collection<String> names = new ArrayList<String>();
while (set.next()) {
names.add(set.getString("name"));
}
c.close();
assertEquals(2, names.size());
}