Skip to content
Permalink
Browse files
BATCHEE-82 better flushing in TransactionalWriter
  • Loading branch information
Romain Manni-Bucau committed Dec 3, 2015
1 parent ca7e91e commit 7aef3e541f8a10a84253eab27aa1f4a816949d60
Showing 2 changed files with 9 additions and 3 deletions.
@@ -189,6 +189,7 @@ public void writeItems(final List<Object> list) throws Exception {
throw new IllegalStateException("No way to write " + o + ". Does it implement Iterable<String> or did you set up a mapper?");
}
}
writer.flush();
}

@Override
@@ -84,16 +84,21 @@ public void write(final char[] cbuf, final int off, final int len) throws IOExce
@Override
public void flush() throws IOException {
if (!Synchronizations.hasTransaction()) {
delegate.force(false);
position = delegate.position();
fileFlush();
} else {
position = delegate.position() + buffer().length();
}
}

private void fileFlush() throws IOException {
delegate.force(false);
position = delegate.position();
}

@Override
public void close() throws IOException {
if (!Synchronizations.hasTransaction() && delegate.isOpen()) {
if ((!Synchronizations.hasTransaction() || Synchronizations.get(bufferKey) == null) && delegate.isOpen()) {
fileFlush();
delegate.close();
} else {
closed = true;

0 comments on commit 7aef3e5

Please sign in to comment.