Search in sources :

Example 11 with RequestStreamObserver

use of alluxio.hub.manager.rpc.observer.RequestStreamObserver in project alluxio by Alluxio.

the class ManagerProcessContext method startSetPrestoConfDirListener.

/**
 * Starts a request stream observer for {@link HostedManagerServiceGrpc} SetPrestoConfDir
 * RPC calls.
 */
public void startSetPrestoConfDirListener() {
    HostedManagerServiceGrpc.HostedManagerServiceStub asyncStub = getHostedAsyncStub();
    RequestStreamObserver requestObserver = new RequestStreamObserver<SetPrestoConfDirRequest, SetPrestoConfDirResponse>() {

        @Override
        public SetPrestoConfDirResponse exec(SetPrestoConfDirRequest req) {
            Preconditions.checkArgument(req.hasPayload());
            Preconditions.checkArgument(req.getPayload().hasConfDir());
            return SetPrestoConfDirResponse.newBuilder().setHubMetadata(mHubMetadata).setPayload(setPrestoConfDir(req)).build();
        }

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

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

Example 12 with RequestStreamObserver

use of alluxio.hub.manager.rpc.observer.RequestStreamObserver in project alluxio by Alluxio.

the class ManagerProcessContext method startPingManagerListener.

/**
 * Starts a request stream observer for {@link HostedManagerServiceGrpc} PingManager RPC calls.
 * The {@link PingManagerResponse}'s {@link HubMetadata} must be the {@link PingManagerRequest}'s
 * {@link HubMetadata} in order for the Hosted Hub to properly track where the ping is coming
 * from. This is to handle scenarios where the cluster id changed due to Alluxio journal formats.
 */
public void startPingManagerListener() {
    HostedManagerServiceGrpc.HostedManagerServiceStub asyncStub = getHostedAsyncStub();
    RequestStreamObserver requestObserver = new RequestStreamObserver<PingManagerRequest, PingManagerResponse>() {

        @Override
        public PingManagerResponse exec(PingManagerRequest req) {
            Preconditions.checkArgument(req.hasHubMetadata());
            Preconditions.checkArgument(req.getHubMetadata().hasClusterId());
            // properly process response
            return PingManagerResponse.newBuilder().setHubMetadata(req.getHubMetadata()).setPayload(PingManagerResponse.Payload.newBuilder().setSuccess(req.getHubMetadata().getClusterId().equals(mHubMetadata.getClusterId()))).build();
        }

        @Override
        public void restart() {
            startPingManagerListener();
            // on ping stream connections - send heartbeat to Hub in-case Hub
            // needs to check if cluster id changed
            alluxioClusterHeartbeat(mAlluxioCluster.toProto());
        }

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

Example 13 with RequestStreamObserver

use of alluxio.hub.manager.rpc.observer.RequestStreamObserver in project alluxio by Alluxio.

the class ManagerProcessContext method startDetectPrestoListener.

/**
 * Starts a request stream observer for {@link HostedManagerServiceGrpc} DetectPresto RPC calls.
 */
public void startDetectPrestoListener() {
    HostedManagerServiceGrpc.HostedManagerServiceStub asyncStub = getHostedAsyncStub();
    RequestStreamObserver requestObserver = new RequestStreamObserver<DetectPrestoRequest, DetectPrestoResponse>() {

        @Override
        public DetectPrestoResponse exec(DetectPrestoRequest req) {
            return DetectPrestoResponse.newBuilder().setHubMetadata(mHubMetadata).setPayload(detectPresto(req)).build();
        }

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

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

Example 14 with RequestStreamObserver

use of alluxio.hub.manager.rpc.observer.RequestStreamObserver in project alluxio by Alluxio.

the class ManagerProcessContext method startListMountPointsListener.

/**
 * Starts a request stream observer for {@link HostedManagerServiceGrpc} ListMountPoints
 * RPC calls.
 */
public void startListMountPointsListener() {
    HostedManagerServiceGrpc.HostedManagerServiceStub asyncStub = getHostedAsyncStub();
    RequestStreamObserver requestObserver = new RequestStreamObserver<ListMountPointRequest, ListMountPointResponse>() {

        @Override
        public ListMountPointResponse exec(ListMountPointRequest req) {
            ListMountPointResponse.Payload p = getMountPointList();
            return ListMountPointResponse.newBuilder().setHubMetadata(mHubMetadata).setPayload(p).build();
        }

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

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

Example 15 with RequestStreamObserver

use of alluxio.hub.manager.rpc.observer.RequestStreamObserver in project alluxio by Alluxio.

the class ManagerProcessContext method startRemoveFileListener.

/**
 * Starts a request stream observer for {@link HostedManagerServiceGrpc} RemoveFile RPC calls.
 */
public void startRemoveFileListener() {
    HostedManagerServiceGrpc.HostedManagerServiceStub asyncStub = getHostedAsyncStub();
    RequestStreamObserver requestObserver = new RequestStreamObserver<RemoveFileRequest, RemoveFileResponse>() {

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

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

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

Aggregations

RequestStreamObserver (alluxio.hub.manager.rpc.observer.RequestStreamObserver)15 HostedManagerServiceGrpc (alluxio.hub.proto.HostedManagerServiceGrpc)15 ByteString (com.google.protobuf.ByteString)15 AgentDetectPrestoRequest (alluxio.hub.proto.AgentDetectPrestoRequest)1 AgentDetectPrestoResponse (alluxio.hub.proto.AgentDetectPrestoResponse)1 AgentGetConfigurationSetRequest (alluxio.hub.proto.AgentGetConfigurationSetRequest)1 AgentListCatalogRequest (alluxio.hub.proto.AgentListCatalogRequest)1 AgentListFileRequest (alluxio.hub.proto.AgentListFileRequest)1 AgentProcessStatusChangeResponse (alluxio.hub.proto.AgentProcessStatusChangeResponse)1 AgentRemoveFileRequest (alluxio.hub.proto.AgentRemoveFileRequest)1 AgentRemoveFileResponse (alluxio.hub.proto.AgentRemoveFileResponse)1 AgentWriteConfigurationSetRequest (alluxio.hub.proto.AgentWriteConfigurationSetRequest)1 AgentWriteConfigurationSetResponse (alluxio.hub.proto.AgentWriteConfigurationSetResponse)1 AlluxioConfigurationSet (alluxio.hub.proto.AlluxioConfigurationSet)1 ApplyMountPointRequest (alluxio.hub.proto.ApplyMountPointRequest)1 ApplyMountPointResponse (alluxio.hub.proto.ApplyMountPointResponse)1 DeleteMountPointRequest (alluxio.hub.proto.DeleteMountPointRequest)1 DeleteMountPointResponse (alluxio.hub.proto.DeleteMountPointResponse)1 DetectPrestoRequest (alluxio.hub.proto.DetectPrestoRequest)1 DetectPrestoResponse (alluxio.hub.proto.DetectPrestoResponse)1