You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by GitBox <gi...@apache.org> on 2022/01/21 13:38:24 UTC
[GitHub] [ratis] codings-dan opened a new pull request #586: RATIS-1498. Take snapshot on specific ratis server
codings-dan opened a new pull request #586:
URL: https://github.com/apache/ratis/pull/586
## What changes were proposed in this pull request?
subtask of Support snapshot command: Take snapshot on specific ratis server
## What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/RATIS-1498
## How was this patch tested?
UT
--
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: issues-unsubscribe@ratis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ratis] codings-dan commented on pull request #586: RATIS-1498. Take snapshot on specific ratis server
Posted by GitBox <gi...@apache.org>.
codings-dan commented on pull request #586:
URL: https://github.com/apache/ratis/pull/586#issuecomment-1019416138
@szetszwo I changed the API related to take shanpshot, PTAL, thx! The result of the CI test has nothing to do with this code change.
```
Error: Tests run: 3, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 3.116 s <<< FAILURE! - in org.apache.ratis.grpc.TestRaftStateMachineExceptionWithGrpc
Error: testRetryOnExceptionDuringReplication(org.apache.ratis.grpc.TestRaftStateMachineExceptionWithGrpc) Time elapsed: 0.59 s <<< ERROR!
java.lang.NullPointerException
at java.util.Objects.requireNonNull(Objects.java:203)
at org.apache.ratis.server.impl.RaftStateMachineExceptionTests.runTestRetryOnExceptionDuringReplication(RaftStateMachineExceptionTests.java:172)
at org.apache.ratis.server.impl.MiniRaftCluster$Factory$Get.runWithNewCluster(MiniRaftCluster.java:125)
at org.apache.ratis.server.impl.MiniRaftCluster$Factory$Get.runWithNewCluster(MiniRaftCluster.java:113)
at org.apache.ratis.server.impl.RaftStateMachineExceptionTests.testRetryOnExceptionDuringReplication(RaftStateMachineExceptionTests.java:147)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:298)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:292)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.lang.Thread.run(Thread.java:748)
```
--
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: issues-unsubscribe@ratis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ratis] szetszwo merged pull request #586: RATIS-1498. Take snapshot on specific ratis server
Posted by GitBox <gi...@apache.org>.
szetszwo merged pull request #586:
URL: https://github.com/apache/ratis/pull/586
--
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: issues-unsubscribe@ratis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [ratis] szetszwo commented on a change in pull request #586: RATIS-1498. Take snapshot on specific ratis server
Posted by GitBox <gi...@apache.org>.
szetszwo commented on a change in pull request #586:
URL: https://github.com/apache/ratis/pull/586#discussion_r790223827
##########
File path: ratis-client/src/main/java/org/apache/ratis/client/RaftClient.java
##########
@@ -58,8 +58,8 @@
/** Get the {@link GroupManagementApi} for the given server. */
GroupManagementApi getGroupManagementApi(RaftPeerId server);
- /** Get the {@link SnapshotManagementApi}. */
- SnapshotManagementApi getSnapshotManagementApi();
+ /** Get the {@link SnapshotManagementApi} for the given server. */
Review comment:
We should support null as below:
```
/**
* If server != null, return the {@link SnapshotManagementApi} for the given server.
* Otherwise, return the {@link SnapshotManagementApi} for the group.
*/
```
##########
File path: ratis-client/src/main/java/org/apache/ratis/client/impl/SnapshotManagementImpl.java
##########
@@ -27,15 +28,19 @@
class SnapshotManagementImpl implements SnapshotManagementApi {
private final RaftClientImpl client;
+ private final RaftPeerId server;
- SnapshotManagementImpl(RaftClientImpl client) {
+ SnapshotManagementImpl(RaftPeerId server, RaftClientImpl client) {
+ this.server = Objects.requireNonNull(server, "server == null");
this.client = Objects.requireNonNull(client, "client == null");
}
@Override
public RaftClientReply create(long timeoutMs) throws IOException {
final long callId = CallId.getAndIncrement();
- return client.io().sendRequestWithRetry(() -> SnapshotManagementRequest.newCreate(
- client.getId(), client.getLeaderId(), client.getGroupId(), callId, timeoutMs));
+ final RaftClientReply reply = client.io().sendRequestWithRetry(
+ () -> SnapshotManagementRequest.newCreate(client.getId(), server,
+ client.getGroupId(), callId, timeoutMs));
+ return reply;
Review comment:
We should support the case the server == null. When server == null, use client.getLeaderId() as before.
```
return client.io().sendRequestWithRetry(() -> SnapshotManagementRequest.newCreate(client.getId(),
Optional.ofNullable(server).orElseGet(client::getLeaderId), client.getGroupId(), callId, timeoutMs));
```
##########
File path: ratis-shell/src/main/java/org/apache/ratis/shell/cli/sh/snapshot/TakeSnapshotCommand.java
##########
@@ -50,16 +52,22 @@ public String getCommandName() {
public int run(CommandLine cl) throws IOException {
super.run(cl);
long timeout;
+ final RaftPeerId peerId;
if (cl.hasOption(TAKE_SNAPSHOT_TIMEOUT_OPTION_NAME)) {
timeout = Long.parseLong(cl.getOptionValue(TAKE_SNAPSHOT_TIMEOUT_OPTION_NAME));
} else {
timeout = 3000;
}
try(final RaftClient raftClient = RaftUtils.createClient(getRaftGroup())) {
- RaftClientReply reply = raftClient.getSnapshotManagementApi().create(timeout);
- processReply(reply, () -> String.format("Failed to take snapshot of peerId %s", raftClient.getLeaderId()));
- printf(String.format("Successful take snapshot, the latest snapshot index is %d",
- reply.getLogIndex()));
+ if (cl.hasOption(PEER_ID_OPTION_NAME)) {
+ peerId = RaftPeerId.getRaftPeerId(cl.getOptionValue(PEER_ID_OPTION_NAME));
+ } else {
+ peerId = raftClient.getLeaderId();
Review comment:
Just set peerId = null. The leader could change so that we should getLeaderId right before sending the rpc.
--
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: issues-unsubscribe@ratis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org