Class RasNode

All Implemented Interfaces:

public class RasNode extends Object implements Comparable<RasNode>
Represents a single node in the cluster.
  • 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.
      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

      public String getId()
    • getHostname

      public String getHostname()
    • getFreeSlotsId

      public Collection<String> getFreeSlotsId()
      Get the IDs of all free slots on this node.
      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.
      topId - the id of the topology to get.
      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.
      exec - is the executor to free
      topo - the topology the executor is a part of
    • free

      public void free(WorkerSlot ws)
      Frees a single slot in this node.
      ws - the slot to free
    • assign

      public void assign(WorkerSlot target, TopologyDetails td, Collection<ExecutorDetails> executors)
      Assigns a worker to a node.
      target - the worker slot to assign the executors
      td - the topology the executors are from
      executors - 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.
      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.
      ws - the slot to possibly put exec in
      exec - the executor to possibly place in ws
      td - the topology exec is a part of
      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.
      exec - the executor to schedule
      td - the topology the executor is a part of
      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

      public boolean equals(Object other)
      equals in class Object
    • hashCode

      public int hashCode()
      hashCode in class Object
    • toString

      public String toString()
      toString in class Object
    • getAvailableMemoryResources

      public double getAvailableMemoryResources()
      Gets the available memory resources for this node.
      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.
      All of the available resources.
    • getTotalMemoryResources

      public double getTotalMemoryResources()
      Gets the total memory resources for this node.
      the total memory for this node
    • getAvailableCpuResources

      public double getAvailableCpuResources()
      Gets the available cpu resources for this node.
      the available cpu for this node
    • getTotalCpuResources

      public double getTotalCpuResources()
      Gets the total cpu resources for this node.
      the total cpu for this node
    • compareTo

      public int compareTo(RasNode o)
      Specified by:
      compareTo in interface Comparable<RasNode>