Properly use cancellable threads to stop UnicastZenPing (#42844)

Fixes a backport issue with #42884 where Zen1 was not properly taken into account.
This commit is contained in:
Yannick Welsch 2019-06-14 13:31:10 +02:00
parent 221d23de9f
commit be9f27bb16
1 changed files with 4 additions and 1 deletions

View File

@ -99,6 +99,8 @@ public class UnicastZenPing implements ZenPing {
private final AtomicInteger pingingRoundIdGenerator = new AtomicInteger();
private final CancellableThreads cancellableThreads = new CancellableThreads();
private final Map<Integer, PingingRound> activePingingRounds = newConcurrentMap();
// a list of temporal responses a node will return for a request (holds responses from other nodes)
@ -145,12 +147,13 @@ public class UnicastZenPing implements ZenPing {
}
private SeedHostsProvider.HostsResolver createHostsResolver() {
return hosts -> SeedHostsResolver.resolveHostsLists(new CancellableThreads(), unicastZenPingExecutorService, logger, hosts,
return hosts -> SeedHostsResolver.resolveHostsLists(cancellableThreads, unicastZenPingExecutorService, logger, hosts,
transportService, resolveTimeout);
}
@Override
public void close() {
cancellableThreads.cancel("stopping UnicastZenPing");
ThreadPool.terminate(unicastZenPingExecutorService, 10, TimeUnit.SECONDS);
Releasables.close(activePingingRounds.values());
closed = true;