org.apache.storm.scheduler.multitenant

## Class NodePool

- java.lang.Object
- - org.apache.storm.scheduler.multitenant.NodePool

- Direct Known Subclasses:
    DefaultPool, FreePool, IsolatedPool

      public abstract class NodePool
      extends Object

  A pool of nodes that can be used to run topologies.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `NodePool.NodeAndSlotCounts`
    `static class` | `NodePool.RoundRobinSlotScheduler` Place executors into slots in a round robin way, taking into account component spreading among different hosts.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Cluster` | `cluster`
    `protected Map<String,Node>` | `nodeIdToNode`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `NodePool()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | `addTopology(TopologyDetails td)` Add a topology to the pool.
    `abstract boolean` | `canAdd(TopologyDetails td)` Check if this topology can be added to this pool.
    `abstract NodePool.NodeAndSlotCounts` | `getNodeAndSlotCountIfSlotsWereTaken(int slots)` Get the number of nodes and slots this would provide to get the slots needed.
    `static int` | `getNodeCountIfSlotsWereTaken(int slots, NodePool[] pools)`
    `void` | `init(Cluster cluster, Map<String,Node> nodeIdToNode)` Initialize the pool.
    `abstract int` | `nodesAvailable()` Get the number of available nodes.
    `static int` | `nodesAvailable(NodePool[] pools)`
    `abstract void` | `scheduleAsNeeded(NodePool... lesserPools)` Reschedule any topologies as needed.
    `abstract int` | `slotsAvailable()` Get number of available slots.
    `static int` | `slotsAvailable(NodePool[] pools)`
    `abstract Collection<Node>` | `takeNodes(int nodesNeeded)` Take up to nodesNeeded from this pool.
    `static Collection<Node>` | `takeNodes(int nodesNeeded, NodePool[] pools)`
    `static Collection<Node>` | `takeNodesBySlot(int slotsNeeded, NodePool[] pools)`
    `abstract Collection<Node>` | `takeNodesBySlots(int slotsNeeded)` Take nodes from this pool that can fulfill possibly up to the slotsNeeded.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### cluster

          protected Cluster cluster

    - #### nodeIdToNode

          protected Map<String,Node> nodeIdToNode

  - ### 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

    - #### takeNodesBySlot

          public static Collection<Node> takeNodesBySlot(int slotsNeeded,
                                                         NodePool[] pools)

    - #### takeNodes

          public static Collection<Node> takeNodes(int nodesNeeded,
                                                   NodePool[] pools)

    - #### 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.

Copyright © 2021 The Apache Software Foundation. All rights reserved.