use of org.apache.ratis.protocol.SnapshotManagementRequest in project incubator-ratis by apache.
the class SnapshotManagementTest method runTestTakeSnapshotWithConfigurableGap.
void runTestTakeSnapshotWithConfigurableGap(CLUSTER cluster) throws Exception {
RaftClientReply snapshotReply;
final RaftServer.Division leader = RaftTestUtil.waitForLeader(cluster);
final RaftPeerId leaderId = leader.getId();
try (final RaftClient client = cluster.createClient(leaderId)) {
for (int i = 0; i < RaftServerConfigKeys.Snapshot.creationGap(getProperties()) / 2 - 1; i++) {
RaftClientReply reply = client.io().send(new RaftTestUtil.SimpleMessage("m" + i));
Assert.assertTrue(reply.isSuccess());
}
Assert.assertTrue(leader.getStateMachine().getLastAppliedTermIndex().getIndex() < RaftServerConfigKeys.Snapshot.creationGap(getProperties()));
snapshotReply = client.getSnapshotManagementApi(leaderId).create(3000);
Assert.assertTrue(snapshotReply.isSuccess());
Assert.assertEquals(0, snapshotReply.getLogIndex());
for (int i = 0; i < RaftServerConfigKeys.Snapshot.creationGap(getProperties()) / 2 - 1; i++) {
RaftClientReply reply = client.io().send(new RaftTestUtil.SimpleMessage("m" + i));
Assert.assertTrue(reply.isSuccess());
}
final SnapshotManagementRequest r1 = SnapshotManagementRequest.newCreate(client.getId(), leaderId, cluster.getGroupId(), CallId.getAndIncrement(), 3000);
snapshotReply = client.getSnapshotManagementApi(leaderId).create(3000);
}
Assert.assertTrue(snapshotReply.isSuccess());
final long snapshotIndex = snapshotReply.getLogIndex();
LOG.info("snapshotIndex = {}", snapshotIndex);
final File snapshotFile = SimpleStateMachine4Testing.get(leader).getStateMachineStorage().getSnapshotFile(leader.getInfo().getCurrentTerm(), snapshotIndex);
Assert.assertTrue(snapshotFile.exists());
}
use of org.apache.ratis.protocol.SnapshotManagementRequest in project incubator-ratis by apache.
the class GrpcAdminProtocolService method snapshotManagement.
@Override
public void snapshotManagement(SnapshotManagementRequestProto proto, StreamObserver<RaftClientReplyProto> responseObserver) {
final SnapshotManagementRequest request = ClientProtoUtils.toSnapshotManagementRequest(proto);
GrpcUtil.asyncCall(responseObserver, () -> protocol.snapshotManagementAsync(request), ClientProtoUtils::toRaftClientReplyProto);
}
Aggregations