use of alluxio.hub.proto.AgentSetPrestoConfResponse 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();
}
}
Aggregations