Skip to content

Commit

Permalink
Do not fail if flush is called before any writes (#1901)
Browse files Browse the repository at this point in the history
This commit logs a warning instead of throwing an exception if an attempt to flush before writing is made (which our
Storm implementation can do).
Closes #1357
  • Loading branch information
masseyke committed Feb 22, 2022
1 parent d64225a commit f70381f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions mr/src/main/java/org/elasticsearch/hadoop/rest/RestRepository.java
Expand Up @@ -194,13 +194,20 @@ private void doWriteToIndex(BytesRef payload) {
}

public BulkResponse tryFlush() {
Assert.isTrue(writeInitialized, "Cannot flush non-initialized write operation");
return bulkProcessor.tryFlush();
if (writeInitialized) {
return bulkProcessor.tryFlush();
} else {
log.warn("Attempt to flush before any data had been written");
return BulkResponse.complete();
}
}

public void flush() {
Assert.isTrue(writeInitialized, "Cannot flush non-initialized write operation");
bulkProcessor.flush();
if (writeInitialized) {
bulkProcessor.flush();
} else {
log.warn("Attempt to flush before any data had been written");
}
}

@Override
Expand Down

0 comments on commit f70381f

Please sign in to comment.