szetszwo commented on a change in pull request #593:
URL: https://github.com/apache/ratis/pull/593#discussion_r793254430
##########
File path:
ratis-server/src/test/java/org/apache/ratis/server/impl/LeaderElectionTests.java
##########
@@ -436,6 +439,37 @@ void runTestPauseResumeLeaderElection(CLUSTER cluster)
throws IOException, Inter
}
}
+ void runTestPauseResumeLeaderWithProxy(CLUSTER cluster) throws Exception {
+ final RaftClientReply pauseLeaderReply;
+ final RaftServer.Division leader = RaftTestUtil.waitForLeader(cluster);
+ final RaftPeerId leaderId = leader.getId();
+ final List<RaftServer.Division> followers = cluster.getFollowers();
+ Assert.assertTrue(followers.size() >= 1);
+ final RaftServerImpl f1 = (RaftServerImpl)followers.get(0);
+
+ try (final RaftClient client = cluster.createClient()) {
+ final PauseLeaderElectionRequest r = new PauseLeaderElectionRequest(
+ client.getId(), f1.getId(),cluster.getGroupId(),
CallId.getAndIncrement(), 3000, true);
+ pauseLeaderReply = RaftServerTestUtil.pauseLeaderElectionAsync(f1,
r).join();
Review comment:
RaftServerProxy.setLeaderElectionAsync(..)
```
pauseLeaderReply = f1.getRaftServer().setLeaderElectionAsync(r).join();
```
##########
File path:
ratis-server/src/test/java/org/apache/ratis/server/impl/RaftServerTestUtil.java
##########
@@ -185,4 +186,9 @@ public static boolean isHighestPriority(RaftConfiguration
config, RaftPeerId pee
throws IOException {
return ((RaftServerImpl)leader).takeSnapshotAsync(r);
}
+
+ public static CompletableFuture<RaftClientReply>
pauseLeaderElectionAsync(RaftServer.Division server, PauseLeaderElectionRequest
r)
+ throws IOException {
+ return ((RaftServerImpl)server).pauseLeaderElectionAsync(r);
+ }
Review comment:
This method is not needed.
##########
File path:
ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerProxy.java
##########
@@ -537,6 +537,15 @@ public RaftClientReply
snapshotManagement(SnapshotManagementRequest request) thr
return submitRequest(request.getRaftGroupId(), impl ->
impl.takeSnapshotAsync(request));
}
+ public CompletableFuture<RaftClientReply>
pauseLeaderElectionAsync(PauseLeaderElectionRequest request) {
+ final RaftGroupId groupId = request.getRaftGroupId();
+ if (groupId == null) {
+ return JavaUtils.completeExceptionally(new GroupMismatchException(
+ getId() + ": Request group id == null"));
+ }
Review comment:
These few lines can be removed. The null case is already taking care in
the submitRequest(..).
--
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]