This commit is contained in:
parent
e0dcd24604
commit
70bfd94b64
2 changed files with 43 additions and 8 deletions
|
|
@ -27,6 +27,7 @@ public class Processor {
|
||||||
for (Stage currStage : pipeline) {
|
for (Stage currStage : pipeline) {
|
||||||
log.info("uuid {}. Stage: {}", task.getUuid(), currStage.getClass().getSimpleName());
|
log.info("uuid {}. Stage: {}", task.getUuid(), currStage.getClass().getSimpleName());
|
||||||
result = currStage.process(task);
|
result = currStage.process(task);
|
||||||
|
log.info("uuid {}. Stage {} finished", task.getUuid(), currStage.getClass().getSimpleName());
|
||||||
if (Arrays.asList(StageResult.ERROR, StageResult.COMPLETE).contains(result)) break;
|
if (Arrays.asList(StageResult.ERROR, StageResult.COMPLETE).contains(result)) break;
|
||||||
}
|
}
|
||||||
long endMills = System.currentTimeMillis();
|
long endMills = System.currentTimeMillis();
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,12 @@ import ru.spcex.clearing.dbf.importer.logic.data.ResultContainer;
|
||||||
import ru.spcex.clearing.dbf.importer.logic.data.enums.ETable;
|
import ru.spcex.clearing.dbf.importer.logic.data.enums.ETable;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@Service("dbfImporterService")
|
@Service("dbfImporterService")
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
|
|
@ -37,15 +41,45 @@ public class DBFImporterService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(ETable specificTable) {
|
public void run(ETable specificTable) {
|
||||||
log.info("performing import {}", specificTable != null ? specificTable.name() : "");
|
log.info("adding import task {}", specificTable != null ? specificTable.name() : "");
|
||||||
Map<ETable, List<File>> newFiles = fileChecker.checkNewFiles(specificTable);
|
executorService.execute(() -> {
|
||||||
for (Map.Entry<ETable, List<File>> newFilesEntry : newFiles.entrySet()) {
|
log.info("checking new files... {}", specificTable != null ? specificTable.name() : "");
|
||||||
ETable currTable = newFilesEntry.getKey();
|
Map<ETable, List<File>> newFiles = fileChecker.checkNewFiles(specificTable);
|
||||||
List<File> fileList = newFilesEntry.getValue();
|
if (log.isDebugEnabled()) {
|
||||||
for (File dbfFile : fileList) {
|
log.debug("following files will be processed {}", forLogging(newFiles));
|
||||||
executorService.execute(() -> processor.process(ResultContainer.createNewTask(currTable, dbfFile)));
|
} else {
|
||||||
|
log.info("following files will be processed {}", forLoggingSizeOnly(newFiles));
|
||||||
}
|
}
|
||||||
}
|
for (Map.Entry<ETable, List<File>> newFilesEntry : newFiles.entrySet()) {
|
||||||
|
ETable currTable = newFilesEntry.getKey();
|
||||||
|
List<File> fileList = newFilesEntry.getValue();
|
||||||
|
for (File dbfFile : fileList) {
|
||||||
|
processor.process(ResultContainer.createNewTask(currTable, dbfFile));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String forLogging(Map<ETable, List<File>> files) {
|
||||||
|
return files
|
||||||
|
.entrySet()
|
||||||
|
.stream()
|
||||||
|
.flatMap((Function<Map.Entry<ETable, List<File>>, Stream<String>>) entry -> {
|
||||||
|
List<String> r = new LinkedList<>();
|
||||||
|
for (File file : entry.getValue()) {
|
||||||
|
r.add(entry.getKey().name() + " " + file.toPath());
|
||||||
|
}
|
||||||
|
return r.stream();
|
||||||
|
})
|
||||||
|
.collect(Collectors.joining(";", "[", "]"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String forLoggingSizeOnly(Map<ETable, List<File>> files) {
|
||||||
|
return files
|
||||||
|
.entrySet()
|
||||||
|
.stream()
|
||||||
|
.map(entry -> entry.getKey().name() + " " + entry.getValue().size())
|
||||||
|
.collect(Collectors.joining(";", "[", "]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue