|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.terracotta.offheapstore.paging.UpfrontAllocatingPageSource
public class UpfrontAllocatingPageSource
An upfront allocating direct byte buffer source.
This buffer source implementation allocates all of its required storage up-front in fixed size chunks. Runtime allocations are then satisfied using slices from these initial chunks.
| Nested Class Summary | |
|---|---|
static class |
UpfrontAllocatingPageSource.ThresholdDirection
|
| Field Summary | |
|---|---|
static String |
ALLOCATION_LOG_LOCATION
|
| Constructor Summary | |
|---|---|
UpfrontAllocatingPageSource(BufferSource source,
long max,
int chunk)
Create an up-front allocating buffer source of max total bytes, in
chunk byte chunks. |
|
UpfrontAllocatingPageSource(BufferSource source,
long max,
int maxChunk,
int minChunk)
Create an up-front allocating buffer source of max total bytes, in
maximally sized chunks, within the given bounds. |
|
| Method Summary | |
|---|---|
Runnable |
addAllocationThreshold(UpfrontAllocatingPageSource.ThresholdDirection direction,
long threshold,
Runnable action)
Adds an allocation threshold action. |
Page |
allocate(int size,
boolean thief,
boolean victim,
OffHeapStorageArea owner)
Allocates a byte buffer of at least the given size. |
void |
free(Page page)
Frees the supplied buffer. |
long |
getAllocatedSize()
|
long |
getAllocatedSizeUnSync()
|
Runnable |
removeAllocationThreshold(UpfrontAllocatingPageSource.ThresholdDirection direction,
long threshold)
Removes an allocation threshold action. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String ALLOCATION_LOG_LOCATION
| Constructor Detail |
|---|
public UpfrontAllocatingPageSource(BufferSource source,
long max,
int chunk)
max total bytes, in
chunk byte chunks.
source - source from which initial buffers will be allocatedmax - total space to allocatechunk - chunk size to allocate in
public UpfrontAllocatingPageSource(BufferSource source,
long max,
int maxChunk,
int minChunk)
max total bytes, in
maximally sized chunks, within the given bounds.
source - source from which initial buffers will be allocatedmax - total space to allocatemaxChunk - the largest chunk sizeminChunk - the smallest chunk size| Method Detail |
|---|
public Page allocate(int size,
boolean thief,
boolean victim,
OffHeapStorageArea owner)
BufferSource is limited to allocating regions that are a power
of two in size. Supplied sizes are therefore rounded up to the next
largest power of two.
allocate in interface PageSourcepublic void free(Page page)
AssertionError is thrown.
free in interface PageSourcepublic long getAllocatedSize()
public long getAllocatedSizeUnSync()
public String toString()
toString in class Object
public Runnable addAllocationThreshold(UpfrontAllocatingPageSource.ThresholdDirection direction,
long threshold,
Runnable action)
There can be only a single action associated with each unique direction and threshold combination. If an action is already associated with the supplied combination then the action is replaced by the new action and the old action is returned.
Actions are fired on passing through the supplied threshold and are called synchronously with the triggering allocation. This means care must be taken to avoid mutating any map that uses this page source from within the action otherwise deadlocks may result. Exceptions thrown by the action will be caught and logged by the page source and will not be propagated on the allocating thread.
direction - new actions directionthreshold - new actions threshold levelaction - fired on breaching the threshold
null if no action was present.
public Runnable removeAllocationThreshold(UpfrontAllocatingPageSource.ThresholdDirection direction,
long threshold)
Removes the allocation threshold action for the given level and direction.
direction - registered actions directionthreshold - registered actions threshold level
null if no action was present.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||