use of alluxio.hub.proto.AgentWriteConfigurationSetResponse in project alluxio by Alluxio.
the class ManagerProcessContext method updateConfigurationFor.
/**
* Updates the configuration for a set of Alluxio nodes.
*
* @param type the type of node to write the configuration to
* @param conf the configuration to write
* @return a set of the nodes which had their configuration updated
*/
public Set<HubNodeAddress> updateConfigurationFor(AlluxioNodeType type, AlluxioConfigurationSet conf) {
Set<HubNodeAddress> nodes = mHubCluster.nodesFromAlluxio(mAlluxioCluster, type);
Map<HubNodeAddress, AgentWriteConfigurationSetResponse> confSet = mHubCluster.exec(nodes, mConf, (client) -> client.writeConfigurationSet(AgentWriteConfigurationSetRequest.newBuilder().setConfSet(conf).build()), mSvc);
// update the file system client to reflect the new conf
if (type.equals(AlluxioNodeType.MASTER)) {
updateFileSystemClient(conf);
}
// if running in K8s, update configmap
if (mK8sConfig != null && (type.equals(AlluxioNodeType.MASTER) || type.equals(AlluxioNodeType.ALL))) {
// We maintain a single configMap for all pods, so the config set is symmetric
LOG.info("Persist configuration to K8s configMap {}", mK8sConfigMapName);
try (KubernetesClient client = new DefaultKubernetesClient(mK8sConfig)) {
String namespace = client.getNamespace();
if (namespace == null) {
LOG.info("Use K8s default namespace ");
namespace = "default";
}
// Update configMap
ConfigMap existingConfig = client.configMaps().inNamespace(namespace).withName(mK8sConfigMapName).get();
if (existingConfig != null) {
ConfigMapBuilder builder = new ConfigMapBuilder().withMetadata(existingConfig.getMetadata()).withData(existingConfig.getData());
// Replace log4 properties
builder.addToData(K8S_CONFIG_MAP_ENV_LOG4J, conf.getLog4JProperties());
// Replace site properties
builder.addToData(K8S_CONFIG_MAP_ENV_SITE, conf.getSiteProperties());
// Replace environment variables
for (Map.Entry<String, String> entry : HubUtil.getEnvVarsFromFile(conf.getAlluxioEnv(), LOG).entrySet()) {
builder.addToData(entry.getKey(), entry.getValue());
}
// Write config map
client.configMaps().inNamespace(namespace).withName(mK8sConfigMapName).replace(builder.build());
LOG.info("Updated K8s configMap {}", mK8sConfigMapName);
}
} catch (Exception e) {
LOG.error("Unable to persist configuration to K8s configMap {}", mK8sConfigMapName, e);
}
}
return confSet.keySet();
}
Aggregations