本文整理汇总了Java中org.springframework.batch.item.ExecutionContext.putLong方法的典型用法代码示例。如果您正苦于以下问题:Java ExecutionContext.putLong方法的具体用法?Java ExecutionContext.putLong怎么用?Java ExecutionContext.putLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.batch.item.ExecutionContext
的用法示例。
在下文中一共展示了ExecutionContext.putLong方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
@Override
public void update(ExecutionContext executionContext) {
if (state == null) {
throw new ItemStreamException(
"ItemStream not open or already closed.");
}
Assert.notNull(executionContext, "ExecutionContext must not be null");
if (saveState) {
try {
executionContext.putLong(
getExecutionContextKey(RESTART_DATA_NAME),
state.position());
} catch (IOException e) {
throw new ItemStreamException(
"ItemStream does not return current position properly",
e);
}
executionContext.putLong(
getExecutionContextKey(WRITTEN_STATISTICS_NAME),
state.jsonObjectsWritten);
}
}
示例2: execute
import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
/**
* @param contribution Set the step contribution
* @param chunkContext Set the chunk context
* @return the repeat status
* @throws Exception if there is a problem deleting the resources
*/
public final RepeatStatus execute(final StepContribution contribution,
final ChunkContext chunkContext)
throws Exception {
UUID uuid1 = UUID.randomUUID();
String temporaryFileName = harvesterSpoolDirectory + File.separator
+ uuid1.toString() + ".xml";
File temporaryFile = new File(temporaryFileName);
ExecutionContext executionContext = chunkContext.getStepContext()
.getStepExecution().getJobExecution().getExecutionContext();
executionContext.put("startindex", 0);
executionContext.put("temporary.file.name", temporaryFile.getAbsolutePath());
executionContext.putLong("job.execution.id", chunkContext.getStepContext().getStepExecution().getJobExecutionId());
return RepeatStatus.FINISHED;
}
示例3: execute
import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
/**
* @param contribution Set the step contribution
* @param chunkContext Set the chunk context
* @return the repeat status
* @throws Exception if there is a problem deleting the resources
*/
public final RepeatStatus execute(final StepContribution contribution, final ChunkContext chunkContext)
throws Exception {
UUID uuid = UUID.randomUUID();
String unpackDirectoryName = harvesterSpoolDirectory + File.separator
+ uuid.toString();
String temporaryFileName = harvesterSpoolDirectory + File.separator
+ uuid.toString() + ".zip";
File unpackDirectory = new File(unpackDirectoryName);
unpackDirectory.mkdir();
File temporaryFile = new File(temporaryFileName);
ExecutionContext executionContext = chunkContext.getStepContext()
.getStepExecution().getJobExecution().getExecutionContext();
executionContext.put("temporary.file.name",temporaryFile.getAbsolutePath());
executionContext.put("unpack.directory.name",unpackDirectory.getAbsolutePath());
executionContext.putLong("job.execution.id", chunkContext.getStepContext().getStepExecution().getJobExecutionId());
return RepeatStatus.FINISHED;
}
示例4: marshallExecutionContextTest
import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
@Test
public void marshallExecutionContextTest() throws Exception {
ExecutionContext ec = new ExecutionContext();
ec.putString("testName", "testValue");
ec.putLong("testLong", 123L);
ec.putDouble("testDouble", 123D);
ec.putInt("testInteger", 123);
ExecutionContextAdapter adapter = new ExecutionContextAdapter();
jaxb2Marshaller.marshal(adapter.marshal(ec), result);
Fragment frag = new Fragment(new DOMBuilder().build(doc));
frag.setNamespaces(getNamespaceProvider().getNamespaces());
frag.prettyPrint();
frag.assertElementExists("/msb:executionContext/msb:map/entry/key[text() = 'testName']");
frag.assertElementExists("/msb:executionContext/msb:map/entry/value[@xsi:type = 'xs:int'][text() = '123']");
frag.assertElementExists("/msb:executionContext/msb:map/entry/value[@xsi:type = 'xs:long'][text() = '123']");
frag.assertElementExists("/msb:executionContext/msb:map/entry/value[@xsi:type = 'xs:string'][text() = 'testValue']");
frag.assertElementExists("/msb:executionContext/msb:map/entry/value[@xsi:type = 'xs:double'][text() = '123.0']");
frag.assertElementExists("/msb:executionContext/msb:hashCode");
}
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:20,代码来源:MarshallSpringBatchPojoToXmlTest.java
示例5: testUpdateContext
import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
@Transactional
@Test
public void testUpdateContext() {
ExecutionContext ctx = new ExecutionContext(Collections
.singletonMap("key", "value"));
jobExecution.setExecutionContext(ctx);
dao.saveExecutionContext(jobExecution);
ctx.putLong("longKey", 7);
dao.updateExecutionContext(jobExecution);
ExecutionContext retrieved = dao.getExecutionContext(jobExecution);
assertEquals(ctx, retrieved);
assertEquals(7, retrieved.getLong("longKey"));
}
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:17,代码来源:MarkLogicExecutionContextDaoTests.java
示例6: execute
import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
/**
* @param contribution Set the step contribution
* @param chunkContext Set the chunk context
* @return the repeat status
* @throws Exception if there is a problem deleting the resources
*/
public final RepeatStatus execute(final StepContribution contribution, final ChunkContext chunkContext) throws Exception {
UUID uuid = UUID.randomUUID();
String unpackDirectoryName = harvesterSpoolDirectory + File.separator + uuid.toString();
String temporaryFileName = harvesterSpoolDirectory + File.separator + uuid.toString() + ".zip";
File unpackDirectory = new File(unpackDirectoryName);
unpackDirectory.mkdir();
File temporaryFile = new File(temporaryFileName);
ExecutionContext executionContext = chunkContext.getStepContext().getStepExecution().getJobExecution().getExecutionContext();
executionContext.put("temporary.file.name", temporaryFile.getAbsolutePath());
executionContext.put("unpack.directory.name", unpackDirectory.getAbsolutePath());
executionContext.putLong("job.execution.id", chunkContext.getStepContext().getStepExecution().getJobExecutionId());
log.debug("setting temporary.file.name to {}", temporaryFile.getAbsolutePath());
log.debug("execution context: {}", executionContext);
return RepeatStatus.FINISHED;
}
示例7: getStepExecution
import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
private StepExecution getStepExecution() {
JobExecution jobExecution = new JobExecution(1L, null, "hi");
final StepExecution stepExecution = new StepExecution("step1", jobExecution);
jobExecution.createStepExecution("step1");
final ExecutionContext executionContext = stepExecution.getExecutionContext();
executionContext.putInt("counter", 1234);
executionContext.putDouble("myDouble", 1.123456d);
executionContext.putLong("Josh", 4444444444L);
executionContext.putString("awesomeString", "Yep");
executionContext.put("hello", "world");
executionContext.put("counter2", 9999);
return stepExecution;
}
示例8: execute
import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
/**
* @param contribution Set the step contribution
* @param chunkContext Set the chunk context
* @return the repeat status
* @throws Exception if there is a problem deleting the resources
*/
public final RepeatStatus execute(final StepContribution contribution,
final ChunkContext chunkContext)
throws Exception {
ExecutionContext executionContext = chunkContext.getStepContext()
.getStepExecution().getJobExecution().getExecutionContext();
UUID uuid = UUID.randomUUID();
String taxonFileName = harvesterSpoolDirectory + File.separator
+ uuid.toString() + "-taxon.xml";
String imageFileName = harvesterSpoolDirectory + File.separator
+ uuid.toString() + "-image.xml";
String outputFileName = harvesterSpoolDirectory + File.separator
+ uuid.toString() + "-output.json";
String inputFileName = harvesterSpoolDirectory + File.separator
+ uuid.toString() + "-input.xml";
File taxonFile = new File(taxonFileName);
executionContext.put("taxon.file.name", taxonFile.getAbsolutePath());
File imageFile = new File(imageFileName);
executionContext.put("image.file.name", imageFile.getAbsolutePath());
File inputFile = new File(inputFileName);
executionContext.put("input.file.name", inputFile.getAbsolutePath());
File outputFile = new File(outputFileName);
executionContext.put("output.file.name", outputFile.getAbsolutePath());
executionContext.putLong("job.execution.id", chunkContext.getStepContext().getStepExecution().getJobExecutionId());
return RepeatStatus.FINISHED;
}
示例9: update
import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
/**
* @param executionContext Set the execution context
* Get the restart data.
*
* @see org.springframework.batch.item.ItemStream#update(ExecutionContext)
*/
public final void update(final ExecutionContext executionContext) {
if (saveState) {
Assert.notNull(executionContext,
"ExecutionContext must not be null");
executionContext.putLong(getKey(RESTART_DATA_NAME), getPosition());
executionContext.putLong(getKey(WRITE_STATISTICS_NAME),
currentRecordCount);
}
}
示例10: execute
import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
/**
* @param contribution Set the step contribution
* @param chunkContext Set the chunk context
* @return the repeat status
* @throws Exception if there is a problem deleting the resources
*/
public RepeatStatus execute( StepContribution contribution, ChunkContext chunkContext)
throws Exception {
UUID uuid = UUID.randomUUID();
String temporaryFileName = harvesterSpoolDirectory + File.separator
+ uuid.toString() + "." + extension;
File temporaryFile = new File(temporaryFileName);
ExecutionContext executionContext = chunkContext.getStepContext().getStepExecution().getJobExecution().getExecutionContext();
executionContext.put("temporary.file.name", temporaryFile.getAbsolutePath());
executionContext.putLong("job.execution.id", chunkContext.getStepContext().getStepExecution().getJobExecutionId());
return RepeatStatus.FINISHED;
}
示例11: update
import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
/**
* Get the restart data.
*
* @see org.springframework.batch.item.ItemStream#update(ExecutionContext)
*/
public void update(ExecutionContext executionContext) {
if (saveState) {
Assert.notNull(executionContext,
"ExecutionContext must not be null");
executionContext.putLong(getKey(RESTART_DATA_NAME), getPosition());
executionContext.putLong(getKey(WRITE_STATISTICS_NAME),
currentRecordCount);
}
}
示例12: partitionCommon
import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
public Map<String, ExecutionContext> partitionCommon(int gridSize)
{
LogUtil.getLogger().info("ColumnRangePartitioner start...");
LogUtil logUtil = LogUtil.newInstance();
long min = jdbcTemplate.queryForObject("SELECT MIN(gfa." + column + ") from (" + table+ ") gfa",Long.class);
long max = jdbcTemplate.queryForObject("SELECT MAX(gfa." + column + ") from (" + table+ ") gfa",Long.class);
long targetSize = (max - min) / gridSize + 1;
LogUtil.getLogger().info("+++++++++++++++++最大值:"+max+"最小值:"+min+"+++++++++++++++++++++++++++++++++");
Map<String, ExecutionContext> result = new HashMap<String, ExecutionContext>();
long number = 0;
long start = min;
long end = start + targetSize - 1;
while (start <= max)
{
ExecutionContext value = new ExecutionContext();
result.put("partition" + number, value);
if (end >= max)
{
end = max;
}
value.putLong("min", start);
value.putLong("max", end);
LogUtil.getLogger().info("min:" + start + " max:" + end);
start += targetSize;
end += targetSize;
number++;
}
LogUtil.getLogger().info("ColumnRangePartitioner end. Cost:"+logUtil.cost());
return result;
}
示例13: testUpdateStepContext
import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
@Transactional
@Test
public void testUpdateStepContext() {
ExecutionContext ctx = new ExecutionContext(Collections.singletonMap("key", "value"));
stepExecution.setExecutionContext(ctx);
dao.saveExecutionContext(stepExecution);
ctx.putLong("longKey", 7);
dao.updateExecutionContext(stepExecution);
ExecutionContext retrieved = dao.getExecutionContext(stepExecution);
assertEquals(ctx, retrieved);
assertEquals(7, retrieved.getLong("longKey"));
}
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:16,代码来源:MarkLogicExecutionContextDaoTests.java
示例14: execute
import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
/**
* @param contribution Set the step contribution
* @param chunkContext Set the chunk context
* @return the repeat status
* @throws Exception if there is a problem deleting the resources
*/
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
UUID uuid = UUID.randomUUID();
String temporaryFileName = harvesterSpoolDirectory + File.separator + uuid.toString() + "." + extension;
File temporaryFile = new File(temporaryFileName);
ExecutionContext executionContext = chunkContext.getStepContext().getStepExecution().getJobExecution().getExecutionContext();
executionContext.put("temporary.file.name", temporaryFile.getAbsolutePath());
executionContext.putLong("job.execution.id", chunkContext.getStepContext().getStepExecution().getJobExecutionId());
log.debug("setting temporary.file.name to {}", temporaryFile.getAbsolutePath());
return RepeatStatus.FINISHED;
}
示例15: execute
import org.springframework.batch.item.ExecutionContext; //导入方法依赖的package包/类
/**
* @param contribution Set the step contribution
* @param chunkContext Set the chunk context
* @return the repeat status
* @throws Exception if there is a problem deleting the resources
*/
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext)
throws Exception {
UUID uuid1 = UUID.randomUUID();
String splitFileName = harvesterSpoolDirectory + File.separator + uuid1.toString() + ".json";
UUID uuid2 = UUID.randomUUID();
String temporaryFileName = harvesterSpoolDirectory + File.separator + uuid2.toString() + ".json";
File temporaryFile = new File(temporaryFileName);
File splitFile = new File(splitFileName);
ExecutionContext executionContext = chunkContext.getStepContext().getStepExecution().getJobExecution().getExecutionContext();
String subsetRank = null;
String subsetValue = null;
if (subtribe != null) {
subsetRank = "subtribe";
subsetValue = subtribe;
} else if (tribe != null) {
subsetRank = "tribe";
subsetValue = tribe;
} else if (subfamily != null) {
subsetRank = "subfamily";
subsetValue = subfamily;
} else if (family != null) {
subsetRank = "family";
subsetValue = family;
}
String queryString = null;
if (subsetValue != null) {
queryString = "select t.id from Taxon t left join t.acceptedNameUsage a where t.#subsetRank = :subsetValue or a.#subsetRank = :subsetValue";
queryString = queryString.replaceAll("#subsetRank", subsetRank);
executionContext.put("index.taxon.subset.value", subsetValue);
} else {
queryString = "select t.id from MeasurementOrFact m join m.taxon t join m.annotations a where a.jobId = :jobId";
}
executionContext.put("index.taxon.query", queryString);
executionContext.put("temporary.file.name", temporaryFile.getAbsolutePath());
executionContext.put("split.file.name", splitFile.getAbsolutePath());
executionContext.putLong("job.execution.id", chunkContext.getStepContext().getStepExecution().getJobExecutionId());
return RepeatStatus.FINISHED;
}