NIFI-841: Ensure that IOExceptions on session commit are handled properly

Signed-off-by: joewitt <joewitt@apache.org>
Signed-off-by: Mark Payne <markap14@hotmail.com>
This commit is contained in:
Mark Payne 2015-08-11 16:19:47 -04:00
parent a264c49d80
commit 35439db347
1 changed files with 165 additions and 138 deletions

View File

@ -292,9 +292,10 @@ public final class StandardProcessSession implements ProcessSession, ProvenanceE
@SuppressWarnings({"unchecked", "rawtypes"})
private void commit(final Checkpoint checkpoint) {
try {
final long commitStartNanos = System.nanoTime();
resetWriteClaims();
resetWriteClaims(false);
resetReadClaim();
final long updateProvenanceStart = System.nanoTime();
@ -424,6 +425,15 @@ public final class StandardProcessSession implements ProcessSession, ProvenanceE
LOG.debug(timingInfo.toString());
}
} catch (final Exception e) {
try {
rollback();
} catch (final Exception e1) {
e.addSuppressed(e1);
}
throw e;
}
}
private void updateEventRepository(final Checkpoint checkpoint) {
@ -2115,23 +2125,40 @@ public final class StandardProcessSession implements ProcessSession, ProvenanceE
}
private void resetWriteClaims() {
resetWriteClaims(true);
}
private void resetWriteClaims(final boolean suppressExceptions) {
try {
if (currentWriteClaimStream != null) {
try {
currentWriteClaimStream.flush();
} finally {
currentWriteClaimStream.close();
}
} catch (final Exception e) {
}
} catch (final IOException e) {
if (!suppressExceptions) {
throw new FlowFileAccessException("Unable to flush the output of FlowFile to the Content Repository");
}
}
currentWriteClaimStream = null;
currentWriteClaim = null;
currentWriteClaimFlowFileCount = 0;
currentWriteClaimSize = 0L;
for (final ByteCountingOutputStream out : appendableStreams.values()) {
try {
try {
out.flush();
} finally {
out.close();
} catch (final Exception e) {
}
} catch (final IOException e) {
if (!suppressExceptions) {
throw new FlowFileAccessException("Unable to flush the output of FlowFile to the Content Repository");
}
}
}
appendableStreams.clear();