public class Allocation extends Object
A DAT node is immutable and pointers only go in the direction from child to parent. Each node has a set number of allocated units, the total of which represents a single allocation unit of its parent. Each node is therefore a sub-allocation of its parent node. This allows the DAT to sub-allocate progress in a decentralized, asynchronous manner.
For example, thread 1 creates node A as the root node with 2 allocation units. A subtask is launched on thread 1 and creates node B with 3 allocation units as a child of node A. Thread 1 then also launches a subtask on thread 2 that creates node C with 5 allocation units. Once the first subtask finishes and reports its progress, that completion would entail completion of 3 allocation units of node B and 1 allocation unit of node A. The second subtask finishes and reports its progress as well, indicating completion of 5 units of node C and thus 1 unit of node A. Allocation A is then deemed complete as well in terms of overall progress.
Note that it is up to the user of the class to ensure that the number of sub-allocations does not exceed the number of allocation units.
| Modifier and Type | Method and Description |
|---|---|
long |
getAllocationUnits()
Gets the allocation units this allocation holds.
|
String |
getDescription()
Gets a user-facing description of what this allocation represents.
|
double |
getFractionOfRoot()
Gets how much of the root allocation each of the allocation units of this allocation accounts
for.
|
Optional<Allocation> |
getParent()
Gets the parent allocation, or
Optional.empty() if this is a root allocation. |
Allocation |
newChild(String description,
long allocationUnits)
Creates a new child
Allocation (sub-allocation). |
static Allocation |
newRoot(String description,
long allocationUnits)
Creates a new root
Allocation. |
public static Allocation newRoot(String description, long allocationUnits)
Allocation.description - user-facing description of what the allocation representsallocationUnits - number of allocation unitsAllocationpublic Allocation newChild(String description, long allocationUnits)
Allocation (sub-allocation).description - user-facing description of what the sub-allocation representsallocationUnits - number of allocation units the child holdsAllocationpublic Optional<Allocation> getParent()
Optional.empty() if this is a root allocation. This
allocation represents 1 allocation unit of the parent allocation.Allocationpublic String getDescription()
public long getAllocationUnits()
public double getFractionOfRoot()
1.0.Copyright © 2019. All rights reserved.