Skip to content

Commit

Permalink
Make log dispatcher stop in parallel #13588
Browse files Browse the repository at this point in the history
  • Loading branch information
liyuheng55555 authored Sep 23, 2024
1 parent 5de8dc7 commit acda1a0
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ public synchronized void start() {

public synchronized void stop() {
if (!threads.isEmpty()) {
threads.forEach(LogDispatcherThread::stop);
threads.forEach(LogDispatcherThread::setStopped);
threads.forEach(LogDispatcherThread::processStopped);
executorService.shutdownNow();
int timeout = 10;
try {
Expand Down Expand Up @@ -300,7 +301,15 @@ private void releaseReservedMemory(IndexedConsensusRequest indexedConsensusReque
}

public void stop() {
setStopped();
processStopped();
}

private void setStopped() {
stopped = true;
}

private void processStopped() {
try {
if (!runFinished.await(30, TimeUnit.SECONDS)) {
logger.info("{}: Dispatcher for {} didn't stop after 30s.", impl.getThisNode(), peer);
Expand Down

0 comments on commit acda1a0

Please sign in to comment.