Class RasNode
java.lang.Object
org.apache.storm.scheduler.resource.RasNode
- All Implemented Interfaces:
Comparable<RasNode>
Represents a single node in the cluster.
-
Constructor Summary
ConstructorDescriptionRasNode
(String nodeId, SupervisorDetails sup, Cluster cluster, Map<String, WorkerSlot> workerIdToWorker, Map<String, Map<String, Collection<ExecutorDetails>>> assignmentMap) Create a new node. -
Method Summary
Modifier and TypeMethodDescriptionvoid
assign
(WorkerSlot target, TopologyDetails td, Collection<ExecutorDetails> executors) Assigns a worker to a node.void
assignSingleExecutor
(WorkerSlot ws, ExecutorDetails exec, TopologyDetails td) Assign a single executor to a slot, even if other things are in the slot.int
boolean
couldEverFit
(ExecutorDetails exec, TopologyDetails td) Is there any possibility that exec could ever fit on this node.boolean
void
free
(WorkerSlot ws) Frees a single slot in this node.void
Free all slots on this node.void
freeSingleExecutor
(ExecutorDetails exec, TopologyDetails topo) frees a single executor.double
Gets the available cpu resources for this node.double
Gets the available memory resources for this node.Get the IDs of all free slots on this node.getId()
Get a collection of the topology ids currently running on this node.Gets all available resources for this node.double
Gets the total cpu resources for this node.double
Gets the total memory resources for this node.Gets total resources for this node.getUsedSlots
(String topId) Get slots used by the given topology.int
hashCode()
boolean
isAlive()
boolean
toString()
int
int
int
int
totalSlotsUsed
(String topId) boolean
wouldFit
(WorkerSlot ws, ExecutorDetails exec, TopologyDetails td) Would scheduling exec in ws fit with the current resource constraints.
-
Constructor Details
-
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 Details
-
getId
-
getHostname
-
getFreeSlotsId
Get the IDs of all free slots on this node.- Returns:
- the ids of the free slots.
-
getSlotsAvailableToScheduleOn
-
getFreeSlots
-
getUsedSlots
-
getUsedSlots
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
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
-
totalSlots
public int totalSlots() -
freeAllSlots
public void freeAllSlots()Free all slots on this node. This will update the Cluster too. -
freeSingleExecutor
frees a single executor.- Parameters:
exec
- is the executor to freetopo
- the topology the executor is a part of
-
free
Frees a single slot in this node.- Parameters:
ws
- the slot to free
-
assign
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
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
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
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.
-
equals
-
hashCode
public int hashCode() -
toString
-
getAvailableMemoryResources
public double getAvailableMemoryResources()Gets the available memory resources for this node.- Returns:
- the available memory for this node
-
getTotalResources
Gets total resources for this node. -
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
- Specified by:
compareTo
in interfaceComparable<RasNode>
-