Search in sources :

Example 1 with PingManagerRequest

use of alluxio.hub.proto.PingManagerRequest 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)

Aggregations

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