use of org.apache.ignite.raft.jraft.rpc.CliRequests.SnapshotRequest in project ignite-3 by apache.
the class CliServiceImpl method snapshot.
@Override
public Status snapshot(final String groupId, final PeerId peer) {
Requires.requireTrue(!StringUtils.isBlank(groupId), "Blank group id");
Requires.requireNonNull(peer, "Null peer");
if (!this.cliClientService.connect(peer.getEndpoint())) {
return new Status(-1, "Fail to init channel to %s", peer);
}
SnapshotRequest req = cliOptions.getRaftMessagesFactory().snapshotRequest().groupId(groupId).peerId(peer.toString()).build();
try {
final Message result = this.cliClientService.snapshot(peer.getEndpoint(), req, null).get();
return statusFromResponse(result);
} catch (final Exception e) {
return new Status(-1, e.getMessage());
}
}
use of org.apache.ignite.raft.jraft.rpc.CliRequests.SnapshotRequest in project ignite-3 by apache.
the class RaftGroupServiceImpl method snapshot.
/**
* {@inheritDoc}
*/
@Override
public CompletableFuture<Void> snapshot(Peer peer) {
SnapshotRequest req = factory.snapshotRequest().groupId(groupId).build();
// Disable the timeout for a snapshot request.
CompletableFuture<NetworkMessage> fut = cluster.messagingService().invoke(peer.address(), req, Integer.MAX_VALUE);
return fut.thenCompose(resp -> {
if (resp != null) {
RpcRequests.ErrorResponse resp0 = (RpcRequests.ErrorResponse) resp;
if (resp0.errorCode() != RaftError.SUCCESS.getNumber())
return CompletableFuture.failedFuture(new RaftException(RaftError.forNumber(resp0.errorCode()), resp0.errorMsg()));
}
return CompletableFuture.completedFuture(null);
});
}
Aggregations