Class Allocation


  • public class Allocation
    extends java.lang.Object
    Represents a Decentralized Allocation Tree (DAT) node.

    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.

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      long getAllocationUnits()
      Gets the allocation units this allocation holds.
      java.lang.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.
      java.util.Optional<Allocation> getParent()
      Gets the parent allocation, or Optional.empty() if this is a root allocation.
      Allocation newChild​(java.lang.String description, long allocationUnits)
      Creates a new child Allocation (sub-allocation).
      static Allocation newRoot​(java.lang.String description, long allocationUnits)
      Creates a new root Allocation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • newRoot

        public static Allocation newRoot​(java.lang.String description,
                                         long allocationUnits)
        Creates a new root Allocation.
        Parameters:
        description - user-facing description of what the allocation represents
        allocationUnits - number of allocation units
        Returns:
        a new Allocation
      • newChild

        public Allocation newChild​(java.lang.String description,
                                   long allocationUnits)
        Creates a new child Allocation (sub-allocation).
        Parameters:
        description - user-facing description of what the sub-allocation represents
        allocationUnits - number of allocation units the child holds
        Returns:
        a new Allocation
      • getParent

        public java.util.Optional<Allocation> getParent()
        Gets the parent allocation, or Optional.empty() if this is a root allocation. This allocation represents 1 allocation unit of the parent allocation.
        Returns:
        the parent Allocation
      • getDescription

        public java.lang.String getDescription()
        Gets a user-facing description of what this allocation represents. For example, this can a description of the task this allocation represents.
        Returns:
        the description
      • getAllocationUnits

        public long getAllocationUnits()
        Gets the allocation units this allocation holds. If this allocation is not the root, the full number of units represents 1 allocation unit of the parent.
        Returns:
        the allocation units
      • getFractionOfRoot

        public double getFractionOfRoot()
        Gets how much of the root allocation each of the allocation units of this allocation accounts for. The entire root allocation is 1.0.
        Returns:
        the fraction of the root allocation this allocation's allocation units accounts for