public class NIOSequentialFile extends AbstractSequentialFile
AbstractSequentialFile.LocalBufferObserverdirectory, factory, fileSize, position, timedBuffer, timedBufferObserver| Constructor and Description |
|---|
NIOSequentialFile(SequentialFileFactory factory,
File directory,
String file,
int maxIO,
Executor writerExecutor) |
| Modifier and Type | Method and Description |
|---|---|
void |
blockingWriteDirect(ByteBuffer bytes,
boolean sync,
boolean releaseBuffer)
Write directly to the file without using any intermediate buffer and wait completion.
If releaseBuffer is true the provided bytes should be released
through SequentialFileFactory.releaseBuffer(ByteBuffer), if supported. |
int |
calculateBlockStart(int position) |
SequentialFile |
cloneFile() |
void |
close() |
void |
copyTo(SequentialFile dstFile) |
protected TimedBufferObserver |
createTimedBufferObserver() |
void |
fill(int size) |
boolean |
isOpen() |
protected ByteBuffer |
newBuffer(int size,
int limit) |
void |
open()
this.maxIO represents the default maxIO.
|
void |
open(int maxIO,
boolean useExecutor)
The maximum number of simultaneous writes accepted
|
void |
position(long pos) |
int |
read(ByteBuffer bytes) |
int |
read(ByteBuffer bytes,
IOCallback callback) |
long |
size() |
void |
sync() |
String |
toString() |
void |
writeDirect(ByteBuffer bytes,
boolean sync)
Write directly to the file without using intermediate any buffer
|
void |
writeDirect(ByteBuffer bytes,
boolean sync,
IOCallback callback)
Write directly to the file without using any buffer
|
delete, exists, fits, getFile, getFileName, getJavaFile, position, renameTo, setTimedBuffer, write, write, write, writeclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitappendTo, closepublic NIOSequentialFile(SequentialFileFactory factory, File directory, String file, int maxIO, Executor writerExecutor)
protected TimedBufferObserver createTimedBufferObserver()
createTimedBufferObserver in class AbstractSequentialFilepublic int calculateBlockStart(int position)
public boolean isOpen()
public void open()
throws IOException
IOExceptionpublic void open(int maxIO,
boolean useExecutor)
throws IOException
SequentialFileIOExceptionpublic void fill(int size)
throws IOException
IOExceptionpublic void close()
throws IOException,
InterruptedException,
ActiveMQException
close in interface SequentialFileclose in class AbstractSequentialFileIOException - we declare throwing IOException because sub-classes need to do itInterruptedExceptionActiveMQExceptionpublic int read(ByteBuffer bytes) throws Exception
bytes - the ByteBuffer must be compatible with the SequentialFile implementation (AIO or
NIO). To be safe, use a buffer from the corresponding
SequentialFileFactory.newBuffer(int).Exceptionpublic int read(ByteBuffer bytes, IOCallback callback) throws IOException, ActiveMQIllegalStateException
bytes - the ByteBuffer must be compatible with the SequentialFile implementation (AIO or
NIO). To be safe, use a buffer from the corresponding
SequentialFileFactory.newBuffer(int).IOExceptionActiveMQIllegalStateExceptionpublic void sync()
throws IOException
IOExceptionpublic long size()
throws IOException
IOExceptionpublic void position(long pos)
throws IOException
position in interface SequentialFileposition in class AbstractSequentialFileIOException - only declare exception due to signature. Sub-class needs it.public SequentialFile cloneFile()
public void writeDirect(ByteBuffer bytes, boolean sync, IOCallback callback)
SequentialFilebytes - the ByteBuffer must be compatible with the SequentialFile implementation (AIO or
NIO). To be safe, use a buffer from the corresponding
SequentialFileFactory.newBuffer(int).public void writeDirect(ByteBuffer bytes, boolean sync) throws Exception
SequentialFilebytes - the ByteBuffer must be compatible with the SequentialFile implementation (AIO or
NIO). To be safe, use a buffer from the corresponding
SequentialFileFactory.newBuffer(int).Exceptionpublic void blockingWriteDirect(ByteBuffer bytes, boolean sync, boolean releaseBuffer) throws Exception
SequentialFilereleaseBuffer is true the provided bytes should be released
through SequentialFileFactory.releaseBuffer(ByteBuffer), if supported.bytes - the ByteBuffer must be compatible with the SequentialFile implementation (AIO or
NIO). If releaseBuffer is true use a buffer from
SequentialFileFactory.newBuffer(int), SequentialFileFactory.allocateDirectBuffer(int)
otherwise.sync - if true will durable flush the written data on the file, false otherwisereleaseBuffer - if true will release the buffer, false otherwiseExceptionprotected ByteBuffer newBuffer(int size, int limit)
newBuffer in class AbstractSequentialFilepublic void copyTo(SequentialFile dstFile) throws IOException
copyTo in interface SequentialFilecopyTo in class AbstractSequentialFileIOExceptionCopyright © 2019 The Apache Software Foundation. All Rights Reserved.