Class MemoryMappedFileManager

    • Field Detail

      • DEFAULT_REGION_LENGTH

        static final int DEFAULT_REGION_LENGTH
        Default length of region to map.
        See Also:
        Constant Field Values
      • immediateFlush

        private final boolean immediateFlush
      • regionLength

        private final int regionLength
      • advertiseURI

        private final java.lang.String advertiseURI
      • randomAccessFile

        private final java.io.RandomAccessFile randomAccessFile
      • isEndOfBatch

        private final java.lang.ThreadLocal<java.lang.Boolean> isEndOfBatch
      • mappedBuffer

        private java.nio.MappedByteBuffer mappedBuffer
      • mappingOffset

        private long mappingOffset
    • Constructor Detail

      • MemoryMappedFileManager

        protected MemoryMappedFileManager​(java.io.RandomAccessFile file,
                                          java.lang.String fileName,
                                          java.io.OutputStream os,
                                          boolean immediateFlush,
                                          long position,
                                          int regionLength,
                                          java.lang.String advertiseURI,
                                          Layout<? extends java.io.Serializable> layout,
                                          boolean writeHeader)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • getFileManager

        public static MemoryMappedFileManager getFileManager​(java.lang.String fileName,
                                                             boolean append,
                                                             boolean immediateFlush,
                                                             int regionLength,
                                                             java.lang.String advertiseURI,
                                                             Layout<? extends java.io.Serializable> layout)
        Returns the MemoryMappedFileManager.
        Parameters:
        fileName - The name of the file to manage.
        append - true if the file should be appended to, false if it should be overwritten.
        immediateFlush - true if the contents should be flushed to disk on every write
        regionLength - The mapped region length.
        advertiseURI - the URI to use when advertising the file
        layout - The layout.
        Returns:
        A MemoryMappedFileManager for the File.
      • isEndOfBatch

        public java.lang.Boolean isEndOfBatch()
      • setEndOfBatch

        public void setEndOfBatch​(boolean endOfBatch)
      • write

        protected void write​(byte[] bytes,
                             int offset,
                             int length,
                             boolean immediateFlush)
        Description copied from class: OutputStreamManager
        Some output streams synchronize writes while others do not. Synchronizing here insures that log events won't be intertwined.
        Overrides:
        write in class OutputStreamManager
        Parameters:
        bytes - The serialized Log event.
        offset - The offset into the byte array.
        length - The number of bytes to write.
        immediateFlush - flushes immediately after writing.
      • remap

        private void remap()
      • mmap

        public static java.nio.MappedByteBuffer mmap​(java.nio.channels.FileChannel fileChannel,
                                                     java.lang.String fileName,
                                                     long start,
                                                     int size)
                                              throws java.io.IOException
        Throws:
        java.io.IOException
      • unsafeUnmap

        private static void unsafeUnmap​(java.nio.MappedByteBuffer mbb)
                                 throws java.security.PrivilegedActionException
        Throws:
        java.security.PrivilegedActionException
      • getFileName

        public java.lang.String getFileName()
        Returns the name of the File being managed.
        Returns:
        The name of the File being managed.
      • getRegionLength

        public int getRegionLength()
        Returns the length of the memory mapped region.
        Returns:
        the length of the mapped region
      • isImmediateFlush

        public boolean isImmediateFlush()
        Returns true if the content of the buffer should be forced to the storage device on every write, false otherwise.
        Returns:
        whether each write should be force-sync'ed
      • getContentFormat

        public java.util.Map<java.lang.String,​java.lang.String> getContentFormat()
        Gets this FileManager's content format specified by:

        Key: "fileURI" Value: provided "advertiseURI" param.

        Overrides:
        getContentFormat in class AbstractManager
        Returns:
        Map of content format keys supporting FileManager