public abstract class NodePool extends Object
A pool of nodes that can be used to run topologies.
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.
|
Modifier and Type | Field and Description |
---|---|
protected Cluster |
_cluster |
protected Map<String,Node> |
_nodeIdToNode |
Constructor and Description |
---|
NodePool() |
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() |
static int |
nodesAvailable(NodePool[] pools) |
abstract void |
scheduleAsNeeded(NodePool... lesserPools)
Reschedule any topologies as needed.
|
abstract int |
slotsAvailable() |
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
|
protected Cluster _cluster
public void init(Cluster cluster, Map<String,Node> nodeIdToNode)
Initialize the pool.
cluster
- the clusternodeIdToNode
- the mapping of node id to nodespublic abstract void addTopology(TopologyDetails td)
Add a topology to the pool
td
- the topology to add.public abstract boolean canAdd(TopologyDetails td)
Check if this topology can be added to this pool
td
- the topologypublic abstract int slotsAvailable()
public abstract Collection<Node> takeNodesBySlots(int slotsNeeded)
Take nodes from this pool that can fulfill possibly up to the slotsNeeded
slotsNeeded
- the number of slots that are needed.public abstract NodePool.NodeAndSlotCounts getNodeAndSlotCountIfSlotsWereTaken(int slots)
Get the number of nodes and slots this would provide to get the slots needed
slots
- the number of slots neededpublic abstract int nodesAvailable()
public abstract Collection<Node> takeNodes(int nodesNeeded)
Take up to nodesNeeded from this pool
nodesNeeded
- the number of nodes that are needed.public abstract void scheduleAsNeeded(NodePool... lesserPools)
Reschedule any topologies as needed.
lesserPools
- pools that may be used to steal nodes from.public static int slotsAvailable(NodePool[] pools)
public static int nodesAvailable(NodePool[] pools)
public static Collection<Node> takeNodesBySlot(int slotsNeeded, NodePool[] pools)
public static Collection<Node> takeNodes(int nodesNeeded, NodePool[] pools)
public static int getNodeCountIfSlotsWereTaken(int slots, NodePool[] pools)
Copyright © 2019 The Apache Software Foundation. All Rights Reserved.