public class TransactionAwareBufferedWriter extends Writer
FileChannel
that delays actually writing to or closing the
buffer if a transaction is active. If a transaction is detected on the call
to Writer.write(String)
the parameter is buffered and passed on to the
underlying writer only when the transaction is committed.Constructor and Description |
---|
TransactionAwareBufferedWriter(FileChannel channel,
Runnable closeCallback)
Create a new instance with the underlying file channel provided, and a callback
to execute on close.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
flush() |
long |
getBufferSize()
Convenience method for clients to determine if there is any unflushed
data.
|
void |
setEncoding(String encoding) |
void |
setForceSync(boolean forceSync)
Flag to indicate that changes should be force-synced to disk on flush.
|
void |
write(char[] cbuf,
int off,
int len) |
public TransactionAwareBufferedWriter(FileChannel channel, Runnable closeCallback)
channel
- channel used to do the actuall file IOcloseCallback
- callback to execute on closepublic void setEncoding(String encoding)
public void setForceSync(boolean forceSync)
forceSync
- the flag value to setpublic long getBufferSize()
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class Writer
IOException
public void flush() throws IOException
flush
in interface Flushable
flush
in class Writer
IOException
public void write(char[] cbuf, int off, int len) throws IOException
write
in class Writer
IOException
Copyright © 2014 Pivotal. All rights reserved.