Class Node


  • public class Node
    extends Object
    Represents a single node in the cluster.
    • Field Detail

      • FREE_NODE_COMPARATOR_DEC

        public static final Comparator<Node> FREE_NODE_COMPARATOR_DEC
        Used to sort a list of nodes so the node with the most free slots comes first.
    • Constructor Detail

      • Node

        public Node​(String nodeId,
                    Set<Integer> allPorts,
                    boolean isAlive)
    • Method Detail

      • countSlotsUsed

        public static int countSlotsUsed​(Collection<Node> nodes)
      • countFreeSlotsAlive

        public static int countFreeSlotsAlive​(Collection<Node> nodes)
      • countTotalSlotsAlive

        public static int countTotalSlotsAlive​(Collection<Node> nodes)
      • getId

        public String getId()
      • isAlive

        public boolean isAlive()
      • getRunningTopologies

        public Collection<String> getRunningTopologies()
        Get running topologies.
        Returns:
        a collection of the topology ids currently running on this node
      • isTotallyFree

        public boolean isTotallyFree()
      • totalSlotsFree

        public int totalSlotsFree()
      • totalSlotsUsed

        public int totalSlotsUsed()
      • totalSlotsUsed

        public int totalSlotsUsed​(String topId)
      • totalSlots

        public int totalSlots()
      • freeAllSlots

        public void freeAllSlots​(Cluster cluster)
        Free all slots on this node. This will update the Cluster too.
        Parameters:
        cluster - the cluster to be updated
      • free

        public void free​(WorkerSlot ws,
                         Cluster cluster,
                         boolean forceFree)
        Frees a single slot in this node.
        Parameters:
        ws - the slot to free
        cluster - the cluster to update
      • freeTopology

        public void freeTopology​(String topId,
                                 Cluster cluster)
        Frees all the slots for a topology.
        Parameters:
        topId - the topology to free slots for
        cluster - the cluster to update
      • assign

        public void assign​(String topId,
                           Collection<ExecutorDetails> executors,
                           Cluster cluster)
        Assign a free slot on the node to the following topology and executors. This will update the cluster too.
        Parameters:
        topId - the topology to assign a free slot to.
        executors - the executors to run in that slot.
        cluster - the cluster to be updated
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object