Class AIOSequentialFile
- java.lang.Object
-
- org.apache.activemq.artemis.core.io.AbstractSequentialFile
-
- org.apache.activemq.artemis.core.io.aio.AIOSequentialFile
-
- All Implemented Interfaces:
SequentialFile
public class AIOSequentialFile extends AbstractSequentialFile
This class is implementing Runnable to reuse a callback to close it.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.activemq.artemis.core.io.AbstractSequentialFile
AbstractSequentialFile.LocalBufferObserver
-
-
Field Summary
-
Fields inherited from class org.apache.activemq.artemis.core.io.AbstractSequentialFile
directory, factory, file, fileSize, position, timedBuffer, timedBufferObserver
-
-
Constructor Summary
Constructors Constructor Description AIOSequentialFile(AIOSequentialFileFactory factory, int bufferSize, long bufferTimeoutMilliseconds, java.io.File directory, java.lang.String fileName, java.util.concurrent.Executor writerExecutor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidblockingWriteDirect(java.nio.ByteBuffer bytes, boolean sync, boolean releaseBuffer)Write directly to the file without using any intermediate buffer and wait completion.
IfreleaseBufferistruethe providedbytesshould be released throughSequentialFileFactory.releaseBuffer(ByteBuffer), if supported.intcalculateBlockStart(int position)SequentialFilecloneFile()voidclose()voidclose(boolean waitSync, boolean blockOnWait)When closing a file from a finalize block, you cant wait on syncs or anything like that.voidfill(int size)booleanisOpen()java.nio.ByteBuffermap(int position, long size)voidopen()voidopen(int maxIO, boolean useExecutor)The maximum number of simultaneous writes acceptedintread(java.nio.ByteBuffer bytes)intread(java.nio.ByteBuffer bytes, IOCallback callback)longsize()voidsync()java.lang.StringtoString()voidwriteDirect(java.nio.ByteBuffer bytes, boolean sync)Write directly to the file without using intermediate any buffervoidwriteDirect(java.nio.ByteBuffer bytes, boolean sync, IOCallback callback)Note: Parameter sync is not used on AIO-
Methods inherited from class org.apache.activemq.artemis.core.io.AbstractSequentialFile
copyTo, createTimedBufferObserver, delete, exists, fits, getFile, getFileName, getJavaFile, newBuffer, position, position, renameTo, setTimedBuffer, write, write, write, write
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.activemq.artemis.core.io.SequentialFile
afterComplete
-
-
-
-
Constructor Detail
-
AIOSequentialFile
public AIOSequentialFile(AIOSequentialFileFactory factory, int bufferSize, long bufferTimeoutMilliseconds, java.io.File directory, java.lang.String fileName, java.util.concurrent.Executor writerExecutor)
-
-
Method Detail
-
map
public java.nio.ByteBuffer map(int position, long size) throws java.io.IOException- Throws:
java.io.IOException
-
isOpen
public boolean isOpen()
-
calculateBlockStart
public int calculateBlockStart(int position)
-
cloneFile
public SequentialFile cloneFile()
-
close
public void close() throws java.io.IOException, java.lang.InterruptedException, org.apache.activemq.artemis.api.core.ActiveMQException- Specified by:
closein interfaceSequentialFile- Overrides:
closein classAbstractSequentialFile- Throws:
java.io.IOException- we declare throwing IOException because sub-classes need to do itjava.lang.InterruptedExceptionorg.apache.activemq.artemis.api.core.ActiveMQException
-
close
public void close(boolean waitSync, boolean blockOnWait) throws java.io.IOException, java.lang.InterruptedException, org.apache.activemq.artemis.api.core.ActiveMQExceptionDescription copied from interface:SequentialFileWhen closing a file from a finalize block, you cant wait on syncs or anything like that. otherwise the VM may hung. Especially on the testsuite.- Throws:
java.io.IOExceptionjava.lang.InterruptedExceptionorg.apache.activemq.artemis.api.core.ActiveMQException
-
fill
public void fill(int size) throws java.lang.Exception- Throws:
java.lang.Exception
-
open
public void open() throws java.lang.Exception- Throws:
java.lang.Exception
-
open
public void open(int maxIO, boolean useExecutor) throws org.apache.activemq.artemis.api.core.ActiveMQExceptionDescription copied from interface:SequentialFileThe maximum number of simultaneous writes accepted- Throws:
org.apache.activemq.artemis.api.core.ActiveMQException
-
read
public int read(java.nio.ByteBuffer bytes, IOCallback callback) throws org.apache.activemq.artemis.api.core.ActiveMQException- Parameters:
bytes- the ByteBuffer must be compatible with the SequentialFile implementation (AIO or NIO). To be safe, use a buffer from the correspondingSequentialFileFactory.newBuffer(int).- Throws:
org.apache.activemq.artemis.api.core.ActiveMQException
-
read
public int read(java.nio.ByteBuffer bytes) throws java.lang.Exception- Parameters:
bytes- the ByteBuffer must be compatible with the SequentialFile implementation (AIO or NIO). To be safe, use a buffer from the correspondingSequentialFileFactory.newBuffer(int).- Throws:
java.lang.Exception
-
writeDirect
public void writeDirect(java.nio.ByteBuffer bytes, boolean sync) throws java.lang.ExceptionDescription copied from interface:SequentialFileWrite directly to the file without using intermediate any buffer- Parameters:
bytes- the ByteBuffer must be compatible with the SequentialFile implementation (AIO or NIO). To be safe, use a buffer from the correspondingSequentialFileFactory.newBuffer(int).- Throws:
java.lang.Exception
-
blockingWriteDirect
public void blockingWriteDirect(java.nio.ByteBuffer bytes, boolean sync, boolean releaseBuffer) throws java.lang.ExceptionDescription copied from interface:SequentialFileWrite directly to the file without using any intermediate buffer and wait completion.
IfreleaseBufferistruethe providedbytesshould be released throughSequentialFileFactory.releaseBuffer(ByteBuffer), if supported.- Parameters:
bytes- the ByteBuffer must be compatible with the SequentialFile implementation (AIO or NIO). IfreleaseBufferistrueuse a buffer fromSequentialFileFactory.newBuffer(int),SequentialFileFactory.allocateDirectBuffer(int)otherwise.sync- iftruewill durable flush the written data on the file,falseotherwisereleaseBuffer- iftruewill release the buffer,falseotherwise- Throws:
java.lang.Exception
-
writeDirect
public void writeDirect(java.nio.ByteBuffer bytes, boolean sync, IOCallback callback)Note: Parameter sync is not used on AIO- Parameters:
bytes- the ByteBuffer must be compatible with the SequentialFile implementation (AIO or NIO). To be safe, use a buffer from the correspondingSequentialFileFactory.newBuffer(int).
-
sync
public void sync()
-
size
public long size() throws java.lang.Exception- Throws:
java.lang.Exception
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-