Class RasNode
- java.lang.Object
-
- org.apache.storm.scheduler.resource.RasNode
-
- All Implemented Interfaces:
Comparable<RasNode>
public class RasNode extends Object implements Comparable<RasNode>
Represents a single node in the cluster.
-
-
Constructor Summary
Constructors Constructor Description RasNode(String nodeId, SupervisorDetails sup, Cluster cluster, Map<String,WorkerSlot> workerIdToWorker, Map<String,Map<String,Collection<ExecutorDetails>>> assignmentMap)Create a new node.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassign(WorkerSlot target, TopologyDetails td, Collection<ExecutorDetails> executors)Assigns a worker to a node.voidassignSingleExecutor(WorkerSlot ws, ExecutorDetails exec, TopologyDetails td)Assign a single executor to a slot, even if other things are in the slot.intcompareTo(RasNode o)booleancouldEverFit(ExecutorDetails exec, TopologyDetails td)Is there any possibility that exec could ever fit on this node.booleanequals(Object other)voidfree(WorkerSlot ws)Frees a single slot in this node.voidfreeAllSlots()Free all slots on this node.voidfreeSingleExecutor(ExecutorDetails exec, TopologyDetails topo)frees a single executor.doublegetAvailableCpuResources()Gets the available cpu resources for this node.doublegetAvailableMemoryResources()Gets the available memory resources for this node.Collection<WorkerSlot>getFreeSlots()Collection<String>getFreeSlotsId()Get the IDs of all free slots on this node.StringgetHostname()StringgetId()Collection<String>getRunningTopologies()Get a collection of the topology ids currently running on this node.Collection<WorkerSlot>getSlotsAvailableToScheduleOn()NormalizedResourceOffergetTotalAvailableResources()Gets all available resources for this node.doublegetTotalCpuResources()Gets the total cpu resources for this node.doublegetTotalMemoryResources()Gets the total memory resources for this node.NormalizedResourceOffergetTotalResources()Gets total resources for this node.Collection<WorkerSlot>getUsedSlots()Collection<WorkerSlot>getUsedSlots(String topId)Get slots used by the given topology.inthashCode()booleanisAlive()booleanisTotallyFree()StringtoString()inttotalSlots()inttotalSlotsFree()inttotalSlotsUsed()inttotalSlotsUsed(String topId)booleanwouldFit(WorkerSlot ws, ExecutorDetails exec, TopologyDetails td)Would scheduling exec in ws fit with the current resource constraints.
-
-
-
Constructor Detail
-
RasNode
public RasNode(String nodeId, SupervisorDetails sup, Cluster cluster, Map<String,WorkerSlot> workerIdToWorker, Map<String,Map<String,Collection<ExecutorDetails>>> assignmentMap)
Create a new node.- Parameters:
nodeId- the id of the node.sup- the supervisor this is for.cluster- the cluster this is a part of.workerIdToWorker- the mapping of slots already assigned to this node.assignmentMap- the mapping of executors already assigned to this node.
-
-
Method Detail
-
getId
public String getId()
-
getHostname
public String getHostname()
-
getFreeSlotsId
public Collection<String> getFreeSlotsId()
Get the IDs of all free slots on this node.- Returns:
- the ids of the free slots.
-
getSlotsAvailableToScheduleOn
public Collection<WorkerSlot> getSlotsAvailableToScheduleOn()
-
getFreeSlots
public Collection<WorkerSlot> getFreeSlots()
-
getUsedSlots
public Collection<WorkerSlot> getUsedSlots()
-
getUsedSlots
public Collection<WorkerSlot> getUsedSlots(String topId)
Get slots used by the given topology.- Parameters:
topId- the id of the topology to get.- Returns:
- the slots currently assigned to that topology on this node.
-
isAlive
public boolean isAlive()
-
getRunningTopologies
public Collection<String> getRunningTopologies()
Get 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()
Free all slots on this node. This will update the Cluster too.
-
freeSingleExecutor
public void freeSingleExecutor(ExecutorDetails exec, TopologyDetails topo)
frees a single executor.- Parameters:
exec- is the executor to freetopo- the topology the executor is a part of
-
free
public void free(WorkerSlot ws)
Frees a single slot in this node.- Parameters:
ws- the slot to free
-
assign
public void assign(WorkerSlot target, TopologyDetails td, Collection<ExecutorDetails> executors)
Assigns a worker to a node.- Parameters:
target- the worker slot to assign the executorstd- the topology the executors are fromexecutors- executors to assign to the specified worker slot
-
assignSingleExecutor
public void assignSingleExecutor(WorkerSlot ws, ExecutorDetails exec, TopologyDetails td)
Assign a single executor to a slot, even if other things are in the slot.- Parameters:
ws- the slot to assign it to.exec- the executor to assign.td- the topology for the executor.
-
wouldFit
public boolean wouldFit(WorkerSlot ws, ExecutorDetails exec, TopologyDetails td)
Would scheduling exec in ws fit with the current resource constraints.- Parameters:
ws- the slot to possibly put exec inexec- the executor to possibly place in wstd- the topology exec is a part of- Returns:
- true if it would fit else false
-
couldEverFit
public boolean couldEverFit(ExecutorDetails exec, TopologyDetails td)
Is there any possibility that exec could ever fit on this node.- Parameters:
exec- the executor to scheduletd- the topology the executor is a part of- Returns:
- true if there is the possibility it might fit, no guarantee that it will, or false if there is no way it would ever fit.
-
getAvailableMemoryResources
public double getAvailableMemoryResources()
Gets the available memory resources for this node.- Returns:
- the available memory for this node
-
getTotalResources
public NormalizedResourceOffer getTotalResources()
Gets total resources for this node.
-
getTotalAvailableResources
public NormalizedResourceOffer getTotalAvailableResources()
Gets all available resources for this node.- Returns:
- All of the available resources.
-
getTotalMemoryResources
public double getTotalMemoryResources()
Gets the total memory resources for this node.- Returns:
- the total memory for this node
-
getAvailableCpuResources
public double getAvailableCpuResources()
Gets the available cpu resources for this node.- Returns:
- the available cpu for this node
-
getTotalCpuResources
public double getTotalCpuResources()
Gets the total cpu resources for this node.- Returns:
- the total cpu for this node
-
compareTo
public int compareTo(RasNode o)
- Specified by:
compareToin interfaceComparable<RasNode>
-
-