Repository: incubator-ratis
Updated Branches:
  refs/heads/master 1e8b23447 -> 8fb860315


RATIS-419. The Arithmetic example cannot be run by the scripts. Contributed by 
Tsz Wo Nicholas Sze.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ratis/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ratis/commit/8fb86031
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ratis/tree/8fb86031
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ratis/diff/8fb86031

Branch: refs/heads/master
Commit: 8fb860315fa8bc2150836ae98c0503fb28187873
Parents: 1e8b234
Author: Jitendra Pandey <[email protected]>
Authored: Thu Nov 15 10:31:03 2018 -0800
Committer: Jitendra Pandey <[email protected]>
Committed: Thu Nov 15 10:31:03 2018 -0800

----------------------------------------------------------------------
 .../org/apache/ratis/examples/arithmetic/cli/Server.java  | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/8fb86031/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/cli/Server.java
----------------------------------------------------------------------
diff --git 
a/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/cli/Server.java
 
b/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/cli/Server.java
index f5be3e1..1772073 100644
--- 
a/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/cli/Server.java
+++ 
b/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/cli/Server.java
@@ -28,13 +28,15 @@ import org.apache.ratis.protocol.RaftPeer;
 import org.apache.ratis.protocol.RaftPeerId;
 import org.apache.ratis.server.RaftServer;
 import org.apache.ratis.server.RaftServerConfigKeys;
-import org.apache.ratis.thirdparty.com.google.protobuf.ByteString;
 import org.apache.ratis.statemachine.StateMachine;
+import org.apache.ratis.thirdparty.com.google.protobuf.ByteString;
+import org.apache.ratis.util.LifeCycle;
 import org.apache.ratis.util.NetUtils;
 
 import java.io.File;
 import java.util.Collections;
 import java.util.Objects;
+import java.util.concurrent.TimeUnit;
 
 /**
  * Class to start a ratis arithmetic example server.
@@ -70,6 +72,10 @@ public class Server extends SubCommandBase {
         .setGroup(raftGroup)
         .build();
     raftServer.start();
+
+    for(; raftServer.getLifeCycleState() != LifeCycle.State.CLOSED;) {
+      TimeUnit.SECONDS.sleep(1);
+    }
   }
 
   /**
@@ -84,6 +90,4 @@ public class Server extends SubCommandBase {
     }
     throw new IllegalArgumentException("Raft peer id " + id + " is not part of 
the raft group definitions " + peers);
   }
-
-
 }

Reply via email to