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
Modifier and TypeClassDescriptionstatic class
static class
Place executors into slots in a round robin way, taking into account component spreading among different hosts. -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
Add a topology to the pool.abstract boolean
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
Initialize the pool.abstract int
Get the number of available nodes.static int
nodesAvailable
(NodePool[] pools) abstract void
scheduleAsNeeded
(NodePool... lesserPools) Reschedule any topologies as needed.abstract int
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>
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.
-