Search in sources :

Example 1 with UploadFileRequest

use of alluxio.hub.proto.UploadFileRequest in project alluxio by Alluxio.

the class ManagerProcessContext method startUploadFileListener.

/**
 * Starts a request stream observer for {@link HostedManagerServiceGrpc} UploadFile RPC calls.
 */
public void startUploadFileListener() {
    HostedManagerServiceGrpc.HostedManagerServiceStub asyncStub = getHostedAsyncStub();
    RequestStreamObserver requestObserver = new RequestStreamObserver<UploadFileRequest, UploadFileResponse>() {

        @Override
        public UploadFileResponse exec(UploadFileRequest req) {
            boolean success = uploadFile(req.getPayload().getFileList());
            return UploadFileResponse.newBuilder().setHubMetadata(mHubMetadata).setPayload(UploadFileResponse.Payload.newBuilder().setSuccess(success)).build();
        }

        @Override
        public void restart() {
            startUploadFileListener();
        }

        @Override
        public void handleError(String message, Throwable t) {
            handleStatusRuntimeException(message, t);
        }
    };
    StreamObserver<UploadFileResponse> responseObserver = asyncStub.uploadFile(requestObserver);
    requestObserver.start(responseObserver, UploadFileResponse.newBuilder().setHubMetadata(mHubMetadata).build());
    LOG.info("Started UploadFile async listener", asyncStub);
}
Also used : UploadFileRequest(alluxio.hub.proto.UploadFileRequest) RequestStreamObserver(alluxio.hub.manager.rpc.observer.RequestStreamObserver) HostedManagerServiceGrpc(alluxio.hub.proto.HostedManagerServiceGrpc) ByteString(com.google.protobuf.ByteString) UploadFileResponse(alluxio.hub.proto.UploadFileResponse)

Aggregations

RequestStreamObserver (alluxio.hub.manager.rpc.observer.RequestStreamObserver)1 HostedManagerServiceGrpc (alluxio.hub.proto.HostedManagerServiceGrpc)1 UploadFileRequest (alluxio.hub.proto.UploadFileRequest)1 UploadFileResponse (alluxio.hub.proto.UploadFileResponse)1 ByteString (com.google.protobuf.ByteString)1