Class Node
- java.lang.Object
-
- org.apache.storm.scheduler.multitenant.Node
-
public class Node extends Object
Represents a single node in the cluster.
-
-
Field Summary
Fields Modifier and Type Field Description static Comparator<Node>FREE_NODE_COMPARATOR_DECUsed to sort a list of nodes so the node with the most free slots comes first.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassign(String topId, Collection<ExecutorDetails> executors, Cluster cluster)Assign a free slot on the node to the following topology and executors.static intcountFreeSlotsAlive(Collection<Node> nodes)static intcountSlotsUsed(String topId, Collection<Node> nodes)static intcountSlotsUsed(Collection<Node> nodes)static intcountTotalSlotsAlive(Collection<Node> nodes)booleanequals(Object other)voidfree(WorkerSlot ws, Cluster cluster, boolean forceFree)Frees a single slot in this node.voidfreeAllSlots(Cluster cluster)Free all slots on this node.voidfreeTopology(String topId, Cluster cluster)Frees all the slots for a topology.static Map<String,Node>getAllNodesFrom(Cluster cluster)StringgetId()Collection<String>getRunningTopologies()Get running topologies.inthashCode()booleanisAlive()booleanisTotallyFree()StringtoString()inttotalSlots()inttotalSlotsFree()inttotalSlotsUsed()inttotalSlotsUsed(String topId)
-
-
-
Field Detail
-
FREE_NODE_COMPARATOR_DEC
public static final Comparator<Node> FREE_NODE_COMPARATOR_DEC
Used to sort a list of nodes so the node with the most free slots comes first.
-
-
Method Detail
-
countSlotsUsed
public static int countSlotsUsed(String topId, Collection<Node> nodes)
-
countSlotsUsed
public static int countSlotsUsed(Collection<Node> nodes)
-
countFreeSlotsAlive
public static int countFreeSlotsAlive(Collection<Node> nodes)
-
countTotalSlotsAlive
public static int countTotalSlotsAlive(Collection<Node> nodes)
-
getId
public String getId()
-
isAlive
public boolean isAlive()
-
getRunningTopologies
public Collection<String> getRunningTopologies()
Get running topologies.- Returns:
- a collection of the topology ids currently running on this node
-
isTotallyFree
public boolean isTotallyFree()
-
totalSlotsFree
public int totalSlotsFree()
-
totalSlotsUsed
public int totalSlotsUsed()
-
totalSlotsUsed
public int totalSlotsUsed(String topId)
-
totalSlots
public int totalSlots()
-
freeAllSlots
public void freeAllSlots(Cluster cluster)
Free all slots on this node. This will update the Cluster too.- Parameters:
cluster- the cluster to be updated
-
free
public void free(WorkerSlot ws, Cluster cluster, boolean forceFree)
Frees a single slot in this node.- Parameters:
ws- the slot to freecluster- the cluster to update
-
freeTopology
public void freeTopology(String topId, Cluster cluster)
Frees all the slots for a topology.- Parameters:
topId- the topology to free slots forcluster- the cluster to update
-
assign
public void assign(String topId, Collection<ExecutorDetails> executors, Cluster cluster)
Assign a free slot on the node to the following topology and executors. This will update the cluster too.- Parameters:
topId- the topology to assign a free slot to.executors- the executors to run in that slot.cluster- the cluster to be updated
-
-