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);
}
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);
}
}
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() {
}
});
}
Aggregations