org.apache.storm.scheduler.resource

## 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 and 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 and Description
    --- | ---
    `void` | `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` | `compareTo(RasNode o)`
    `boolean` | `couldEverFit(ExecutorDetails exec, TopologyDetails td)` Is there any possibility that exec could ever fit on this node.
    `boolean` | `equals(Object other)`
    `void` | `free(WorkerSlot ws)` Frees a single slot in this node.
    `void` | `freeAllSlots()` Free all slots on this node.
    `void` | `freeSingleExecutor(ExecutorDetails exec, TopologyDetails topo)` frees a single executor.
    `double` | `getAvailableCpuResources()` Gets the available cpu resources for this node.
    `double` | `getAvailableMemoryResources()` Gets the available memory resources for this node.
    `Collection<WorkerSlot>` | `getFreeSlots()`
    `Collection<String>` | `getFreeSlotsId()` Get the IDs of all free slots on this node.
    `String` | `getHostname()`
    `String` | `getId()`
    `Collection<String>` | `getRunningTopologies()` Get a collection of the topology ids currently running on this node.
    `Collection<WorkerSlot>` | `getSlotsAvailableToScheduleOn()`
    `NormalizedResourceOffer` | `getTotalAvailableResources()` Gets all available resources for this node.
    `double` | `getTotalCpuResources()` Gets the total cpu resources for this node.
    `double` | `getTotalMemoryResources()` Gets the total memory resources for this node.
    `NormalizedResourceOffer` | `getTotalResources()` Gets total resources for this node.
    `Collection<WorkerSlot>` | `getUsedSlots()`
    `Collection<WorkerSlot>` | `getUsedSlots(String topId)` Get slots used by the given topology.
    `int` | `hashCode()`
    `boolean` | `isAlive()`
    `boolean` | `isTotallyFree()`
    `String` | `toString()`
    `int` | `totalSlots()`
    `int` | `totalSlotsFree()`
    `int` | `totalSlotsUsed()`
    `int` | `totalSlotsUsed(String topId)`
    `boolean` | `wouldFit(WorkerSlot ws, ExecutorDetails exec, TopologyDetails td)` Would scheduling exec in ws fit with the current resource constraints.

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### 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 free
        `topo` - 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 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.

      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 in
        `exec` - the executor to possibly place in ws
        `td` - 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 schedule
        `td` - 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

          public boolean equals(Object other)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### 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:
        `compareTo` in interface `Comparable<RasNode>`

Copyright © 2021 The Apache Software Foundation. All rights reserved.