backtype.storm.scheduler
Class Cluster

java.lang.Object
  extended by backtype.storm.scheduler.Cluster

public class Cluster
extends java.lang.Object


Constructor Summary
Cluster(java.util.Map<java.lang.String,SupervisorDetails> supervisors, java.util.Map<java.lang.String,SchedulerAssignmentImpl> assignments)
           
 
Method Summary
 void assign(WorkerSlot slot, java.lang.String topologyId, java.util.Collection<ExecutorDetails> executors)
          Assign the slot to the executors for this topology.
 void freeSlot(WorkerSlot slot)
          Free the specified slot.
 void freeSlots(java.util.Collection<WorkerSlot> slots)
          free the slots.
 int getAssignedNumWorkers(TopologyDetails topology)
          Gets the number of workers assigned to this topology.
 SchedulerAssignment getAssignmentById(java.lang.String topologyId)
          get the current assignment for the topology.
 java.util.Map<java.lang.String,SchedulerAssignment> getAssignments()
          Get all the assignments.
 java.util.List<java.lang.Integer> getAvailablePorts(SupervisorDetails supervisor)
          Return the available ports of this supervisor.
 java.util.List<WorkerSlot> getAvailableSlots()
          Gets all the available slots in the cluster.
 java.util.List<WorkerSlot> getAvailableSlots(SupervisorDetails supervisor)
          Return all the available slots on this supervisor.
 java.util.Map<java.lang.String,java.util.List<ExecutorDetails>> getNeedsSchedulingComponentToExecutors(TopologyDetails topology)
          Gets a component-id -> executors map which needs scheduling in this topology.
 java.util.Map<ExecutorDetails,java.lang.String> getNeedsSchedulingExecutorToComponents(TopologyDetails topology)
          Gets a executor -> component-id map which needs scheduling in this topology.
 SupervisorDetails getSupervisorById(java.lang.String nodeId)
          Get a specific supervisor with the nodeId
 java.util.Map<java.lang.String,SupervisorDetails> getSupervisors()
          Get all the supervisors.
 java.util.List<SupervisorDetails> getSupervisorsByHost(java.lang.String host)
          Get all the supervisors on the specified host.
 java.util.Collection<ExecutorDetails> getUnassignedExecutors(TopologyDetails topology)
          get the unassigned executors of the topology.
 java.util.List<java.lang.Integer> getUsedPorts(SupervisorDetails supervisor)
          Get all the used ports of this supervisor.
 boolean isSlotOccupied(WorkerSlot slot)
          Checks the specified slot is occupied.
 boolean needsScheduling(TopologyDetails topology)
          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.
 java.util.List<TopologyDetails> needsSchedulingTopologies(Topologies topologies)
          Gets all the topologies which needs scheduling.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cluster

public Cluster(java.util.Map<java.lang.String,SupervisorDetails> supervisors,
               java.util.Map<java.lang.String,SchedulerAssignmentImpl> assignments)
Method Detail

needsSchedulingTopologies

public java.util.List<TopologyDetails> needsSchedulingTopologies(Topologies topologies)
Gets all the topologies which needs scheduling.

Parameters:
topologies -
Returns:

needsScheduling

public boolean needsScheduling(TopologyDetails topology)
Does the topology need scheduling? A topology needs scheduling if one of the following conditions holds:


getNeedsSchedulingExecutorToComponents

public java.util.Map<ExecutorDetails,java.lang.String> getNeedsSchedulingExecutorToComponents(TopologyDetails topology)
Gets a executor -> component-id map which needs scheduling in this topology.

Parameters:
topology -
Returns:

getNeedsSchedulingComponentToExecutors

public java.util.Map<java.lang.String,java.util.List<ExecutorDetails>> getNeedsSchedulingComponentToExecutors(TopologyDetails topology)
Gets a component-id -> executors map which needs scheduling in this topology.

Parameters:
topology -
Returns:

getUsedPorts

public java.util.List<java.lang.Integer> getUsedPorts(SupervisorDetails supervisor)
Get all the used ports of this supervisor.

Parameters:
cluster -
Returns:

getAvailablePorts

public java.util.List<java.lang.Integer> getAvailablePorts(SupervisorDetails supervisor)
Return the available ports of this supervisor.

Parameters:
cluster -
Returns:

getAvailableSlots

public java.util.List<WorkerSlot> getAvailableSlots(SupervisorDetails supervisor)
Return all the available slots on this supervisor.

Parameters:
cluster -
Returns:

getUnassignedExecutors

public java.util.Collection<ExecutorDetails> getUnassignedExecutors(TopologyDetails topology)
get the unassigned executors of the topology.


getAssignedNumWorkers

public int getAssignedNumWorkers(TopologyDetails topology)
Gets the number of workers assigned to this topology.

Parameters:
topology -
Returns:

assign

public void assign(WorkerSlot slot,
                   java.lang.String topologyId,
                   java.util.Collection<ExecutorDetails> executors)
Assign the slot to the executors for this topology.

Throws:
java.lang.RuntimeException - if the specified slot is already occupied.

getAvailableSlots

public java.util.List<WorkerSlot> getAvailableSlots()
Gets all the available slots in the cluster.

Returns:

freeSlot

public void freeSlot(WorkerSlot slot)
Free the specified slot.

Parameters:
slot -

freeSlots

public void freeSlots(java.util.Collection<WorkerSlot> slots)
free the slots.

Parameters:
slots -

isSlotOccupied

public boolean isSlotOccupied(WorkerSlot slot)
Checks the specified slot is occupied.

Parameters:
slot - the slot be to checked.
Returns:

getAssignmentById

public SchedulerAssignment getAssignmentById(java.lang.String topologyId)
get the current assignment for the topology.


getSupervisorById

public SupervisorDetails getSupervisorById(java.lang.String nodeId)
Get a specific supervisor with the nodeId


getSupervisorsByHost

public java.util.List<SupervisorDetails> getSupervisorsByHost(java.lang.String host)
Get all the supervisors on the specified host.

Parameters:
host - hostname of the supervisor
Returns:
the SupervisorDetails object.

getAssignments

public java.util.Map<java.lang.String,SchedulerAssignment> getAssignments()
Get all the assignments.


getSupervisors

public java.util.Map<java.lang.String,SupervisorDetails> getSupervisors()
Get all the supervisors.