Skip to content

Commit

Permalink
improve some comment
Browse files Browse the repository at this point in the history
Change-Id: Ib74c3df54ed2f7cbbe27a76d6f344173792bf654
  • Loading branch information
Linary committed Apr 13, 2021
1 parent 3b7837f commit 706c316
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ public void onError(PeerId peer, Status status) {

// NOTE: Jraft itself doesn't have this callback, it's added by us
public void onBusy(PeerId peer, Status status) {
/*
* If follower is busy then increase busy counter,
* it will lead to submit thread wait more time
*/
int count = RaftNode.this.busyCounter.incrementAndGet();
LOG.info("Increase busy counter: [{}]", count);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.io.IOException;
import java.nio.file.Paths;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.RejectedExecutionException;
Expand Down Expand Up @@ -73,6 +74,7 @@ public final class RaftSharedContext {
public static final int WAIT_RPC_TIMEOUT = 30 * 60 * 1000;
// compress block size
public static final int BLOCK_SIZE = 8192;
public static final int QUEUE_SIZE = 10;

public static final String DEFAULT_GROUP = "default";

Expand Down Expand Up @@ -362,7 +364,7 @@ private ExecutorService createBackendExecutor(int threads) {
private static ExecutorService newPool(int coreThreads, int maxThreads,
String name,
RejectedExecutionHandler handler) {
BlockingQueue<Runnable> workQueue = new SynchronousQueue<>();
BlockingQueue<Runnable> workQueue = new ArrayBlockingQueue<>(QUEUE_SIZE);
return ThreadPoolUtil.newBuilder()
.poolName(name)
.enableMetric(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ public void onConfigurationCommitted(Configuration conf) {

@Override
public void onError(final RaftException e) {
// If busy, spin and wait a moment
LOG.error("Raft error: {}", e.getMessage(), e);
}
}

0 comments on commit 706c316

Please sign in to comment.