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 2022/08/31 02:36:14 UTC
[ratis] branch master updated: RATIS-1694. Fix the compatibility issue of RATIS-1677. (#731)
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/ratis.git
The following commit(s) were added to refs/heads/master by this push:
new 74905dfdb RATIS-1694. Fix the compatibility issue of RATIS-1677. (#731)
74905dfdb is described below
commit 74905dfdb942a722caf32f78c2f5afedf9cc8095
Author: Tsz-Wo Nicholas Sze <sz...@apache.org>
AuthorDate: Tue Aug 30 19:36:08 2022 -0700
RATIS-1694. Fix the compatibility issue of RATIS-1677. (#731)
---
.../java/org/apache/ratis/protocol/GroupManagementRequest.java | 5 +++++
.../src/main/java/org/apache/ratis/server/RaftServer.java | 2 +-
.../test/java/org/apache/ratis/grpc/TestRaftServerWithGrpc.java | 8 +++++---
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/ratis-common/src/main/java/org/apache/ratis/protocol/GroupManagementRequest.java b/ratis-common/src/main/java/org/apache/ratis/protocol/GroupManagementRequest.java
index 2783d2c65..6aaee8e6e 100644
--- a/ratis-common/src/main/java/org/apache/ratis/protocol/GroupManagementRequest.java
+++ b/ratis-common/src/main/java/org/apache/ratis/protocol/GroupManagementRequest.java
@@ -85,6 +85,11 @@ public final class GroupManagementRequest extends RaftClientRequest {
}
}
+ /** The same as newAdd(clientId, serverId, callId, group, true). */
+ public static GroupManagementRequest newAdd(ClientId clientId, RaftPeerId serverId, long callId, RaftGroup group) {
+ return newAdd(clientId, serverId, callId, group, true);
+ }
+
public static GroupManagementRequest newAdd(ClientId clientId, RaftPeerId serverId, long callId,
RaftGroup group, boolean format) {
return new GroupManagementRequest(clientId, serverId, callId, new Add(group, format));
diff --git a/ratis-server-api/src/main/java/org/apache/ratis/server/RaftServer.java b/ratis-server-api/src/main/java/org/apache/ratis/server/RaftServer.java
index 8d00d29db..dbf6bbd8c 100644
--- a/ratis-server-api/src/main/java/org/apache/ratis/server/RaftServer.java
+++ b/ratis-server-api/src/main/java/org/apache/ratis/server/RaftServer.java
@@ -193,7 +193,7 @@ public interface RaftServer extends Closeable, RpcType.Get,
private RaftPeerId serverId;
private StateMachine.Registry stateMachineRegistry ;
private RaftGroup group = null;
- private RaftStorage.StartupOption option = RaftStorage.StartupOption.RECOVER;
+ private RaftStorage.StartupOption option = RaftStorage.StartupOption.FORMAT;
private RaftProperties properties;
private Parameters parameters;
diff --git a/ratis-test/src/test/java/org/apache/ratis/grpc/TestRaftServerWithGrpc.java b/ratis-test/src/test/java/org/apache/ratis/grpc/TestRaftServerWithGrpc.java
index bcf70f169..fb5588e0a 100644
--- a/ratis-test/src/test/java/org/apache/ratis/grpc/TestRaftServerWithGrpc.java
+++ b/ratis-test/src/test/java/org/apache/ratis/grpc/TestRaftServerWithGrpc.java
@@ -26,6 +26,7 @@ import static org.apache.ratis.server.metrics.RaftServerMetricsImpl.REQUEST_MEGA
import static org.apache.ratis.server.metrics.RaftServerMetricsImpl.REQUEST_BYTE_SIZE_LIMIT_HIT_COUNTER;
import static org.apache.ratis.server.metrics.RaftServerMetricsImpl.RESOURCE_LIMIT_HIT_COUNTER;
+import org.apache.ratis.server.storage.RaftStorage;
import org.apache.ratis.thirdparty.com.codahale.metrics.Gauge;
import org.apache.log4j.Level;
import org.apache.ratis.BaseTest;
@@ -103,12 +104,13 @@ public class TestRaftServerWithGrpc extends BaseTest implements MiniRaftClusterW
}
static RaftServer newRaftServer(MiniRaftClusterWithGrpc cluster, RaftPeerId id, StateMachine stateMachine,
- RaftProperties p) throws IOException {
+ RaftStorage.StartupOption option, RaftProperties p) throws IOException {
final RaftGroup group = cluster.getGroup();
return RaftServer.newBuilder()
.setServerId(id)
.setGroup(cluster.getGroup())
.setStateMachine(stateMachine)
+ .setOption(option)
.setProperties(p)
.setParameters(cluster.setPropertiesAndInitParameters(id, group, p))
.build();
@@ -126,7 +128,7 @@ public class TestRaftServerWithGrpc extends BaseTest implements MiniRaftClusterW
// be used by next raft server proxy instance.
final StateMachine stateMachine = cluster.getLeader().getStateMachine();
RaftServerConfigKeys.setStorageDir(p, Collections.singletonList(cluster.getStorageDir(leaderId)));
- newRaftServer(cluster, leaderId, stateMachine, p);
+ newRaftServer(cluster, leaderId, stateMachine, RaftStorage.StartupOption.FORMAT, p);
// Close the server rpc for leader so that new raft server can be bound to it.
RaftServerTestUtil.getServerRpc(cluster.getLeader()).close();
@@ -136,7 +138,7 @@ public class TestRaftServerWithGrpc extends BaseTest implements MiniRaftClusterW
// the rpc server on failure.
RaftServerConfigKeys.setStorageDir(p, Collections.singletonList(cluster.getStorageDir(leaderId)));
testFailureCase("Starting a new server with the same address should fail",
- () -> newRaftServer(cluster, leaderId, stateMachine, p).start(),
+ () -> newRaftServer(cluster, leaderId, stateMachine, RaftStorage.StartupOption.RECOVER, p).start(),
CompletionException.class, LOG, IOException.class, OverlappingFileLockException.class);
// Try to start a raft server rpc at the leader address.