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 Description static classNodePool.NodeAndSlotCountsstatic classNodePool.RoundRobinSlotSchedulerPlace executors into slots in a round robin way, taking into account component spreading among different hosts.
-
Constructor Summary
Constructors Constructor Description NodePool()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidaddTopology(TopologyDetails td)Add a topology to the pool.abstract booleancanAdd(TopologyDetails td)Check if this topology can be added to this pool.abstract NodePool.NodeAndSlotCountsgetNodeAndSlotCountIfSlotsWereTaken(int slots)Get the number of nodes and slots this would provide to get the slots needed.static intgetNodeCountIfSlotsWereTaken(int slots, NodePool[] pools)voidinit(Cluster cluster, Map<String,Node> nodeIdToNode)Initialize the pool.abstract intnodesAvailable()Get the number of available nodes.static intnodesAvailable(NodePool[] pools)abstract voidscheduleAsNeeded(NodePool... lesserPools)Reschedule any topologies as needed.abstract intslotsAvailable()Get number of available slots.static intslotsAvailable(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.
-
-
-
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 clusternodeIdToNode- 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.
-
-