Class AIOSequentialFile
java.lang.Object
org.apache.activemq.artemis.core.io.AbstractSequentialFile
org.apache.activemq.artemis.core.io.aio.AIOSequentialFile
- All Implemented Interfaces:
SequentialFile
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
ConstructorsConstructorDescriptionAIOSequentialFile(AIOSequentialFileFactory factory, int bufferSize, long bufferTimeoutMilliseconds, File directory, String fileName) -
Method Summary
Modifier and TypeMethodDescriptionvoidblockingWriteDirect(ByteBuffer bytes, boolean sync, boolean releaseBuffer) Write directly to the file without using any intermediate buffer and wait completion.intcalculateBlockStart(int position) voidclose()voidclose(boolean waitSync, boolean blockOnWait) When closing a file from a finalize block, you cant wait on syncs or anything like that. otherwise the VM may hung.voidfill(int size) booleanisOpen()map(int position, long size) voidopen()voidopen(int maxIO, boolean useExecutor) The maximum number of simultaneous writes acceptedintread(ByteBuffer bytes) Read the file.intread(ByteBuffer bytes, IOCallback callback) Read the file.longsize()voidsync()toString()voidwriteDirect(ByteBuffer bytes, boolean sync) Write directly to the file without using intermediate any buffervoidwriteDirect(ByteBuffer bytes, boolean sync, IOCallback callback) Note: Parameter sync is not used on AIOMethods 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, writeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.activemq.artemis.core.io.SequentialFile
afterComplete
-
Constructor Details
-
AIOSequentialFile
public AIOSequentialFile(AIOSequentialFileFactory factory, int bufferSize, long bufferTimeoutMilliseconds, File directory, String fileName)
-
-
Method Details
-
map
- Throws:
IOException
-
isOpen
public boolean isOpen() -
calculateBlockStart
public int calculateBlockStart(int position) -
cloneFile
-
close
- Specified by:
closein interfaceSequentialFile- Overrides:
closein classAbstractSequentialFile- Throws:
IOException- we declare throwing IOException because sub-classes need to do itInterruptedExceptionActiveMQException
-
close
public void close(boolean waitSync, boolean blockOnWait) throws IOException, InterruptedException, ActiveMQException Description 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. -
fill
- Throws:
Exception
-
open
- Throws:
Exception
-
open
Description copied from interface:SequentialFileThe maximum number of simultaneous writes accepted- Throws:
ActiveMQException
-
read
Description copied from interface:SequentialFileRead the file.- 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:
ActiveMQException
-
read
Description copied from interface:SequentialFileRead the file.- 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:
Exception
-
writeDirect
Description 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:
Exception
-
blockingWriteDirect
public void blockingWriteDirect(ByteBuffer bytes, boolean sync, boolean releaseBuffer) throws Exception Description copied from interface:SequentialFileWrite directly to the file without using any intermediate buffer and wait completion.If
releaseBufferistruethe 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:
Exception
-
writeDirect
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
- Throws:
Exception
-
toString
-