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