Class SecondaryBlockAllocator
java.lang.Object
org.rostore.v2.media.block.allocator.SecondaryBlockAllocator
This class creates
BlockAllocator
that allows to control a set of blocks.
Allocation on the storage level still should happen on RootBlockAllocator
, then
the object of this class can store some subset of blocks, e.g. for container.
This allocator will keep the blocks that has been allocated with its usage, then it can for example be freed without any knowledge about the structure of objects stored within it.
E.g. for the container it is beneficial to know all the blocks that are associated with it, so that it can be considered independent from the rest.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic BlockAllocator
create
(String allocatorName, BlockAllocator rootBlockAllocator, long upperBlockNumberLimit) Creates a new secondary block allocator.static BlockAllocator
load
(String allocatorName, BlockAllocator rootBlockAllocator, long startIndex, long upperBlockNumberLimit) Loads the secondary block allocator by providing the first block of the allocator
-
Constructor Details
-
SecondaryBlockAllocator
public SecondaryBlockAllocator()
-
-
Method Details
-
create
public static BlockAllocator create(String allocatorName, BlockAllocator rootBlockAllocator, long upperBlockNumberLimit) Creates a new secondary block allocator.It will create a new entity with the usage of
RootBlockAllocator
. After it is created its reference can be stored overBlockAllocator.getStartIndex()
. This is the first block of the allocator.- Parameters:
allocatorName
- the name of the allocator, used for notification and loggingrootBlockAllocator
- the root allocatorupperBlockNumberLimit
- how many block numbers this allocator is allowed to manage- Returns:
- the entity of block allocator to allocate the blocks
-
load
public static BlockAllocator load(String allocatorName, BlockAllocator rootBlockAllocator, long startIndex, long upperBlockNumberLimit) Loads the secondary block allocator by providing the first block of the allocator- Parameters:
allocatorName
- the name of the allocator used for notification and loggingrootBlockAllocator
- the root allocatorstartIndex
- the first index of the logging (taken byBlockAllocator.getStartIndex()
upperBlockNumberLimit
- how many block numbers this allocator is allowed to manage- Returns:
- the entity of block allocator to allocate the blocks
-