This is an automated email from the ASF dual-hosted git repository.
szetszwo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ratis.git
The following commit(s) were added to refs/heads/master by this push:
new b49974d RATIS-707. Test failures caused by minTimeout set to zero.
Contributed by Siddharth Wagle
b49974d is described below
commit b49974df21a089dfd7b97db826fee409d384fcf3
Author: Tsz Wo Nicholas Sze <[email protected]>
AuthorDate: Tue Oct 15 17:20:34 2019 +0800
RATIS-707. Test failures caused by minTimeout set to zero. Contributed by
Siddharth Wagle
---
.../main/java/org/apache/ratis/server/impl/RaftServerImpl.java | 10 +---------
.../main/java/org/apache/ratis/server/impl/ServerState.java | 1 -
2 files changed, 1 insertion(+), 10 deletions(-)
diff --git
a/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
index 3b724c6..443f23d 100644
---
a/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
+++
b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
@@ -50,7 +50,6 @@ import java.util.concurrent.CompletionException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import java.util.function.Supplier;
@@ -97,8 +96,6 @@ public class RaftServerImpl implements RaftServerProtocol,
RaftServerAsynchronou
private AtomicReference<TermIndex> inProgressInstallSnapshotRequest;
- private final AtomicBoolean honorMinTimeoutMs = new AtomicBoolean();
-
RaftServerImpl(RaftGroup group, StateMachine stateMachine, RaftServerProxy
proxy) throws IOException {
final RaftPeerId id = proxy.getId();
LOG.info("{}: new RaftServerImpl for {} with {}", id, group, stateMachine);
@@ -151,12 +148,7 @@ public class RaftServerImpl implements RaftServerProtocol,
RaftServerAsynchronou
}
int getRandomTimeoutMs() {
- return (honorMinTimeoutMs.get() ? minTimeoutMs : 0) +
- ThreadLocalRandom.current().nextInt(maxTimeoutMs - minTimeoutMs + 1);
- }
-
- void honorMinTimeoutMs() {
- honorMinTimeoutMs.set(Boolean.TRUE);
+ return minTimeoutMs + ThreadLocalRandom.current().nextInt(maxTimeoutMs -
minTimeoutMs + 1);
}
int getSleepDeviationThresholdMs() {
diff --git
a/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerState.java
b/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerState.java
index 5f35a95..b91f029 100644
--- a/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerState.java
+++ b/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerState.java
@@ -251,7 +251,6 @@ public class ServerState implements Closeable {
lastNoLeaderTime = null;
suffix = ", leader elected after " + previous.elapsedTimeMs() + "ms";
server.getStateMachine().notifyLeaderChanged(getMemberId(),
newLeaderId);
- server.honorMinTimeoutMs();
}
LOG.info("{}: change Leader from {} to {} at term {} for {}{}",
getMemberId(), leaderId, newLeaderId, getCurrentTerm(), op, suffix);