Search in sources :

Example 1 with WriteIngestorRequest

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

the class IngestorWriteClient method writeIngestorAsync.

public void writeIngestorAsync(String requestId, int queueId, OperationBatch operationBatch, CompletionCallback<Long> callback) {
    WriteIngestorRequest request = WriteIngestorRequest.newBuilder().setRequestId(requestId).setQueueId(queueId).setOperationBatch(operationBatch.toProto()).build();
    this.asyncStub.writeIngestor(request, new StreamObserver<WriteIngestorResponse>() {

        @Override
        public void onNext(WriteIngestorResponse response) {
            callback.onCompleted(response.getSnapshotId());
        }

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

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

Example 2 with WriteIngestorRequest

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

the class IngestorRpcTest method testIngestorWriteService.

@Test
void testIngestorWriteService() {
    IngestService ingestService = mock(IngestService.class);
    IngestorWriteService ingestorWriteService = new IngestorWriteService(ingestService);
    WriteIngestorRequest req = WriteIngestorRequest.newBuilder().setQueueId(2).setRequestId("test_req").setOperationBatch(OperationBatch.newBuilder().build().toProto()).build();
    doAnswer(invocation -> {
        IngestCallback callback = invocation.getArgument(3);
        callback.onSuccess(10L);
        return null;
    }).when(ingestService).ingestBatch(eq("test_req"), eq(2), eq(OperationBatch.newBuilder().build()), any());
    StreamObserver<WriteIngestorResponse> observer = mock(StreamObserver.class);
    ingestorWriteService.writeIngestor(req, observer);
    verify(observer).onNext(WriteIngestorResponse.newBuilder().setSnapshotId(10L).build());
    verify(observer).onCompleted();
}
Also used : IngestService(com.alibaba.graphscope.groot.ingestor.IngestService) IngestorWriteService(com.alibaba.graphscope.groot.ingestor.IngestorWriteService) WriteIngestorRequest(com.alibaba.maxgraph.proto.groot.WriteIngestorRequest) WriteIngestorResponse(com.alibaba.maxgraph.proto.groot.WriteIngestorResponse) IngestCallback(com.alibaba.graphscope.groot.ingestor.IngestCallback) Test(org.junit.jupiter.api.Test)

Example 3 with WriteIngestorRequest

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

the class IngestorWriteClient method writeIngestor.

public BatchId writeIngestor(String requestId, int queueId, OperationBatch operationBatch) {
    WriteIngestorRequest request = WriteIngestorRequest.newBuilder().setRequestId(requestId).setQueueId(queueId).setOperationBatch(operationBatch.toProto()).build();
    WriteIngestorResponse response = this.stub.writeIngestor(request);
    return new BatchId(response.getSnapshotId());
}
Also used : BatchId(com.alibaba.graphscope.groot.operation.BatchId) WriteIngestorRequest(com.alibaba.maxgraph.proto.groot.WriteIngestorRequest) WriteIngestorResponse(com.alibaba.maxgraph.proto.groot.WriteIngestorResponse)

Aggregations

WriteIngestorRequest (com.alibaba.maxgraph.proto.groot.WriteIngestorRequest)3 WriteIngestorResponse (com.alibaba.maxgraph.proto.groot.WriteIngestorResponse)3 IngestCallback (com.alibaba.graphscope.groot.ingestor.IngestCallback)1 IngestService (com.alibaba.graphscope.groot.ingestor.IngestService)1 IngestorWriteService (com.alibaba.graphscope.groot.ingestor.IngestorWriteService)1 BatchId (com.alibaba.graphscope.groot.operation.BatchId)1 Test (org.junit.jupiter.api.Test)1