public class HeartbeatCache extends Object
Holds a cache of heartbeats from the workers.
Constructor and Description |
---|
HeartbeatCache()
Create an empty cache.
|
Modifier and Type | Method and 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.
|
public void addEmptyTopoForTests(String topoId)
Add an empty topology to the cache for testing purposes.
topoId
- the id of the topology to add.public int getNumToposCached()
Get the number of topologies with cached heartbeats.
public Set<String> getTopologyIds()
Get the topology ids with cached heartbeats.
public void removeTopo(String topoId)
Remove a specific topology from the cache.
topoId
- the id of the topology to remove.public void timeoutOldHeartbeats(String topoId, Integer taskTimeoutSecs)
Go through all executors and time them out if needed.
topoId
- the id of the topology to look at.taskTimeoutSecs
- the timeout to know if they are too old.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.
topoId
- the id to the topology.executorBeats
- the HB data.allExecutors
- the executors.timeout
- the timeout.public void updateHeartbeat(SupervisorWorkerHeartbeat workerHeartbeat, Integer taskTimeoutSecs)
Update the heartbeats for a given worker.
workerHeartbeat
- the heartbeats from the worker.taskTimeoutSecs
- the timeout we should be looking at.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.
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.Copyright © 2020 The Apache Software Foundation. All rights reserved.