codings-dan commented on a change in pull request #605:
URL: https://github.com/apache/ratis/pull/605#discussion_r813778112



##########
File path: 
ratis-examples/src/main/java/org/apache/ratis/examples/debug/server/Server.java
##########
@@ -0,0 +1,81 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ratis.examples.debug.server;
+
+import org.apache.ratis.conf.RaftProperties;
+import org.apache.ratis.examples.common.StateMachine;
+import org.apache.ratis.examples.common.Common;
+import org.apache.ratis.grpc.GrpcConfigKeys;
+import org.apache.ratis.protocol.RaftPeer;
+import org.apache.ratis.server.RaftServer;
+import org.apache.ratis.server.RaftServerConfigKeys;
+import org.apache.ratis.util.NetUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collections;
+
+/**
+ * Simplest Ratis server, use a simple state machine {@link StateMachine}
+ * which maintain a counter across multi server.
+ *
+ * Run this application three times with three different parameter set-up a
+ * ratis cluster which maintain a counter value replicated in each server 
memory
+ */
+public final class Server {
+
+  private Server(){
+  }
+
+  public static void main(String[] args) throws IOException {
+    if (args.length < 1) {
+      System.err.println("Ratis sever address should be provided in the style 
<ip:port>");
+      System.exit(1);
+    }
+
+    //find current peer object based on application parameter
+    RaftPeer currentPeer =
+        Common.PEERS.stream()
+            .filter(raftPeer -> raftPeer.getAddress().equals(args[0]))
+            .findFirst().get();
+
+    //create a property object
+    RaftProperties properties = new RaftProperties();
+
+    //set the storage directory (different for each peer) in RaftProperty 
object
+    File raftStorageDir = new File("./" + currentPeer.getId().toString());

Review comment:
       I suggest adding a `raft.server.root.storage.path` configuration item to 
the `conf.properties` file, and the default path can be 
`./ratis-examples/target`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to