Package org.apache.storm.daemon.nimbus

## Class HeartbeatCache

- java.lang.Object
- - org.apache.storm.daemon.nimbus.HeartbeatCache

-     public class HeartbeatCache
      extends Object

  Holds a cache of heartbeats from the workers.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `HeartbeatCache()` | Create an empty cache.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addEmptyTopoForTests​(String topoId)` | Add an empty topology to the cache for testing purposes.
    `Set<List<Integer>>` | `getAliveExecutors​(String topoId, Set<List<Integer>> allExecutors, Assignment assignment, int taskLaunchSecs)` | Get all of the alive executors for a given topology.
    `int` | `getNumToposCached()` | Get the number of topologies with cached heartbeats.
    `Set<String>` | `getTopologyIds()` | Get the topology ids with cached heartbeats.
    `void` | `removeTopo​(String topoId)` | Remove a specific topology from the cache.
    `void` | `timeoutOldHeartbeats​(String topoId, Integer taskTimeoutSecs)` | Go through all executors and time them out if needed.
    `void` | `updateFromZkHeartbeat​(String topoId, Map<List<Integer>,​Map<String,​Object>> executorBeats, Set<List<Integer>> allExecutors, Integer timeout)` | Update the cache with heartbeats from a worker through zookeeper.
    `void` | `updateHeartbeat​(SupervisorWorkerHeartbeat workerHeartbeat, Integer taskTimeoutSecs)` | Update the heartbeats for a given worker.

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### HeartbeatCache

          public HeartbeatCache()

      Create an empty cache.

  - ### Method Detail

    - #### addEmptyTopoForTests

          public void addEmptyTopoForTests​(String topoId)

      Add an empty topology to the cache for testing purposes.
      Parameters:
        `topoId` - the id of the topology to add.

    - #### getNumToposCached

          public int getNumToposCached()

      Get the number of topologies with cached heartbeats.
      Returns:
        the number of topologies with cached heartbeats.

    - #### getTopologyIds

          public Set<String> getTopologyIds()

      Get the topology ids with cached heartbeats.
      Returns:
        the set of topology ids with cached heartbeats.

    - #### removeTopo

          public void removeTopo​(String topoId)

      Remove a specific topology from the cache.
      Parameters:
        `topoId` - the id of the topology to remove.

    - #### timeoutOldHeartbeats

          public void timeoutOldHeartbeats​(String topoId,
                                           Integer taskTimeoutSecs)

      Go through all executors and time them out if needed.
      Parameters:
        `topoId` - the id of the topology to look at.
        `taskTimeoutSecs` - the timeout to know if they are too old.

    - #### updateFromZkHeartbeat

          public void updateFromZkHeartbeat​(String topoId,
                                            Map<List<Integer>,​Map<String,​Object>> executorBeats,
                                            Set<List<Integer>> allExecutors,
                                            Integer timeout)

      Update the cache with heartbeats from a worker through zookeeper.
      Parameters:
        `topoId` - the id to the topology.
        `executorBeats` - the HB data.
        `allExecutors` - the executors.
        `timeout` - the timeout.

    - #### updateHeartbeat

          public void updateHeartbeat​(SupervisorWorkerHeartbeat workerHeartbeat,
                                      Integer taskTimeoutSecs)

      Update the heartbeats for a given worker.
      Parameters:
        `workerHeartbeat` - the heartbeats from the worker.
        `taskTimeoutSecs` - the timeout we should be looking at.

    - #### getAliveExecutors

          public Set<List<Integer>> getAliveExecutors​(String topoId,
                                                      Set<List<Integer>> allExecutors,
                                                      Assignment assignment,
                                                      int taskLaunchSecs)

      Get all of the alive executors for a given topology.
      Parameters:
        `topoId` - the id of the topology we are looking for.
        `allExecutors` - all of the executors for this topology.
        `assignment` - the current topology assignment.
        `taskLaunchSecs` - timeout for right after a worker is launched.
      Returns:
        the set of tasks that are alive.