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 Details

    • HeartbeatCache

      public HeartbeatCache()
      Create an empty cache.
  • Method Details

    • 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.