Search in sources :

Example 1 with WriteStoreResponse

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

the class IngestorRpcTest method testStoreWriteClient.

@Test
void testStoreWriteClient() {
    StoreWriteGrpc.StoreWriteStub stub = mock(StoreWriteGrpc.StoreWriteStub.class);
    StoreWriteClient client = new StoreWriteClient(stub);
    CompletionCallback callback = mock(CompletionCallback.class);
    doAnswer(invocation -> {
        StreamObserver<WriteStoreResponse> observer = invocation.getArgument(1);
        observer.onNext(WriteStoreResponse.newBuilder().setSuccess(true).build());
        return null;
    }).when(stub).writeStore(any(), any());
    client.writeStore(Arrays.asList(StoreDataBatch.newBuilder().requestId("test_req").build()), callback);
    verify(callback).onCompleted(10);
}
Also used : WriteStoreResponse(com.alibaba.maxgraph.proto.groot.WriteStoreResponse) StoreWriteGrpc(com.alibaba.maxgraph.proto.groot.StoreWriteGrpc) CompletionCallback(com.alibaba.graphscope.groot.CompletionCallback) StoreWriteClient(com.alibaba.graphscope.groot.ingestor.StoreWriteClient) Test(org.junit.jupiter.api.Test)

Example 2 with WriteStoreResponse

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

the class StoreWriteService method writeStore.

@Override
public void writeStore(WriteStoreRequest request, StreamObserver<WriteStoreResponse> responseObserver) {
    List<StoreDataBatchPb> dataBatchesList = request.getDataBatchesList();
    List<StoreDataBatch> batches = new ArrayList<>(dataBatchesList.size());
    try {
        for (StoreDataBatchPb pb : dataBatchesList) {
            batches.add(StoreDataBatch.parseProto(pb));
        }
        boolean success = writerAgent.writeStore2(batches);
        WriteStoreResponse response = WriteStoreResponse.newBuilder().setSuccess(success).build();
        responseObserver.onNext(response);
        responseObserver.onCompleted();
    } catch (Exception e) {
        responseObserver.onError(e);
    }
}
Also used : WriteStoreResponse(com.alibaba.maxgraph.proto.groot.WriteStoreResponse) StoreDataBatch(com.alibaba.graphscope.groot.operation.StoreDataBatch) ArrayList(java.util.ArrayList) StoreDataBatchPb(com.alibaba.maxgraph.proto.groot.StoreDataBatchPb)

Example 3 with WriteStoreResponse

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

the class StoreWriteClient method writeStore.

public void writeStore(List<StoreDataBatch> storeDataBatches, CompletionCallback<Integer> callback) {
    Builder builder = WriteStoreRequest.newBuilder();
    for (StoreDataBatch storeDataBatch : storeDataBatches) {
        builder.addDataBatches(storeDataBatch.toProto());
    }
    WriteStoreRequest req = builder.build();
    stub.writeStore(req, new StreamObserver<WriteStoreResponse>() {

        @Override
        public void onNext(WriteStoreResponse writeStoreResponse) {
            boolean success = writeStoreResponse.getSuccess();
            if (success) {
                callback.onCompleted(req.getSerializedSize());
            } else {
                onError(new RuntimeException("store buffer is full"));
            }
        }

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

        @Override
        public void onCompleted() {
        }
    });
}
Also used : WriteStoreResponse(com.alibaba.maxgraph.proto.groot.WriteStoreResponse) WriteStoreRequest(com.alibaba.maxgraph.proto.groot.WriteStoreRequest) Builder(com.alibaba.maxgraph.proto.groot.WriteStoreRequest.Builder) StoreDataBatch(com.alibaba.graphscope.groot.operation.StoreDataBatch)

Aggregations

WriteStoreResponse (com.alibaba.maxgraph.proto.groot.WriteStoreResponse)3 StoreDataBatch (com.alibaba.graphscope.groot.operation.StoreDataBatch)2 CompletionCallback (com.alibaba.graphscope.groot.CompletionCallback)1 StoreWriteClient (com.alibaba.graphscope.groot.ingestor.StoreWriteClient)1 StoreDataBatchPb (com.alibaba.maxgraph.proto.groot.StoreDataBatchPb)1 StoreWriteGrpc (com.alibaba.maxgraph.proto.groot.StoreWriteGrpc)1 WriteStoreRequest (com.alibaba.maxgraph.proto.groot.WriteStoreRequest)1 Builder (com.alibaba.maxgraph.proto.groot.WriteStoreRequest.Builder)1 ArrayList (java.util.ArrayList)1 Test (org.junit.jupiter.api.Test)1