Class NodePool

    • Constructor Detail

      • NodePool

        public NodePool()
    • Method Detail

      • slotsAvailable

        public static int slotsAvailable​(NodePool[] pools)
      • slotsAvailable

        public abstract int slotsAvailable()
        Get number of available slots.
        Returns:
        the number of slots that are available to be taken
      • nodesAvailable

        public static int nodesAvailable​(NodePool[] pools)
      • nodesAvailable

        public abstract int nodesAvailable()
        Get the number of available nodes.
        Returns:
        the number of nodes that are available to be taken
      • getNodeCountIfSlotsWereTaken

        public static int getNodeCountIfSlotsWereTaken​(int slots,
                                                       NodePool[] pools)
      • init

        public void init​(Cluster cluster,
                         Map<String,​Node> nodeIdToNode)
        Initialize the pool.
        Parameters:
        cluster - the cluster
        nodeIdToNode - the mapping of node id to nodes
      • addTopology

        public abstract void addTopology​(TopologyDetails td)
        Add a topology to the pool.
        Parameters:
        td - the topology to add
      • canAdd

        public abstract boolean canAdd​(TopologyDetails td)
        Check if this topology can be added to this pool.
        Parameters:
        td - the topology
        Returns:
        true if it can else false
      • takeNodesBySlots

        public abstract Collection<Node> takeNodesBySlots​(int slotsNeeded)
        Take nodes from this pool that can fulfill possibly up to the slotsNeeded.
        Parameters:
        slotsNeeded - the number of slots that are needed.
        Returns:
        a Collection of nodes with the removed nodes in it. This may be empty, but should not be null.
      • getNodeAndSlotCountIfSlotsWereTaken

        public abstract NodePool.NodeAndSlotCounts getNodeAndSlotCountIfSlotsWereTaken​(int slots)
        Get the number of nodes and slots this would provide to get the slots needed.
        Parameters:
        slots - the number of slots needed
        Returns:
        the number of nodes and slots that would be returned.
      • takeNodes

        public abstract Collection<Node> takeNodes​(int nodesNeeded)
        Take up to nodesNeeded from this pool.
        Parameters:
        nodesNeeded - the number of nodes that are needed.
        Returns:
        a Collection of nodes with the removed nodes in it. This may be empty, but should not be null.
      • scheduleAsNeeded

        public abstract void scheduleAsNeeded​(NodePool... lesserPools)
        Reschedule any topologies as needed.
        Parameters:
        lesserPools - pools that may be used to steal nodes from.