Search in sources :

Example 1 with AdvanceIngestSnapshotIdResponse

use of com.alibaba.maxgraph.proto.groot.AdvanceIngestSnapshotIdResponse in project GraphScope by alibaba.

the class IngestorSnapshotClient method advanceIngestSnapshotId.

public void advanceIngestSnapshotId(long writeSnapshotId, CompletionCallback<Long> callback) {
    AdvanceIngestSnapshotIdRequest req = AdvanceIngestSnapshotIdRequest.newBuilder().setSnapshotId(writeSnapshotId).build();
    stub.advanceIngestSnapshotId(req, new StreamObserver<AdvanceIngestSnapshotIdResponse>() {

        @Override
        public void onNext(AdvanceIngestSnapshotIdResponse response) {
            long previousSnapshotId = response.getPreviousSnapshotId();
            callback.onCompleted(previousSnapshotId);
        }

        @Override
        public void onError(Throwable throwable) {
            callback.onError(throwable);
        }

        @Override
        public void onCompleted() {
        }
    });
}
Also used : AdvanceIngestSnapshotIdResponse(com.alibaba.maxgraph.proto.groot.AdvanceIngestSnapshotIdResponse) AdvanceIngestSnapshotIdRequest(com.alibaba.maxgraph.proto.groot.AdvanceIngestSnapshotIdRequest)

Example 2 with AdvanceIngestSnapshotIdResponse

use of com.alibaba.maxgraph.proto.groot.AdvanceIngestSnapshotIdResponse in project GraphScope by alibaba.

the class IngestorRpcTest method testIngestorSnapshotService.

@Test
void testIngestorSnapshotService() {
    IngestService ingestService = mock(IngestService.class);
    IngestorSnapshotService ingestorSnapshotService = new IngestorSnapshotService(ingestService);
    AdvanceIngestSnapshotIdRequest req = AdvanceIngestSnapshotIdRequest.newBuilder().setSnapshotId(10L).build();
    StreamObserver<AdvanceIngestSnapshotIdResponse> streamObserver = mock(StreamObserver.class);
    doAnswer(invocation -> {
        CompletionCallback<Long> callback = invocation.getArgument(1);
        callback.onCompleted(9L);
        return null;
    }).when(ingestService).advanceIngestSnapshotId(anyLong(), any());
    ingestorSnapshotService.advanceIngestSnapshotId(req, streamObserver);
    verify(streamObserver).onNext(AdvanceIngestSnapshotIdResponse.newBuilder().setPreviousSnapshotId(9L).build());
    verify(streamObserver).onCompleted();
}
Also used : IngestService(com.alibaba.graphscope.groot.ingestor.IngestService) AdvanceIngestSnapshotIdResponse(com.alibaba.maxgraph.proto.groot.AdvanceIngestSnapshotIdResponse) AdvanceIngestSnapshotIdRequest(com.alibaba.maxgraph.proto.groot.AdvanceIngestSnapshotIdRequest) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) IngestorSnapshotService(com.alibaba.graphscope.groot.ingestor.IngestorSnapshotService) Test(org.junit.jupiter.api.Test)

Aggregations

AdvanceIngestSnapshotIdRequest (com.alibaba.maxgraph.proto.groot.AdvanceIngestSnapshotIdRequest)2 AdvanceIngestSnapshotIdResponse (com.alibaba.maxgraph.proto.groot.AdvanceIngestSnapshotIdResponse)2 IngestService (com.alibaba.graphscope.groot.ingestor.IngestService)1 IngestorSnapshotService (com.alibaba.graphscope.groot.ingestor.IngestorSnapshotService)1 Test (org.junit.jupiter.api.Test)1 ArgumentMatchers.anyLong (org.mockito.ArgumentMatchers.anyLong)1