You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ratis.apache.org by sz...@apache.org on 2019/11/22 21:16:34 UTC

[incubator-ratis] branch master updated: RATIS-730. Fix checkstyle violations in ratis-examples. Contributed by Dinesh Chitlangia

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 260dbaa  RATIS-730. Fix checkstyle violations in ratis-examples.  Contributed by Dinesh Chitlangia
260dbaa is described below

commit 260dbaad18267be3c5b32d297af1ccdb63dfd693
Author: Tsz Wo Nicholas Sze <sz...@apache.org>
AuthorDate: Fri Nov 22 13:15:16 2019 -0800

    RATIS-730. Fix checkstyle violations in ratis-examples.  Contributed by Dinesh Chitlangia
---
 .../arithmetic/ArithmeticStateMachine.java         | 12 +++++-----
 .../ratis/examples/arithmetic/cli/Arithmetic.java  |  5 ++++-
 .../ratis/examples/arithmetic/cli/Assign.java      | 24 ++++++++++----------
 .../ratis/examples/arithmetic/cli/Client.java      |  4 ++--
 .../apache/ratis/examples/arithmetic/cli/Get.java  |  3 +--
 .../ratis/examples/arithmetic/cli/Server.java      | 18 ++-------------
 .../arithmetic/expression/BinaryExpression.java    | 26 +++++++++++++---------
 .../arithmetic/expression/DoubleValue.java         |  8 +++++--
 .../examples/arithmetic/expression/Expression.java |  4 ++++
 .../examples/arithmetic/expression/NullValue.java  |  2 +-
 .../arithmetic/expression/UnaryExpression.java     | 16 ++++++++-----
 .../org/apache/ratis/examples/common/Runner.java   |  6 ++++-
 .../ratis/examples/common/SubCommandBase.java      | 23 +++++++++++++++++--
 .../apache/ratis/examples/filestore/FileInfo.java  |  6 ++---
 .../ratis/examples/filestore/FileStoreClient.java  |  3 +--
 .../ratis/examples/filestore/FileStoreCommon.java  |  1 -
 .../ratis/examples/filestore/cli/Client.java       |  4 ++--
 .../ratis/examples/filestore/cli/FileStore.java    |  5 ++++-
 .../ratis/examples/filestore/cli/LoadGen.java      |  4 ++--
 .../ratis/examples/filestore/cli/Server.java       | 18 ++-------------
 20 files changed, 103 insertions(+), 89 deletions(-)

diff --git a/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/ArithmeticStateMachine.java b/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/ArithmeticStateMachine.java
index c873aa3..b7f5925 100644
--- a/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/ArithmeticStateMachine.java
+++ b/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/ArithmeticStateMachine.java
@@ -86,7 +86,7 @@ public class ArithmeticStateMachine extends BaseStateMachine {
   public long takeSnapshot() {
     final Map<String, Double> copy;
     final TermIndex last;
-    try(final AutoCloseableLock readLock = readLock()) {
+    try(AutoCloseableLock readLock = readLock()) {
       copy = new HashMap<>(variables);
       last = getLastAppliedTermIndex();
     }
@@ -94,7 +94,7 @@ public class ArithmeticStateMachine extends BaseStateMachine {
     final File snapshotFile =  storage.getSnapshotFile(last.getTerm(), last.getIndex());
     LOG.info("Taking a snapshot to file {}", snapshotFile);
 
-    try(final ObjectOutputStream out = new ObjectOutputStream(
+    try(ObjectOutputStream out = new ObjectOutputStream(
         new BufferedOutputStream(new FileOutputStream(snapshotFile)))) {
       out.writeObject(copy);
     } catch(IOException ioe) {
@@ -121,8 +121,8 @@ public class ArithmeticStateMachine extends BaseStateMachine {
     }
 
     final TermIndex last = SimpleStateMachineStorage.getTermIndexFromSnapshotFile(snapshotFile);
-    try(final AutoCloseableLock writeLock = writeLock();
-        final ObjectInputStream in = new ObjectInputStream(
+    try(AutoCloseableLock writeLock = writeLock();
+        ObjectInputStream in = new ObjectInputStream(
             new BufferedInputStream(new FileInputStream(snapshotFile)))) {
       if (reload) {
         reset();
@@ -144,7 +144,7 @@ public class ArithmeticStateMachine extends BaseStateMachine {
   public CompletableFuture<Message> query(Message request) {
     final Expression q = Expression.Utils.bytes2Expression(request.getContent().toByteArray(), 0);
     final Double result;
-    try(final AutoCloseableLock readLock = readLock()) {
+    try(AutoCloseableLock readLock = readLock()) {
       result = q.evaluate(variables);
     }
     final Expression r = Expression.Utils.double2Expression(result);
@@ -164,7 +164,7 @@ public class ArithmeticStateMachine extends BaseStateMachine {
 
     final long index = entry.getIndex();
     final Double result;
-    try(final AutoCloseableLock writeLock = writeLock()) {
+    try(AutoCloseableLock writeLock = writeLock()) {
       result = assignment.evaluate(variables);
       updateLastAppliedTermIndex(entry.getTerm(), index);
     }
diff --git a/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/cli/Arithmetic.java b/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/cli/Arithmetic.java
index fc35348..82d3e78 100644
--- a/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/cli/Arithmetic.java
+++ b/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/cli/Arithmetic.java
@@ -26,7 +26,10 @@ import java.util.List;
 /**
  * This class enumerates all the commands enqueued by Arithmetic state machine.
  */
-public class Arithmetic {
+public final class Arithmetic {
+  private Arithmetic() {
+  }
+
   public static List<SubCommandBase> getSubCommands() {
     List<SubCommandBase> commands = new ArrayList<>();
     commands.add(new Server());
diff --git a/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/cli/Assign.java b/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/cli/Assign.java
index be45c03..14dda58 100644
--- a/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/cli/Assign.java
+++ b/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/cli/Assign.java
@@ -37,15 +37,15 @@ import java.util.regex.Pattern;
 @Parameters(commandDescription = "Assign value to a variable.")
 public class Assign extends Client {
 
-  Pattern binaryOperationPattern = Pattern.compile("([a-z1-9]*)([\\*\\-/\\+])([a-z1-9]*)");
-  Pattern unaryOperationPattern = Pattern.compile("([√~])([a-z1-9]+)");
+  private Pattern binaryOperationPattern = Pattern.compile("([a-z1-9]*)([\\*\\-/\\+])([a-z1-9]*)");
+  private Pattern unaryOperationPattern = Pattern.compile("([√~])([a-z1-9]+)");
 
   @Parameter(names = {
       "--name"}, description = "Name of the variable to set", required = true)
-  String name;
+  private String name;
 
   @Parameter(names = {"--value"}, description = "Value to set", required = true)
-  String value;
+  private String value;
 
   @Override
   protected void operation(RaftClient client) throws IOException {
@@ -56,21 +56,21 @@ public class Assign extends Client {
   }
 
   @VisibleForTesting
-  protected Expression createExpression(String value) {
-    if (value.matches("\\d*(\\.\\d*)?")) {
-      return new DoubleValue(Double.valueOf(value));
-    } else if (value.matches("[a-zA-Z]+")) {
-      return new Variable(value);
+  protected Expression createExpression(String val) {
+    if (val.matches("\\d*(\\.\\d*)?")) {
+      return new DoubleValue(Double.valueOf(val));
+    } else if (val.matches("[a-zA-Z]+")) {
+      return new Variable(val);
     }
-    Matcher binaryMatcher = binaryOperationPattern.matcher(value);
-    Matcher unaryMatcher = unaryOperationPattern.matcher(value);
+    Matcher binaryMatcher = this.binaryOperationPattern.matcher(val);
+    Matcher unaryMatcher = this.unaryOperationPattern.matcher(val);
 
     if (binaryMatcher.matches()) {
       return createBinaryExpression(binaryMatcher);
     } else if (unaryMatcher.matches()) {
       return createUnaryExpression(unaryMatcher);
     } else {
-      throw new IllegalArgumentException("Invalid expression " + value + " Try something like: 'a+b' or '2'");
+      throw new IllegalArgumentException("Invalid expression " + val + " Try something like: 'a+b' or '2'");
     }
   }
 
diff --git a/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/cli/Client.java b/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/cli/Client.java
index 5efbcb8..5c01520 100644
--- a/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/cli/Client.java
+++ b/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/cli/Client.java
@@ -39,8 +39,8 @@ public abstract class Client extends SubCommandBase {
   public void run() throws Exception {
     RaftProperties raftProperties = new RaftProperties();
 
-    final RaftGroup raftGroup = RaftGroup.valueOf(RaftGroupId.valueOf(ByteString.copyFromUtf8(raftGroupId)),
-        parsePeers(peers));
+    final RaftGroup raftGroup = RaftGroup.valueOf(RaftGroupId.valueOf(ByteString.copyFromUtf8(getRaftGroupId())),
+            getPeers());
 
     RaftClient.Builder builder =
         RaftClient.newBuilder().setProperties(raftProperties);
diff --git a/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/cli/Get.java b/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/cli/Get.java
index 4cad380..c274334 100644
--- a/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/cli/Get.java
+++ b/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/cli/Get.java
@@ -20,7 +20,6 @@ package org.apache.ratis.examples.arithmetic.cli;
 import com.beust.jcommander.Parameter;
 import com.beust.jcommander.Parameters;
 import org.apache.ratis.client.RaftClient;
-import org.apache.ratis.examples.arithmetic.AssignmentMessage;
 import org.apache.ratis.examples.arithmetic.expression.DoubleValue;
 import org.apache.ratis.examples.arithmetic.expression.Expression;
 import org.apache.ratis.examples.arithmetic.expression.Variable;
@@ -36,7 +35,7 @@ public class Get extends Client {
 
   @Parameter(names = {
       "--name"}, description = "Name of the variable to set", required = true)
-  String name;
+  private String name;
 
   @Override
   protected void operation(RaftClient client) throws IOException {
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 5089bd7..139a3a3 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
@@ -25,7 +25,6 @@ import org.apache.ratis.examples.common.SubCommandBase;
 import org.apache.ratis.grpc.GrpcConfigKeys;
 import org.apache.ratis.protocol.RaftGroup;
 import org.apache.ratis.protocol.RaftGroupId;
-import org.apache.ratis.protocol.RaftPeer;
 import org.apache.ratis.protocol.RaftPeerId;
 import org.apache.ratis.server.RaftServer;
 import org.apache.ratis.server.RaftServerConfigKeys;
@@ -36,7 +35,6 @@ import org.apache.ratis.util.NetUtils;
 
 import java.io.File;
 import java.util.Collections;
-import java.util.Objects;
 import java.util.concurrent.TimeUnit;
 
 /**
@@ -59,14 +57,14 @@ public class Server extends SubCommandBase {
     RaftPeerId peerId = RaftPeerId.valueOf(id);
     RaftProperties properties = new RaftProperties();
 
-    RaftPeer[] peers = getPeers();
     final int port = NetUtils.createSocketAddr(getPeer(peerId).getAddress()).getPort();
     GrpcConfigKeys.Server.setPort(properties, port);
     properties.setInt(GrpcConfigKeys.OutputStream.RETRY_TIMES_KEY, Integer.MAX_VALUE);
     RaftServerConfigKeys.setStorageDirs(properties, Collections.singletonList(storageDir));
     StateMachine stateMachine = new ArithmeticStateMachine();
 
-    final RaftGroup raftGroup = RaftGroup.valueOf(RaftGroupId.valueOf(ByteString.copyFromUtf8(raftGroupId)), peers);
+    final RaftGroup raftGroup = RaftGroup.valueOf(RaftGroupId.valueOf(ByteString.copyFromUtf8(getRaftGroupId())),
+            getPeers());
     RaftServer raftServer = RaftServer.newBuilder()
         .setServerId(RaftPeerId.valueOf(id))
         .setStateMachine(stateMachine).setProperties(properties)
@@ -79,16 +77,4 @@ public class Server extends SubCommandBase {
     }
   }
 
-  /**
-   * @return the peer with the given id if it is in this group; otherwise, return null.
-   */
-  public RaftPeer getPeer(RaftPeerId id) {
-    Objects.requireNonNull(id, "id == null");
-    for (RaftPeer p : getPeers()) {
-      if (id.equals(p.getId())) {
-        return p;
-      }
-    }
-    throw new IllegalArgumentException("Raft peer id " + id + " is not part of the raft group definitions " + peers);
-  }
 }
diff --git a/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/expression/BinaryExpression.java b/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/expression/BinaryExpression.java
index c8f3537..d0ba2ec 100644
--- a/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/expression/BinaryExpression.java
+++ b/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/expression/BinaryExpression.java
@@ -27,7 +27,7 @@ public class BinaryExpression implements Expression {
   public enum Op implements BinaryOperator<Expression> {
     ADD("+"), SUBTRACT("-"), MULT("*"), DIV("/");
 
-    final String symbol;
+    private final String symbol;
 
     Op(String symbol) {
       this.symbol = symbol;
@@ -38,20 +38,20 @@ public class BinaryExpression implements Expression {
     }
 
     @Override
-    public BinaryExpression apply(Expression left, Expression right) {
-      return new BinaryExpression(this, left, right);
+    public BinaryExpression apply(Expression l, Expression r) {
+      return new BinaryExpression(this, l, r);
     }
 
-    public BinaryExpression apply(double left, Expression right) {
-      return apply(new DoubleValue(left), right);
+    public BinaryExpression apply(double l, Expression r) {
+      return apply(new DoubleValue(l), r);
     }
 
-    public BinaryExpression apply(Expression left, double right) {
-      return apply(left, new DoubleValue(right));
+    public BinaryExpression apply(Expression l, double r) {
+      return apply(l, new DoubleValue(r));
     }
 
-    public BinaryExpression apply(double left, double right) {
-      return apply(new DoubleValue(left), new DoubleValue(right));
+    public BinaryExpression apply(double l, double r) {
+      return apply(new DoubleValue(l), new DoubleValue(r));
     }
 
     @Override
@@ -126,8 +126,12 @@ public class BinaryExpression implements Expression {
 
   @Override
   public boolean equals(Object o) {
-    if (this == o) return true;
-    if (o == null || getClass() != o.getClass()) return false;
+    if (this == o) {
+      return true;
+    }
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
     BinaryExpression that = (BinaryExpression) o;
     return op == that.op &&
         Objects.equals(left, that.left) &&
diff --git a/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/expression/DoubleValue.java b/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/expression/DoubleValue.java
index 9edf8d6..f90e5a1 100644
--- a/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/expression/DoubleValue.java
+++ b/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/expression/DoubleValue.java
@@ -63,8 +63,12 @@ public class DoubleValue implements Expression {
 
   @Override
   public boolean equals(Object o) {
-    if (this == o) return true;
-    if (o == null || getClass() != o.getClass()) return false;
+    if (this == o) {
+      return true;
+    }
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
     DoubleValue that = (DoubleValue) o;
     return Double.compare(that.value, value) == 0;
   }
diff --git a/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/expression/Expression.java b/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/expression/Expression.java
index f212ce6..af7b625 100644
--- a/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/expression/Expression.java
+++ b/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/expression/Expression.java
@@ -45,6 +45,10 @@ public interface Expression extends Evaluable {
   int length();
 
   class Utils {
+    private Utils() {
+
+    }
+
     public static Message toMessage(final Expression e) {
       final byte[] buf = new byte[e.length()];
       final int length = e.toBytes(buf, 0);
diff --git a/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/expression/NullValue.java b/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/expression/NullValue.java
index 6f589fa..d0b4832 100644
--- a/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/expression/NullValue.java
+++ b/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/expression/NullValue.java
@@ -21,7 +21,7 @@ import org.apache.ratis.util.Preconditions;
 
 import java.util.Map;
 
-public class NullValue implements Expression {
+public final class NullValue implements Expression {
   private static final NullValue INSTANCE = new NullValue();
 
   public static NullValue getInstance() {
diff --git a/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/expression/UnaryExpression.java b/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/expression/UnaryExpression.java
index 74b6ba8..29175be 100644
--- a/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/expression/UnaryExpression.java
+++ b/ratis-examples/src/main/java/org/apache/ratis/examples/arithmetic/expression/UnaryExpression.java
@@ -32,8 +32,8 @@ public class UnaryExpression implements Expression {
   public enum Op implements UnaryOperator<Expression>, DoubleFunction<Expression> {
     NEG("~"), SQRT("√"), SQUARE("^2", POSTFIX_OP_TO_STRING);
 
-    final String symbol;
-    final BiFunction<Op, Expression, String> stringFunction;
+    private final String symbol;
+    private final BiFunction<Op, Expression, String> stringFunction;
 
     Op(String symbol) {
       this(symbol, PREFIX_OP_TO_STRING);
@@ -78,8 +78,8 @@ public class UnaryExpression implements Expression {
     }
   }
 
-  final Op op;
-  final Expression expression;
+  private final Op op;
+  private final Expression expression;
 
   UnaryExpression(byte[] buf, int offset) {
     Preconditions.assertTrue(buf[offset] == Type.UNARY.byteValue());
@@ -122,8 +122,12 @@ public class UnaryExpression implements Expression {
 
   @Override
   public boolean equals(Object o) {
-    if (this == o) return true;
-    if (o == null || getClass() != o.getClass()) return false;
+    if (this == o) {
+      return true;
+    }
+    if (o == null || getClass() != o.getClass()) {
+      return false;
+    }
     UnaryExpression that = (UnaryExpression) o;
     return op == that.op &&
         Objects.equals(expression, that.expression);
diff --git a/ratis-examples/src/main/java/org/apache/ratis/examples/common/Runner.java b/ratis-examples/src/main/java/org/apache/ratis/examples/common/Runner.java
index 38fb272..ad45141 100644
--- a/ratis-examples/src/main/java/org/apache/ratis/examples/common/Runner.java
+++ b/ratis-examples/src/main/java/org/apache/ratis/examples/common/Runner.java
@@ -28,7 +28,11 @@ import java.util.Optional;
 /**
  * Standalone arithmetic raft server.
  */
-public class Runner {
+public final class Runner {
+
+  private Runner() {
+
+  }
 
   public static void main(String[] args) throws Exception {
     if (args.length == 0) {
diff --git a/ratis-examples/src/main/java/org/apache/ratis/examples/common/SubCommandBase.java b/ratis-examples/src/main/java/org/apache/ratis/examples/common/SubCommandBase.java
index 7f3d402..428afa4 100644
--- a/ratis-examples/src/main/java/org/apache/ratis/examples/common/SubCommandBase.java
+++ b/ratis-examples/src/main/java/org/apache/ratis/examples/common/SubCommandBase.java
@@ -21,6 +21,7 @@ import com.beust.jcommander.Parameter;
 import org.apache.ratis.protocol.RaftPeer;
 import org.apache.ratis.protocol.RaftPeerId;
 
+import java.util.Objects;
 import java.util.stream.Stream;
 
 /**
@@ -30,12 +31,12 @@ public abstract class SubCommandBase {
 
   @Parameter(names = {"--raftGroup",
       "-g"}, description = "Raft group identifier")
-  protected String raftGroupId = "demoRaftGroup123";
+  private String raftGroupId = "demoRaftGroup123";
 
   @Parameter(names = {"--peers", "-r"}, description =
       "Raft peers (format: name:host:port,"
           + "name:host:port)", required = true)
-  protected String peers;
+  private String peers;
 
   public static RaftPeer[] parsePeers(String peers) {
     return Stream.of(peers.split(",")).map(address -> {
@@ -50,4 +51,22 @@ public abstract class SubCommandBase {
   }
 
   public abstract void run() throws Exception;
+
+  public String getRaftGroupId() {
+    return raftGroupId;
+  }
+
+  /**
+   * @return the peer with the given id if it is in this group; otherwise, return null.
+   */
+  public RaftPeer getPeer(RaftPeerId raftPeerId) {
+    Objects.requireNonNull(raftPeerId, "raftPeerId == null");
+    for (RaftPeer p : getPeers()) {
+      if (raftPeerId.equals(p.getId())) {
+        return p;
+      }
+    }
+    throw new IllegalArgumentException("Raft peer id " + raftPeerId + " is not part of the raft group definitions " +
+            this.peers);
+  }
 }
\ No newline at end of file
diff --git a/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/FileInfo.java b/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/FileInfo.java
index 8e63f1f..9bad915 100644
--- a/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/FileInfo.java
+++ b/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/FileInfo.java
@@ -80,7 +80,7 @@ abstract class FileInfo {
           + ", path=" + getRelativePath());
     }
 
-    try(final SeekableByteChannel in = Files.newByteChannel(
+    try(SeekableByteChannel in = Files.newByteChannel(
         resolver.apply(getRelativePath()), StandardOpenOption.READ)) {
       final ByteBuffer buffer = ByteBuffer.allocateDirect(FileStoreCommon.getChunkSize(length));
       in.position(offset).read(buffer);
@@ -302,8 +302,8 @@ abstract class FileInfo {
       final CompletableFuture<Integer> previousCommit = previous != null?
           previous.getCommitFuture(): CompletableFuture.completedFuture(0);
       // Commit after both current write and previous commit completed.
-      return info.getWriteFuture().thenCombineAsync(previousCommit, (writeSize, previousCommitSize) -> {
-        Preconditions.assertTrue(size == writeSize);
+      return info.getWriteFuture().thenCombineAsync(previousCommit, (wSize, previousCommitSize) -> {
+        Preconditions.assertTrue(size == wSize);
         try {
           return task.get();
         } catch (IOException e) {
diff --git a/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/FileStoreClient.java b/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/FileStoreClient.java
index a7c9fee..4b8cd5a 100644
--- a/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/FileStoreClient.java
+++ b/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/FileStoreClient.java
@@ -82,8 +82,7 @@ public class FileStoreClient implements Closeable {
   }
 
   static CompletableFuture<ByteString> sendAsync(
-      ByteString request, Function<Message, CompletableFuture<RaftClientReply>> sendFunction)
-      {
+      ByteString request, Function<Message, CompletableFuture<RaftClientReply>> sendFunction) {
     return sendFunction.apply(() -> request
     ).thenApply(reply -> {
       final StateMachineException sme = reply.getStateMachineException();
diff --git a/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/FileStoreCommon.java b/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/FileStoreCommon.java
index 8e223d2..cc769fc 100644
--- a/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/FileStoreCommon.java
+++ b/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/FileStoreCommon.java
@@ -23,7 +23,6 @@ import org.apache.ratis.util.*;
 import java.io.IOException;
 import java.nio.file.Path;
 import java.util.concurrent.CompletableFuture;
-import java.util.function.Supplier;
 
 public interface FileStoreCommon {
   String STATEMACHINE_DIR_KEY = "example.filestore.statemachine.dir";
diff --git a/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/Client.java b/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/Client.java
index 8f9c888..bf200ee 100644
--- a/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/Client.java
+++ b/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/Client.java
@@ -66,8 +66,8 @@ public abstract class Client extends SubCommandBase {
     RaftClientConfigKeys.Async.setMaxOutstandingRequests(raftProperties, 1000);
 
 
-    final RaftGroup raftGroup = RaftGroup.valueOf(RaftGroupId.valueOf(ByteString.copyFromUtf8(raftGroupId)),
-        parsePeers(peers));
+    final RaftGroup raftGroup = RaftGroup.valueOf(RaftGroupId.valueOf(ByteString.copyFromUtf8(getRaftGroupId())),
+            getPeers());
 
     RaftClient.Builder builder =
         RaftClient.newBuilder().setProperties(raftProperties);
diff --git a/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/FileStore.java b/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/FileStore.java
index 8cedf8b..dd19c6c 100644
--- a/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/FileStore.java
+++ b/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/FileStore.java
@@ -26,7 +26,10 @@ import java.util.List;
 /**
  * This class enumerates all the commands enqueued by FileStore state machine.
  */
-public class FileStore {
+public final class FileStore {
+  private FileStore() {
+  }
+
   public static List<SubCommandBase> getSubCommands() {
     List<SubCommandBase> commands = new ArrayList<>();
     commands.add(new Server());
diff --git a/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/LoadGen.java b/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/LoadGen.java
index 2658324..0731405 100644
--- a/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/LoadGen.java
+++ b/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/LoadGen.java
@@ -41,10 +41,10 @@ public class LoadGen extends Client {
   private static final String UTF8_CSN = StandardCharsets.UTF_8.name();
 
   @Parameter(names = {"--size"}, description = "Size of each file", required = true)
-  String size;
+  private String size;
 
   @Parameter(names = {"--numFiles"}, description = "Number of files", required = true)
-  String numFiles;
+  private String numFiles;
 
   private static byte[] string2Bytes(String str) {
     try {
diff --git a/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/Server.java b/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/Server.java
index a81366b..c780aba 100644
--- a/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/Server.java
+++ b/ratis-examples/src/main/java/org/apache/ratis/examples/filestore/cli/Server.java
@@ -28,7 +28,6 @@ import org.apache.ratis.grpc.GrpcConfigKeys;
 import org.apache.ratis.metrics.JVMMetrics;
 import org.apache.ratis.protocol.RaftGroup;
 import org.apache.ratis.protocol.RaftGroupId;
-import org.apache.ratis.protocol.RaftPeer;
 import org.apache.ratis.protocol.RaftPeerId;
 import org.apache.ratis.server.RaftServer;
 import org.apache.ratis.server.RaftServerConfigKeys;
@@ -40,7 +39,6 @@ import org.apache.ratis.util.TimeDuration;
 
 import java.io.File;
 import java.util.Collections;
-import java.util.Objects;
 import java.util.concurrent.TimeUnit;
 
 /**
@@ -62,7 +60,6 @@ public class Server extends SubCommandBase {
     RaftPeerId peerId = RaftPeerId.valueOf(id);
     RaftProperties properties = new RaftProperties();
 
-    RaftPeer[] peers = getPeers();
     final int port = NetUtils.createSocketAddr(getPeer(peerId).getAddress()).getPort();
     GrpcConfigKeys.Server.setPort(properties, port);
     properties.setInt(GrpcConfigKeys.OutputStream.RETRY_TIMES_KEY, Integer.MAX_VALUE);
@@ -71,7 +68,8 @@ public class Server extends SubCommandBase {
         storageDir);
     StateMachine stateMachine = new FileStoreStateMachine(properties);
 
-    final RaftGroup raftGroup = RaftGroup.valueOf(RaftGroupId.valueOf(ByteString.copyFromUtf8(raftGroupId)), peers);
+    final RaftGroup raftGroup = RaftGroup.valueOf(RaftGroupId.valueOf(ByteString.copyFromUtf8(getRaftGroupId())),
+            getPeers());
     RaftServer raftServer = RaftServer.newBuilder()
         .setServerId(RaftPeerId.valueOf(id))
         .setStateMachine(stateMachine).setProperties(properties)
@@ -85,16 +83,4 @@ public class Server extends SubCommandBase {
     }
   }
 
-  /**
-   * @return the peer with the given id if it is in this group; otherwise, return null.
-   */
-  public RaftPeer getPeer(RaftPeerId id) {
-    Objects.requireNonNull(id, "id == null");
-    for (RaftPeer p : getPeers()) {
-      if (id.equals(p.getId())) {
-        return p;
-      }
-    }
-    throw new IllegalArgumentException("Raft peer id " + id + " is not part of the raft group definitions " + peers);
-  }
 }