Package org.apache.storm.scheduler
Interface ISchedulingState
- All Known Implementing Classes:
Cluster
,SingleTopologyCluster
public interface ISchedulingState
An interface that provides access to the current scheduling state.
The scheduling state is not guaranteed to be thread safe.
-
Method Summary
Modifier and TypeMethodDescriptionGet all scheduled resources for node.getAssignablePorts
(SupervisorDetails supervisor) Get the ports that are not blacklisted.Get all non-blacklisted slots in the cluster.getAssignableSlots
(SupervisorDetails supervisor) Return all non-blacklisted slots on this supervisor.int
getAssignedNumWorkers
(TopologyDetails topology) Get the number of workers assigned to a topology.getAssignedRacks
(String... topologyIds) Determine the list of racks on which topologyIds have been assigned.getAssignmentById
(String topologyId) get the current assignment for the topology.Get all the assignments.getAvailablePorts
(SupervisorDetails supervisor) Return the available ports of this supervisor.Get the resources on the supervisor that are available to be scheduled.Get all the available worker slots in the cluster.getAvailableSlots
(SupervisorDetails supervisor) Return all the available slots on this supervisor.Get all of the hosts that are blacklisted.double
Get the total amount of CPU resources in cluster.Get the total amount of generic resources (excluding CPU and memory) in cluster.double
Get the total amount of memory resources in cluster.getConf()
Get the nimbus configuration.Map a supervisor to a given host.Get host -> rack map - the inverse of networkTopography.Get the component name to executor list for executors that need to be scheduled.Get the executor to component name map for executors that need to be scheduled.Get the network topography (rackId -> nodes in the rack).getNonBlacklistedAvailableSlots
(List<String> blacklistedSupervisorIds) Get all the available worker slots in the cluster, that are not blacklisted.getNonBlacklistedClusterAvailableResources
(Collection<String> blacklistedSupervisorIds) Get the resources in the cluster that are available for scheduling.double
getScheduledCpuForNode
(String nodeId) Get the total cpu currently scheduled on a node.double
getScheduledMemoryForNode
(String nodeId) Get the total memory currently scheduled on a node.Get all topology scheduler statuses.getSupervisorById
(String nodeId) Get a specific supervisor with thenodeId
.Get all the supervisors.getSupervisorsByHost
(String host) Get all the supervisors on the specifiedhost
.Get the amount of used and free resources on a supervisor.Get all of the topologies.Get the amount of resources used by topologies.getUnassignedExecutors
(TopologyDetails topology) get the unassigned executors of the topology.getUsedPorts
(SupervisorDetails supervisor) Get all the used ports of this supervisor.Get all currently occupied slots.getUsedSlotsByTopologyId
(String topologyId) get slots used by a topology.Get the resources for a given slot.Gets the reference to the full topology->worker resource map.boolean
isBlackListed
(String supervisorId) Check is a given supervisor is on a blacklisted host.boolean
isBlacklistedHost
(String host) Check if a given host is blacklisted.boolean
isSlotOccupied
(WorkerSlot slot) Check if a slot is occupied or not.boolean
needsScheduling
(TopologyDetails topology) Does the topology need scheduling.boolean
needsSchedulingRas
(TopologyDetails topology) LikeneedsScheduling(TopologyDetails)
but does not take into account the number of workers requested.Get all of the topologies that need scheduling.boolean
wouldFit
(WorkerSlot ws, ExecutorDetails exec, TopologyDetails td, NormalizedResourceOffer resourcesAvailable, double maxHeap) Would scheduling exec on ws fit?
-
Method Details
-
getTopologies
Topologies getTopologies()Get all of the topologies.- Returns:
- all of the topologies that are a part of the cluster.
-
needsSchedulingTopologies
List<TopologyDetails> needsSchedulingTopologies()Get all of the topologies that need scheduling.- Returns:
- all of the topologies that are not fully scheduled.
-
needsScheduling
Does the topology need scheduling.A topology needs scheduling if one of the following conditions holds:
- Although the topology is assigned slots, but is squeezed. i.e. the topology is assigned less slots than desired.
- There are unassigned executors in this topology
-
needsSchedulingRas
LikeneedsScheduling(TopologyDetails)
but does not take into account the number of workers requested. This is because the number of workers is ignored in RAS- Parameters:
topology
- the topology to check- Returns:
- true if the topology needs scheduling else false.
-
getBlacklistedHosts
Get all of the hosts that are blacklisted.- Returns:
- all of the hosts that are blacklisted
-
isBlackListed
Check is a given supervisor is on a blacklisted host.- Parameters:
supervisorId
- the id of the supervisor- Returns:
- true if it is else false
-
isBlacklistedHost
Check if a given host is blacklisted.- Parameters:
host
- the name of the host- Returns:
- true if it is else false.
-
getHost
Map a supervisor to a given host.- Parameters:
supervisorId
- the id of the supervisor- Returns:
- the actual host name the supervisor is on
-
getUnassignedExecutors
get the unassigned executors of the topology.- Parameters:
topology
- the topology to check- Returns:
- the unassigned executors of the topology.
-
getNeedsSchedulingExecutorToComponents
Get the executor to component name map for executors that need to be scheduled.- Parameters:
topology
- the topology this is for- Returns:
- a executor -> component-id map which needs scheduling in this topology.
-
getNeedsSchedulingComponentToExecutors
Get the component name to executor list for executors that need to be scheduled.- Parameters:
topology
- the topology this is for- Returns:
- a component-id -> executors map which needs scheduling in this topology.
-
getUsedPorts
Get all the used ports of this supervisor. -
getAvailablePorts
Return the available ports of this supervisor. -
getAssignablePorts
Get the ports that are not blacklisted.- Parameters:
supervisor
- the supervisor- Returns:
- the ports that are not blacklisted
-
getAvailableSlots
Return all the available slots on this supervisor. -
getAvailableSlots
List<WorkerSlot> getAvailableSlots()Get all the available worker slots in the cluster. -
getNonBlacklistedAvailableSlots
Get all the available worker slots in the cluster, that are not blacklisted.- Parameters:
blacklistedSupervisorIds
- list of supervisor ids that should also be considered blacklisted.
-
getAssignableSlots
Return all non-blacklisted slots on this supervisor.- Parameters:
supervisor
- the supervisor- Returns:
- the non-blacklisted slots
-
getAssignableSlots
List<WorkerSlot> getAssignableSlots()Get all non-blacklisted slots in the cluster. -
getUsedSlots
Collection<WorkerSlot> getUsedSlots()Get all currently occupied slots. -
isSlotOccupied
Check if a slot is occupied or not.- Parameters:
slot
- the slot be to checked.- Returns:
- true if the specified slot is occupied.
-
getAssignedNumWorkers
Get the number of workers assigned to a topology.- Parameters:
topology
- the topology this is for- Returns:
- the number of workers assigned to this topology.
-
getAvailableResources
Get the resources on the supervisor that are available to be scheduled.- Parameters:
sd
- the supervisor.- Returns:
- the resources available to be scheduled.
-
wouldFit
boolean wouldFit(WorkerSlot ws, ExecutorDetails exec, TopologyDetails td, NormalizedResourceOffer resourcesAvailable, double maxHeap) Would scheduling exec on ws fit? With a heap <= maxHeap total memory added <= memoryAvailable and cpu added <= cpuAvailable.- Parameters:
ws
- the slot to put it inexec
- the executor to investigatetd
- the topology detains for this executorresourcesAvailable
- all the available resourcesmaxHeap
- the maximum heap size for ws- Returns:
- true it fits else false
-
getAssignmentById
get the current assignment for the topology. -
getUsedSlotsByTopologyId
get slots used by a topology. -
getSupervisorById
Get a specific supervisor with thenodeId
. -
getSupervisorsByHost
Get all the supervisors on the specifiedhost
.- Parameters:
host
- hostname of the supervisor- Returns:
- the
SupervisorDetails
object.
-
getAssignments
Map<String,SchedulerAssignment> getAssignments()Get all the assignments. -
getSupervisors
Map<String,SupervisorDetails> getSupervisors()Get all the supervisors. -
getAllScheduledResourcesForNode
Get all scheduled resources for node. -
getNonBlacklistedClusterAvailableResources
NormalizedResourceOffer getNonBlacklistedClusterAvailableResources(Collection<String> blacklistedSupervisorIds) Get the resources in the cluster that are available for scheduling.- Parameters:
blacklistedSupervisorIds
- other ids that are tentatively blacklisted.
-
getClusterTotalCpuResource
double getClusterTotalCpuResource()Get the total amount of CPU resources in cluster. -
getClusterTotalMemoryResource
double getClusterTotalMemoryResource()Get the total amount of memory resources in cluster. -
getClusterTotalGenericResources
Get the total amount of generic resources (excluding CPU and memory) in cluster. -
getNetworkTopography
Get the network topography (rackId -> nodes in the rack). -
getHostToRack
Get host -> rack map - the inverse of networkTopography. -
getStatusMap
Get all topology scheduler statuses. -
getTopologyResourcesMap
Map<String,TopologyResources> getTopologyResourcesMap()Get the amount of resources used by topologies. Used for displaying resource information on the UI.- Returns:
- a map that contains multiple topologies and the resources the topology requested and assigned. Key: topology id Value: an array that describes the resources the topology requested and assigned in the following format: {requestedMemOnHeap, requestedMemOffHeap, requestedCpu, assignedMemOnHeap, assignedMemOffHeap, assignedCpu}
-
getSupervisorsResourcesMap
Map<String,SupervisorResources> getSupervisorsResourcesMap()Get the amount of used and free resources on a supervisor. Used for displaying resource information on the UI- Returns:
- a map where the key is the supervisor id and the value is a map that represents resource usage for a supervisor in the following format: {totalMem, totalCpu, usedMem, usedCpu}
-
getWorkerResourcesMap
Map<String,Map<WorkerSlot, getWorkerResourcesMap()WorkerResources>> Gets the reference to the full topology->worker resource map.- Returns:
- map of topology -> map of worker slot ->resources for that worker
-
getWorkerResources
Get the resources for a given slot.- Parameters:
ws
- the slot- Returns:
- the resources currently assigned
-
getScheduledMemoryForNode
Get the total memory currently scheduled on a node.- Parameters:
nodeId
- the id of the node- Returns:
- the total memory currently scheduled on the node
-
getScheduledCpuForNode
Get the total cpu currently scheduled on a node.- Parameters:
nodeId
- the id of the node- Returns:
- the total cpu currently scheduled on the node
-
getConf
Get the nimbus configuration. -
getAssignedRacks
Determine the list of racks on which topologyIds have been assigned. Note that the returned set may containDNSToSwitchMapping.DEFAULT_RACK
ifgetHostToRack()
is null or does not contain the assigned host.- Parameters:
topologyIds
- for which assignments are examined.- Returns:
- set of racks on which assignments have been made.
-