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.
  • Constructor Details

  • Method Details

    • map

      public ByteBuffer map(int position, long size) throws IOException
      Throws:
      IOException
    • isOpen

      public boolean isOpen()
    • calculateBlockStart

      public int calculateBlockStart(int position)
    • cloneFile

      public SequentialFile cloneFile()
    • close

      public void close() throws IOException, InterruptedException, org.apache.activemq.artemis.api.core.ActiveMQException
      Specified by:
      close in interface SequentialFile
      Overrides:
      close in class AbstractSequentialFile
      Throws:
      IOException - we declare throwing IOException because sub-classes need to do it
      InterruptedException
      org.apache.activemq.artemis.api.core.ActiveMQException
    • close

      public void close(boolean waitSync, boolean blockOnWait) throws IOException, InterruptedException, org.apache.activemq.artemis.api.core.ActiveMQException
      Description copied from interface: SequentialFile
      When 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:
      IOException
      InterruptedException
      org.apache.activemq.artemis.api.core.ActiveMQException
    • fill

      public void fill(int size) throws Exception
      Throws:
      Exception
    • open

      public void open() throws Exception
      Throws:
      Exception
    • open

      public void open(int maxIO, boolean useExecutor) throws org.apache.activemq.artemis.api.core.ActiveMQException
      Description copied from interface: SequentialFile
      The maximum number of simultaneous writes accepted
      Throws:
      org.apache.activemq.artemis.api.core.ActiveMQException
    • read

      public int read(ByteBuffer bytes, IOCallback callback) throws org.apache.activemq.artemis.api.core.ActiveMQException
      Description copied from interface: SequentialFile
      Read the file.
      Parameters:
      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).
      Throws:
      org.apache.activemq.artemis.api.core.ActiveMQException
    • read

      public int read(ByteBuffer bytes) throws Exception
      Description copied from interface: SequentialFile
      Read the file.
      Parameters:
      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).
      Throws:
      Exception
    • writeDirect

      public void writeDirect(ByteBuffer bytes, boolean sync) throws Exception
      Description copied from interface: SequentialFile
      Write 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 corresponding SequentialFileFactory.newBuffer(int).
      Throws:
      Exception
    • blockingWriteDirect

      public void blockingWriteDirect(ByteBuffer bytes, boolean sync, boolean releaseBuffer) throws Exception
      Description copied from interface: SequentialFile
      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.

      Parameters:
      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 otherwise
      releaseBuffer - if true will release the buffer, false otherwise
      Throws:
      Exception
    • writeDirect

      public void writeDirect(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 corresponding SequentialFileFactory.newBuffer(int).
    • sync

      public void sync()
    • size

      public long size() throws Exception
      Throws:
      Exception
    • toString

      public String toString()
      Overrides:
      toString in class Object