adoroszlai commented on code in PR #1279:
URL: https://github.com/apache/ratis/pull/1279#discussion_r2272805964


##########
ratis-server/src/main/java/org/apache/ratis/statemachine/impl/BaseStateMachine.java:
##########
@@ -42,13 +42,17 @@
 import java.util.SortedMap;
 import java.util.TreeMap;
 import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
 
 /**
  * Base implementation for StateMachines.
  */
 public class BaseStateMachine implements StateMachine, StateMachine.DataApi,
     StateMachine.EventApi, StateMachine.LeaderEventApi, 
StateMachine.FollowerEventApi {
+  static final AtomicInteger ID_GENERATOR = new AtomicInteger();

Review Comment:
   nit: should be private?
   
   ```suggestion
     private static final AtomicInteger ID_GENERATOR = new AtomicInteger();
   ```



##########
ratis-common/src/main/java/org/apache/ratis/util/FileUtils.java:
##########
@@ -382,4 +386,26 @@ public FileVisitResult postVisitDirectory(Path dir, 
IOException e) throws IOExce
       }
     });
   }
+
+  static void listDir(File dir, Consumer<Object> out, BiConsumer<String, 
Throwable> err) {
+    listDir(dir.toPath(), out, err);
+  }
+
+  static void listDir(Path dir, Consumer<Object> out, BiConsumer<String, 
Throwable> err) {
+    try {
+      listDir(dir, out);
+    } catch (IOException e) {
+      err.accept("Failed to lsDir: " + dir, e);
+    }
+  }
+
+  static void listDir(Path dir, Consumer<Object> out) throws IOException {
+    if (!Files.isDirectory(dir, LinkOption.NOFOLLOW_LINKS)) {
+      throw new NotDirectoryException( "Failed to lsDir: " + dir + " is not a 
directory.");

Review Comment:
   nit:
   
   ```suggestion
         throw new NotDirectoryException("Failed to listDir: " + dir + " is not 
a directory.");
   ```



##########
ratis-examples/src/test/java/org/apache/ratis/examples/counter/server/TestManualRestoreSnapshot.java:
##########
@@ -0,0 +1,142 @@
+/*
+ * 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.counter.server;
+
+import org.apache.ratis.BaseTest;
+import org.apache.ratis.RaftTestUtil;
+import org.apache.ratis.client.RaftClient;
+import org.apache.ratis.examples.counter.CounterCommand;
+import org.apache.ratis.grpc.MiniRaftClusterWithGrpc;
+import org.apache.ratis.protocol.Message;
+import org.apache.ratis.protocol.RaftClientReply;
+import org.apache.ratis.protocol.RaftGroup;
+import org.apache.ratis.protocol.RaftPeerId;
+import org.apache.ratis.server.RaftServer;
+import org.apache.ratis.server.impl.MiniRaftCluster;
+import org.apache.ratis.server.protocol.TermIndex;
+import org.apache.ratis.statemachine.SnapshotInfo;
+import org.apache.ratis.statemachine.StateMachine;
+import org.apache.ratis.statemachine.impl.SimpleStateMachineStorage;
+import org.apache.ratis.util.FileUtils;
+import org.apache.ratis.util.JavaUtils;
+import org.apache.ratis.util.TimeDuration;
+import org.junit.jupiter.api.Test;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Test StateMachine related functionality

Review Comment:
   Comment seems to be leftover from `TestStateMachine`.



##########
ratis-common/src/main/java/org/apache/ratis/util/FileUtils.java:
##########
@@ -382,4 +386,26 @@ public FileVisitResult postVisitDirectory(Path dir, 
IOException e) throws IOExce
       }
     });
   }
+
+  static void listDir(File dir, Consumer<Object> out, BiConsumer<String, 
Throwable> err) {
+    listDir(dir.toPath(), out, err);
+  }
+
+  static void listDir(Path dir, Consumer<Object> out, BiConsumer<String, 
Throwable> err) {
+    try {
+      listDir(dir, out);
+    } catch (IOException e) {
+      err.accept("Failed to lsDir: " + dir, e);

Review Comment:
   nit:
   
   ```suggestion
         err.accept("Failed to listDir: " + dir, e);
   ```



-- 
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