Class NodePool
java.lang.Object
org.apache.storm.scheduler.multitenant.NodePool
- Direct Known Subclasses:
DefaultPool,FreePool,IsolatedPool
A pool of nodes that can be used to run topologies.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classPlace executors into slots in a round robin way, taking into account component spreading among different hosts. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidAdd a topology to the pool.abstract booleanCheck 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) voidInitialize the pool.abstract intGet the number of available nodes.static intnodesAvailable(NodePool[] pools) abstract voidscheduleAsNeeded(NodePool... lesserPools) Reschedule any topologies as needed.abstract intGet number of available slots.static intslotsAvailable(NodePool[] pools) abstract Collection<Node>takeNodes(int nodesNeeded) Take up to nodesNeeded from this pool.static Collection<Node>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.
-
Field Details
-
cluster
-
nodeIdToNode
-
-
Constructor Details
-
NodePool
public NodePool()
-
-
Method Details
-
slotsAvailable
-
slotsAvailable
public abstract int slotsAvailable()Get number of available slots.- Returns:
- the number of slots that are available to be taken
-
nodesAvailable
-
nodesAvailable
public abstract int nodesAvailable()Get the number of available nodes.- Returns:
- the number of nodes that are available to be taken
-
takeNodesBySlot
-
takeNodes
-
getNodeCountIfSlotsWereTaken
-
init
Initialize the pool.- Parameters:
cluster- the clusternodeIdToNode- the mapping of node id to nodes
-
addTopology
Add a topology to the pool.- Parameters:
td- the topology to add
-
canAdd
Check if this topology can be added to this pool.- Parameters:
td- the topology- Returns:
- true if it can else false
-
takeNodesBySlots
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
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
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
Reschedule any topologies as needed.- Parameters:
lesserPools- pools that may be used to steal nodes from.
-