- restore WRITE_STATISTICS_NAME from execution context on restart
- don't assume output file is always present on restart (could be deleted by previous execution if shouldDeleteIfEmpty flag was set)
This commit is contained in:
@@ -469,7 +469,14 @@ InitializingBean {
|
||||
*/
|
||||
public void restoreFrom(ExecutionContext executionContext) {
|
||||
lastMarkedByteOffsetPosition = executionContext.getLong(getExecutionContextKey(RESTART_DATA_NAME));
|
||||
restarted = true;
|
||||
linesWritten = executionContext.getLong(getExecutionContextKey(WRITTEN_STATISTICS_NAME));
|
||||
if (shouldDeleteIfEmpty && linesWritten == 0) {
|
||||
// previous execution deleted the output file because no items were written
|
||||
restarted = false;
|
||||
lastMarkedByteOffsetPosition = 0;
|
||||
} else {
|
||||
restarted = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -585,7 +592,6 @@ InitializingBean {
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
linesWritten = 0;
|
||||
}
|
||||
|
||||
public boolean isInitialized() {
|
||||
|
||||
@@ -368,6 +368,13 @@ ResourceAwareItemWriterItemStream<T>, InitializingBean {
|
||||
startAtPosition = executionContext.getLong(getExecutionContextKey(RESTART_DATA_NAME));
|
||||
currentRecordCount = executionContext.getLong(getExecutionContextKey(WRITE_STATISTICS_NAME));
|
||||
restarted = true;
|
||||
if (shouldDeleteIfEmpty && currentRecordCount == 0) {
|
||||
// previous execution deleted the output file because no items were written
|
||||
restarted = false;
|
||||
startAtPosition = 0;
|
||||
} else {
|
||||
restarted = true;
|
||||
}
|
||||
}
|
||||
|
||||
open(startAtPosition, restarted);
|
||||
|
||||
Reference in New Issue
Block a user