use of alluxio.hub.proto.SetPrestoConfDirRequest in project alluxio by Alluxio.
the class ManagerProcessContext method setPrestoConfDir.
/**
* Set Presto configuration directory.
* @param request presto conf directory request
* @return response object
*/
public SetPrestoConfDirResponse.Payload setPrestoConfDir(SetPrestoConfDirRequest request) {
String confDir = request.getPayload().getConfDir();
SetPrestoConfDirResponse.Payload.Builder builder = SetPrestoConfDirResponse.Payload.newBuilder();
List<AlluxioNodeType> nodeTypes = ImmutableList.of(AlluxioNodeType.MASTER, AlluxioNodeType.WORKER);
Map<String, String> map = ImmutableMap.of(PropertyKey.HUB_MANAGER_PRESTO_CONF_PATH.getName(), confDir);
if (nodeTypes.stream().map(type -> execOnHub((client) -> client.setPrestoConfDir(AgentSetPrestoConfRequest.newBuilder().putAllProps(map).build()), type)).allMatch(response -> response.values().stream().allMatch(AgentSetPrestoConfResponse::getSuccess))) {
return builder.setSuccess(true).setConfDir(confDir).setIsDefault(confDir.equals(PropertyKey.HUB_MANAGER_PRESTO_CONF_PATH.getDefaultStringValue())).build();
} else {
String oldConfDir = getUpdatedProps(configurationSetFor(AlluxioNodeType.MASTER)).getString(PropertyKey.HUB_MANAGER_PRESTO_CONF_PATH);
return builder.setSuccess(false).setConfDir(oldConfDir).setIsDefault(oldConfDir.equals(PropertyKey.HUB_MANAGER_PRESTO_CONF_PATH.getDefaultStringValue())).build();
}
}
use of alluxio.hub.proto.SetPrestoConfDirRequest 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);
}
Aggregations