【发布时间】:2017-08-07 02:36:47
【问题描述】:
我正在使用 Spring Boot 中的 async task executor 对我的数百万条记录的数据进行分区,块大小为 1000,网格大小为 10。 我正在使用 Item Reader 之前步骤中的 StepExecution 获取分区数据(来自 Partitioner 类)的开始和结束索引,以便从数据库中获取特定的分区数据。
问题是只有一个分区被读写。
例如: 物品阅读器
beforeStep(StepExecution execution){
int startIndex = execution.getExecutionContext().getInt("startIndexValue")
int endIndex = execution.getExecutionContext().getInt("endIndexValue")
List testDataList = getTestDatabetween(startIndex, endIndex);
}
项目阅读器 遍历 testData List 并将 testData 值返回给 writer
testData read()
{
if(!testData.isEmpty()){
testData = testDataList.get(testIndex);
testIndex++;
}
return testData;
}
TestData = Partition1, Partition2, Partition3
只有最后一个分区 Partition3 被读取、处理和写入。
我希望同时读取所有分区。
【问题讨论】:
-
您是否查看了 BATCH_STEP_EXECUTION 以查看是否创建了其他分区?您是否尝试过在调试中运行以查看
getTestDatabetwee方法是否正在为您提交的范围拉回行?您是否尝试过添加日志记录?
标签: spring-boot spring-batch partitioning