대용량 파일의 파일 크기는 10 억 ~ 50 억 개입니다. 나는 청크 지향적 인 프로세싱을 사용할 계획이고 내 생각은이다.대용량 파일 (10 억 ~ 50 억 개의 플랫 파일 데이터)의 일괄 처리
1) 각 파일에서 10K라고 말해라.
2) 10 억 개 레코드가 있다면 나는 10K 기록
3
) 나는이 10000 개 파일을 분할하고 싶은 10 개 스레드를 사용하여 처리하고 싶습니다를 포함 10000 개 파일 각을 얻을 것이다. 사용자 지정 MultiResourcePartioner를 사용했습니다.4) 10 개의 스레드가 분할 프로세스에서 생성 된 10000 개의 파일을 모두 처리해야합니다.
5) 메모리 문제가 발생할 수있는 경우와 동일한 수의 스레드를 파일 수와 같게 만들고 싶지 않습니다. 내가 바라는 것은 단지 10 개의 스레드 만 사용하여 파일을 처리하고자하는 파일의 수와 관계가 없습니다.
전문가가 스프링 배치를 사용하여 달성 할 수 있음을 알려주십시오. 그렇다면 포인터 또는 참조 구현을 공유하십시오.
예 :
<bean id="transformPartitioner"
class="com.example.transformers.partition.TransformerPartitioner">
<property name="outputPath" value="${output.directory}" />
</bean>
<bean id="loadTransformData" class="com.example.transformers.step.LoadTransformData"
factory-method="reader" scope="step">
<constructor-arg value="#{stepExecutionContext[outputFile]}" />
</bean>
<bean id="processTransformData" class="com.example.transformers.step.ProcessTransformData"
scope="step">
<property name="threadName" value="#{stepExecutionContext[threadName]}" />
<property name="sourceFileName" value="#{jobParameters[filename]}" />
</bean>
<bean id="notifyToJMS" class="com.example.transformers.step.NotifyToJMS"
scope="step">
<property name="fileName" value="#{stepExecutionContext[outputFile]}" />
</bean>
<bean id="outputFileDeletingTasklet"
class="com.example.transformers.step.OutputFileDeletingTasklet"
scope="step">
<property name="directory" value="file:${output.directory}" />
</bean>
<bean class="org.springframework.batch.core.scope.StepScope" />
<bean id="jobRepository"
class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean">
<property name="transactionManager" ref="transactionManager" />
</bean>
<bean id="jobLauncher"
class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository" />
</bean>
<bean id="transactionManager"
class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />
사용자 정의 멀티 자원 분할 :
public Map<String, ExecutionContext> partition(int gridSize) {
int index = 0;
File directory = new File(outputPath);
File[] fList = directory.listFiles();
Map result = new HashMap(gridSize);
for (File file : fList) {
if (file.isFile()) {
ExecutionContext exContext = new ExecutionContext();
logger.info(loggerClassName+" Starting : Thread [" + index + "] for file : " + file.getName());
exContext.put(constants.THREAD_NAME, "Thread" + index);
exContext.put(constants.OUTPUT_FILE, outputPath + file.getName());
exContext.put(constants.OUTPUT_FILE_NAME, file.getName());
result.put(constants.PARTITION + index, exContext);
index++;
}
}
당신의 응답을 주셔서 감사합니다.
큰 숫자를 다루는 사람들의 숫자는 아주 적습니다. 세계는 아마도 Spring Batch를 사용하여 수십억 개의 레코드를 처리하는 데 더 많은 전문가를 사용할 수 있습니다. 그래서 시도해보고 결과를 확인한 다음 다시보고하십시오 :) – Paul
이 문제를 해결하는 방법을 모르겠습니다. 파티션을 제어 할 방법이 없습니까? 배치가 현명하다면 가능할 것입니다. 예를 들어 첫 번째 일괄 처리 100 개의 파일과 두 번째 일괄 처리 100 개의 파티션을 다음 100 개의 파일로 나눕니다. 이렇게 ... 내 요구 사항은 1 억 5 천만에서 5 억 2 천만 개의 파일을 플랫 파일 데이터로 사용합니다. – Sai
@Sai : 죄송합니다. 귀하의 답변은 내 대답에 대한 의견이어야하며 답변 자체는 아닙니다. 문제가 해결되었음을 알려주십시오. –