Class NIOSequentialFile
java.lang.Object
org.apache.activemq.artemis.core.io.AbstractSequentialFile
org.apache.activemq.artemis.core.io.nio.NIOSequentialFile
- All Implemented Interfaces:
SequentialFile
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.activemq.artemis.core.io.AbstractSequentialFile
AbstractSequentialFile.LocalBufferObserver -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected FileChannelprotected final intprotected RandomAccessFileFields inherited from class org.apache.activemq.artemis.core.io.AbstractSequentialFile
directory, factory, file, fileSize, position, timedBuffer, timedBufferObserver -
Constructor Summary
ConstructorsConstructorDescriptionNIOSequentialFile(SequentialFileFactory factory, File directory, String file, int maxIO, Executor writerExecutor) -
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) static voidvoidclose()voidclose(boolean waitSync, boolean blockOnPending) When closing a file from a finalize block, you cant wait on syncs or anything like that.voidcopyTo(SequentialFile dstFile) protected TimedBufferObservervoidfill(int size) static AtomicIntegergetDebugCounter(Exception location) static AtomicIntegergetDebugCounter(String strLocation) booleanisOpen()map(int position, long size) voidopen()this.maxIO represents the default maxIO.voidopen(int maxIO, boolean useExecutor) The maximum number of simultaneous writes acceptedvoidposition(long pos) static voidintread(ByteBuffer bytes) Read the file.intread(ByteBuffer bytes, IOCallback callback) Read the file.longsize()voidsync()protected voidsyncChannel(FileChannel syncChannel) toString()voidwriteDirect(ByteBuffer bytes, boolean sync) Write directly to the file without using intermediate any buffervoidwriteDirect(ByteBuffer bytes, boolean sync, IOCallback callback) Write directly to the file without using any bufferMethods inherited from class org.apache.activemq.artemis.core.io.AbstractSequentialFile
delete, exists, fits, getFile, getFileName, getJavaFile, newBuffer, 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
-
Field Details
-
channel
-
rfile
-
maxIO
protected final int maxIO
-
-
Constructor Details
-
NIOSequentialFile
public NIOSequentialFile(SequentialFileFactory factory, File directory, String file, int maxIO, Executor writerExecutor)
-
-
Method Details
-
createTimedBufferObserver
- Overrides:
createTimedBufferObserverin classAbstractSequentialFile
-
calculateBlockStart
public int calculateBlockStart(int position) -
isOpen
public boolean isOpen() -
open
this.maxIO represents the default maxIO. Some operations while initializing files on the journal may require a different maxIO- Throws:
IOException
-
map
- Throws:
IOException
-
clearDebug
public static void clearDebug() -
printDebug
public static void printDebug() -
getDebugCounter
-
getDebugCounter
-
open
Description copied from interface:SequentialFileThe maximum number of simultaneous writes accepted- Throws:
IOException
-
fill
- Throws:
IOException
-
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 blockOnPending) 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. -
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
-
read
public int read(ByteBuffer bytes, IOCallback callback) throws IOException, ActiveMQIllegalStateException 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:
IOExceptionActiveMQIllegalStateException
-
sync
- Throws:
IOException
-
syncChannel
- Throws:
IOException
-
size
- Throws:
IOException
-
position
- Specified by:
positionin interfaceSequentialFile- Overrides:
positionin classAbstractSequentialFile- Throws:
IOException- only declare exception due to signature. Sub-class needs it.
-
toString
-
cloneFile
-
writeDirect
Description copied from interface:SequentialFileWrite directly to the file without using 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).
-
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
-
copyTo
- Specified by:
copyToin interfaceSequentialFile- Overrides:
copyToin classAbstractSequentialFile- Throws:
IOException
-