Class MappedPageSource
- java.lang.Object
-
- org.terracotta.offheapstore.disk.paging.MappedPageSource
-
- All Implemented Interfaces:
PageSource
public class MappedPageSource extends java.lang.Object implements PageSource
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classMappedPageSource.AllocatedRegion
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.Long,MappedPageSource.AllocatedRegion>allocatedprivate PowerOfTwoFileAllocatorallocatorprivate static RetryerASYNC_FLUSH_EXECUTORprivate ReopeningInterruptibleChannel<java.nio.channels.FileChannel>channelprivate java.io.Filefileprivate static org.slf4j.LoggerLOGGERprivate java.util.IdentityHashMap<MappedPage,java.lang.Long>pagesprivate java.io.RandomAccessFileraf
-
Constructor Summary
Constructors Constructor Description MappedPageSource(java.io.File file)MappedPageSource(java.io.File file, boolean truncate)MappedPageSource(java.io.File file, boolean truncate, long size)MappedPageSource(java.io.File file, long size)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MappedPageallocate(int size, boolean thief, boolean victim, OffHeapStorageArea owner)Attempt to allocate a page of the given size.java.lang.LongallocateRegion(long size)MappedPageclaimPage(long address, long size)longclaimRegion(long address, long size)voidclose()voidflush()voidfree(Page page)voidfreeRegion(long address)longgetAddress(Page underlying)java.io.FilegetFile()java.nio.channels.FileChannelgetReadableChannel()java.nio.channels.FileChannelgetWritableChannel()
-
-
-
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
-
channel
private final ReopeningInterruptibleChannel<java.nio.channels.FileChannel> channel
-
allocator
private final PowerOfTwoFileAllocator allocator
-
pages
private final java.util.IdentityHashMap<MappedPage,java.lang.Long> pages
-
allocated
private final java.util.Map<java.lang.Long,MappedPageSource.AllocatedRegion> allocated
-
-
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:PageSourceAttempt 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.
owneris the area from which the returned page can subsequently be stolen or recovered. This is most likely to be the calling instance.- Specified by:
allocatein interfacePageSource- Parameters:
size- size of page to allocatethief-trueif the allocation can steal space from victimsvictim-trueif the allocated page should be eligible for stealingowner- owner from which subsequent steal should occur- Returns:
- an allocated page, or
nullin the case of failure
-
free
public void free(Page page)
- Specified by:
freein interfacePageSource
-
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
-
-