org.terracotta.offheapstore.disk.paging
Class MappedPageSource

java.lang.Object
  extended by org.terracotta.offheapstore.disk.paging.MappedPageSource
All Implemented Interfaces:
PageSource

public class MappedPageSource
extends Object
implements PageSource

Author:
Chris Dennis

Constructor Summary
MappedPageSource(File file)
           
MappedPageSource(File file, boolean truncate)
           
MappedPageSource(File file, boolean truncate, long size)
           
MappedPageSource(File file, long size)
           
 
Method Summary
 MappedPage allocate(int size, boolean thief, boolean victim, OffHeapStorageArea owner)
          Attempt to allocate a page of the given size.
 Long allocateRegion(long size)
           
 MappedPage claimPage(long address, long size)
           
 long claimRegion(long address, long size)
           
 void close()
           
 void flush()
           
 void free(Page page)
           
 void freeRegion(long address)
           
 long getAddress(Page underlying)
           
 File getFile()
           
 FileChannel getReadableChannel()
           
 FileChannel getWritableChannel()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MappedPageSource

public MappedPageSource(File file)
                 throws IOException
Throws:
IOException

MappedPageSource

public MappedPageSource(File file,
                        long size)
                 throws IOException
Throws:
IOException

MappedPageSource

public MappedPageSource(File file,
                        boolean truncate)
                 throws IOException
Throws:
IOException

MappedPageSource

public MappedPageSource(File file,
                        boolean truncate,
                        long size)
                 throws IOException
Throws:
IOException
Method Detail

allocateRegion

public Long allocateRegion(long size)

freeRegion

public void freeRegion(long address)

claimRegion

public long claimRegion(long address,
                        long size)
                 throws IOException
Throws:
IOException

getReadableChannel

public FileChannel getReadableChannel()

getWritableChannel

public FileChannel getWritableChannel()

getFile

public 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

free

public void free(Page page)
Specified by:
free in interface PageSource

claimPage

public MappedPage claimPage(long address,
                            long size)
                     throws IOException
Throws:
IOException

getAddress

public long getAddress(Page underlying)

flush

public void flush()
           throws IOException
Throws:
IOException

close

public void close()
           throws IOException
Throws:
IOException


Copyright © 2016. All Rights Reserved.