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