Class MappedPageSource

  • All Implemented Interfaces:
    PageSource

    public class MappedPageSource
    extends java.lang.Object
    implements PageSource
    • Field Detail

      • LOGGER

        private static final org.slf4j.Logger LOGGER
      • ASYNC_FLUSH_EXECUTOR

        private static final Retryer ASYNC_FLUSH_EXECUTOR
      • file

        private final java.io.File file
      • raf

        private final java.io.RandomAccessFile raf
      • pages

        private final java.util.IdentityHashMap<MappedPage,​java.lang.Long> pages
    • Constructor Detail

      • MappedPageSource

        public MappedPageSource​(java.io.File file)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • MappedPageSource

        public MappedPageSource​(java.io.File file,
                                long size)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • MappedPageSource

        public MappedPageSource​(java.io.File file,
                                boolean truncate)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • MappedPageSource

        public MappedPageSource​(java.io.File file,
                                boolean truncate,
                                long size)
                         throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • allocateRegion

        public java.lang.Long allocateRegion​(long size)
      • freeRegion

        public void freeRegion​(long address)
      • claimRegion

        public long claimRegion​(long address,
                                long size)
      • getReadableChannel

        public java.nio.channels.FileChannel getReadableChannel()
      • getWritableChannel

        public java.nio.channels.FileChannel getWritableChannel()
      • getFile

        public java.io.File getFile()
      • allocate

        public MappedPage allocate​(int size,
                                   boolean thief,
                                   boolean victim,
                                   OffHeapStorageArea owner)
        Description copied from interface: PageSource
        Attempt to allocate a page of the given size.

        Allocations identified as thieves will if necessary 'steal' space from previous allocations identified as 'victims' in order to fulfill the allocation request. owner is the area from which the returned page can subsequently be stolen or recovered. This is most likely to be the calling instance.

        Specified by:
        allocate in interface PageSource
        Parameters:
        size - size of page to allocate
        thief - true if the allocation can steal space from victims
        victim - true if the allocated page should be eligible for stealing
        owner - owner from which subsequent steal should occur
        Returns:
        an allocated page, or null in the case of failure
      • claimPage

        public MappedPage claimPage​(long address,
                                    long size)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • getAddress

        public long getAddress​(Page underlying)
      • flush

        public void flush()
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Throws:
        java.io.IOException