ratis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From szets...@apache.org
Subject [incubator-ratis] branch master updated: RATIS-397. Remove the deprecated getMaxTimeout() method from MiniRaftCluster. Contributed by Ritesh
Date Sat, 02 Feb 2019 22:43:02 GMT
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 dbe103e  RATIS-397. Remove the deprecated getMaxTimeout() method from MiniRaftCluster.
 Contributed by Ritesh
dbe103e is described below

commit dbe103eecc5cae0778917e29f77d543cf8888496
Author: Tsz Wo Nicholas Sze <szetszwo@apache.org>
AuthorDate: Sat Feb 2 14:42:17 2019 -0800

    RATIS-397. Remove the deprecated getMaxTimeout() method from MiniRaftCluster.  Contributed
by Ritesh
---
 .../test/java/org/apache/ratis/grpc/MiniRaftClusterWithGrpc.java  | 2 +-
 .../org/apache/ratis/hadooprpc/MiniRaftClusterWithHadoopRpc.java  | 2 +-
 .../java/org/apache/ratis/netty/MiniRaftClusterWithNetty.java     | 2 +-
 ratis-server/src/test/java/org/apache/ratis/MiniRaftCluster.java  | 6 ------
 ratis-server/src/test/java/org/apache/ratis/RaftBasicTests.java   | 8 ++++----
 ratis-server/src/test/java/org/apache/ratis/RaftTestUtil.java     | 4 ++--
 .../ratis/server/simulation/MiniRaftClusterWithSimulatedRpc.java  | 3 ++-
 .../test/java/org/apache/ratis/statemachine/TestStateMachine.java | 3 ++-
 8 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/ratis-grpc/src/test/java/org/apache/ratis/grpc/MiniRaftClusterWithGrpc.java b/ratis-grpc/src/test/java/org/apache/ratis/grpc/MiniRaftClusterWithGrpc.java
index 92401ba..0174860 100644
--- a/ratis-grpc/src/test/java/org/apache/ratis/grpc/MiniRaftClusterWithGrpc.java
+++ b/ratis-grpc/src/test/java/org/apache/ratis/grpc/MiniRaftClusterWithGrpc.java
@@ -67,6 +67,6 @@ public class MiniRaftClusterWithGrpc extends MiniRaftCluster.RpcBase {
   protected void blockQueueAndSetDelay(String leaderId, int delayMs)
       throws InterruptedException {
     RaftTestUtil.blockQueueAndSetDelay(getServers(), sendServerRequestInjection,
-        leaderId, delayMs, getMaxTimeout());
+        leaderId, delayMs, getTimeoutMax());
   }
 }
diff --git a/ratis-hadoop/src/test/java/org/apache/ratis/hadooprpc/MiniRaftClusterWithHadoopRpc.java
b/ratis-hadoop/src/test/java/org/apache/ratis/hadooprpc/MiniRaftClusterWithHadoopRpc.java
index 85c1092..65cf97a 100644
--- a/ratis-hadoop/src/test/java/org/apache/ratis/hadooprpc/MiniRaftClusterWithHadoopRpc.java
+++ b/ratis-hadoop/src/test/java/org/apache/ratis/hadooprpc/MiniRaftClusterWithHadoopRpc.java
@@ -94,7 +94,7 @@ public class MiniRaftClusterWithHadoopRpc extends MiniRaftCluster.RpcBase
{
   public void blockQueueAndSetDelay(String leaderId, int delayMs)
       throws InterruptedException {
     RaftTestUtil.blockQueueAndSetDelay(getServers(), sendServerRequest,
-        leaderId, delayMs, getMaxTimeout());
+        leaderId, delayMs, getTimeoutMax());
   }
 
   @Override
diff --git a/ratis-netty/src/test/java/org/apache/ratis/netty/MiniRaftClusterWithNetty.java
b/ratis-netty/src/test/java/org/apache/ratis/netty/MiniRaftClusterWithNetty.java
index 6f30964..e7597d6 100644
--- a/ratis-netty/src/test/java/org/apache/ratis/netty/MiniRaftClusterWithNetty.java
+++ b/ratis-netty/src/test/java/org/apache/ratis/netty/MiniRaftClusterWithNetty.java
@@ -66,6 +66,6 @@ public class MiniRaftClusterWithNetty extends MiniRaftCluster.RpcBase {
   protected void blockQueueAndSetDelay(String leaderId, int delayMs)
       throws InterruptedException {
     RaftTestUtil.blockQueueAndSetDelay(getServers(), sendServerRequest,
-        leaderId, delayMs, getMaxTimeout());
+        leaderId, delayMs, getTimeoutMax());
   }
 }
diff --git a/ratis-server/src/test/java/org/apache/ratis/MiniRaftCluster.java b/ratis-server/src/test/java/org/apache/ratis/MiniRaftCluster.java
index 91bc51c..54f93c7 100644
--- a/ratis-server/src/test/java/org/apache/ratis/MiniRaftCluster.java
+++ b/ratis-server/src/test/java/org/apache/ratis/MiniRaftCluster.java
@@ -317,12 +317,6 @@ public abstract class MiniRaftCluster implements Closeable {
     start();
   }
 
-  /** @deprecated use {@link #getTimeoutMax()}. */
-  @Deprecated
-  public int getMaxTimeout() {
-    return RaftServerConfigKeys.Rpc.timeoutMax(properties).toIntExact(TimeUnit.MILLISECONDS);
-  }
-
   public TimeDuration getTimeoutMax() {
     return RaftServerConfigKeys.Rpc.timeoutMax(properties);
   }
diff --git a/ratis-server/src/test/java/org/apache/ratis/RaftBasicTests.java b/ratis-server/src/test/java/org/apache/ratis/RaftBasicTests.java
index b4efcc6..3478d9f 100644
--- a/ratis-server/src/test/java/org/apache/ratis/RaftBasicTests.java
+++ b/ratis-server/src/test/java/org/apache/ratis/RaftBasicTests.java
@@ -181,7 +181,7 @@ public abstract class RaftBasicTests<CLUSTER extends MiniRaftCluster>
     SimpleMessage[] messages = SimpleMessage.create(1);
     RaftTestUtil.sendMessageInNewThread(cluster, leaderId, messages);
 
-    Thread.sleep(cluster.getMaxTimeout() + 100);
+    Thread.sleep(cluster.getTimeoutMax().toLong(TimeUnit.MILLISECONDS) + 100);
     RaftLog followerLog = followerToSendLog.getState().getLog();
     Assert.assertTrue(RaftTestUtil.logEntriesContains(followerLog, messages));
 
@@ -194,7 +194,7 @@ public abstract class RaftBasicTests<CLUSTER extends MiniRaftCluster>
       cluster.restartServer(follower.getId(), false );
     }
 
-    Thread.sleep(cluster.getMaxTimeout() * 5);
+    Thread.sleep(cluster.getTimeoutMax().toLong(TimeUnit.MILLISECONDS) * 5);
     // confirm the server with log is elected as new leader.
     final RaftPeerId newLeaderId = waitForLeader(cluster).getId();
     Assert.assertEquals(followerToSendLog.getId(), newLeaderId);
@@ -221,7 +221,7 @@ public abstract class RaftBasicTests<CLUSTER extends MiniRaftCluster>
     SimpleMessage[] messages = SimpleMessage.create(1);
     RaftTestUtil.sendMessageInNewThread(cluster, leaderId, messages);
 
-    Thread.sleep(cluster.getMaxTimeout() + 100);
+    Thread.sleep(cluster.getTimeoutMax().toLong(TimeUnit.MILLISECONDS) + 100);
     RaftTestUtil.logEntriesContains(followerToCommit.getState().getLog(), messages);
 
     cluster.killServer(leaderId);
@@ -232,7 +232,7 @@ public abstract class RaftBasicTests<CLUSTER extends MiniRaftCluster>
       cluster.restartServer(follower.getId(), false );
     }
     waitForLeader(cluster);
-    Thread.sleep(cluster.getMaxTimeout() + 100);
+    Thread.sleep(cluster.getTimeoutMax().toLong(TimeUnit.MILLISECONDS) + 100);
 
     final Predicate<LogEntryProto> predicate = l -> l.getTerm() != 1;
     cluster.getServerAliveStream()
diff --git a/ratis-server/src/test/java/org/apache/ratis/RaftTestUtil.java b/ratis-server/src/test/java/org/apache/ratis/RaftTestUtil.java
index fe8dd37..96fc578 100644
--- a/ratis-server/src/test/java/org/apache/ratis/RaftTestUtil.java
+++ b/ratis-server/src/test/java/org/apache/ratis/RaftTestUtil.java
@@ -363,7 +363,7 @@ public interface RaftTestUtil {
   static <SERVER extends RaftServer> void blockQueueAndSetDelay(
       Collection<SERVER> servers,
       DelayLocalExecutionInjection injection, String leaderId, int delayMs,
-      long maxTimeout) throws InterruptedException {
+      TimeDuration maxTimeout) throws InterruptedException {
     // block reqeusts sent to leader if delayMs > 0
     final boolean block = delayMs > 0;
     LOG.debug("{} requests sent to leader {} and set {}ms delay for the others",
@@ -384,7 +384,7 @@ public interface RaftTestUtil {
           }
         });
 
-    Thread.sleep(3 * maxTimeout);
+    Thread.sleep(3 * maxTimeout.toLong(TimeUnit.MILLISECONDS));
   }
 
   static void sendMessageInNewThread(MiniRaftCluster cluster, RaftPeerId leaderId, SimpleMessage...
messages) {
diff --git a/ratis-server/src/test/java/org/apache/ratis/server/simulation/MiniRaftClusterWithSimulatedRpc.java
b/ratis-server/src/test/java/org/apache/ratis/server/simulation/MiniRaftClusterWithSimulatedRpc.java
index 2de422b..0403456 100644
--- a/ratis-server/src/test/java/org/apache/ratis/server/simulation/MiniRaftClusterWithSimulatedRpc.java
+++ b/ratis-server/src/test/java/org/apache/ratis/server/simulation/MiniRaftClusterWithSimulatedRpc.java
@@ -17,6 +17,7 @@
  */
 package org.apache.ratis.server.simulation;
 
+import java.util.concurrent.TimeUnit;
 import org.apache.ratis.MiniRaftCluster;
 import org.apache.ratis.RaftConfigKeys;
 import org.apache.ratis.conf.ConfUtils;
@@ -109,7 +110,7 @@ public class MiniRaftClusterWithSimulatedRpc extends MiniRaftCluster {
         .map(s -> serverRequestReply.getQueue(s.getId().toString()))
         .forEach(q -> q.delayTakeRequestTo.set(delayMs));
 
-    final long sleepMs = 3 * getMaxTimeout() / 2;
+    final long sleepMs = 3 * getTimeoutMax().toLong(TimeUnit.MILLISECONDS) / 2;
     Thread.sleep(sleepMs);
   }
 
diff --git a/ratis-test/src/test/java/org/apache/ratis/statemachine/TestStateMachine.java
b/ratis-test/src/test/java/org/apache/ratis/statemachine/TestStateMachine.java
index a4dc88a..1e55da4 100644
--- a/ratis-test/src/test/java/org/apache/ratis/statemachine/TestStateMachine.java
+++ b/ratis-test/src/test/java/org/apache/ratis/statemachine/TestStateMachine.java
@@ -17,6 +17,7 @@
  */
 package org.apache.ratis.statemachine;
 
+import java.util.concurrent.TimeUnit;
 import org.apache.log4j.Level;
 import org.apache.ratis.BaseTest;
 import org.apache.ratis.MiniRaftCluster;
@@ -149,7 +150,7 @@ public class TestStateMachine extends BaseTest implements MiniRaftClusterWithSim
     }
 
     // TODO: there eshould be a better way to ensure all data is replicated and applied
-    Thread.sleep(cluster.getMaxTimeout() + 100);
+    Thread.sleep(cluster.getTimeoutMax().toLong(TimeUnit.MILLISECONDS) + 100);
 
     for (RaftServerImpl raftServer : cluster.iterateServerImpls()) {
       final SMTransactionContext sm = SMTransactionContext.get(raftServer);


Mime
View raw message