Class FifoFile


  • public class FifoFile
    extends Object
    A FifoFile allows code to read and write to an on-disk managed FIFO. Objects of this class provide InputStream and OutputStream implementations that may be used by any number of concurrent threads. If using this class to access a single file from multiple instances of FifoFile, whether in a single JVM or different JVMs, due to limitations of the underlying RandomAccessFile, only one instance may read and one instance may write. However, race conditions still exists in this scenario, and it is strongly advised to access a file through a single instance of FifoFile.

    This class is best used for persistence or management of large FIFO data sets.

    Author:
    AO Industries, Inc.
    • Method Detail

      • getMaximumFifoLength

        public long getMaximumFifoLength()
      • getFileLength

        public long getFileLength()
      • getBlockSize

        public int getBlockSize()
      • reset

        public void reset()
                   throws IOException
        Resets this FifoFile to contain no contents and start writing at the beginning of the file.
        Throws:
        IOException
      • getFirstIndex

        protected long getFirstIndex()
                              throws IOException
        Gets the data index of the next value that will be read.
        Throws:
        IOException
      • setFirstIndex

        protected void setFirstIndex​(long index)
                              throws IOException
        Sets the data index of the next value that will be read.
        Throws:
        IOException
      • getLength

        public long getLength()
                       throws IOException
        Gets the number of bytes currently contained by the FIFO.
        Throws:
        IOException
      • setLength

        protected void setLength​(long length)
                          throws IOException
        Sets the number of bytes currently contained by the FIFO.
        Throws:
        IOException