Package org.apache.storm.daemon.nimbus
Class HeartbeatCache
java.lang.Object
org.apache.storm.daemon.nimbus.HeartbeatCache
Holds a cache of heartbeats from the workers.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addEmptyTopoForTests
(String topoId) Add an empty topology to the cache for testing purposes.getAliveExecutors
(String topoId, Set<List<Integer>> allExecutors, Assignment assignment, int taskLaunchSecs) Get all of the alive executors for a given topology.int
Get the number of topologies with cached heartbeats.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.
-
Constructor Details
-
HeartbeatCache
public HeartbeatCache()Create an empty cache.
-
-
Method Details
-
addEmptyTopoForTests
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
Get the topology ids with cached heartbeats.- Returns:
- the set of topology ids with cached heartbeats.
-
removeTopo
Remove a specific topology from the cache.- Parameters:
topoId
- the id of the topology to remove.
-
timeoutOldHeartbeats
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
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.
-