use of alluxio.hub.agent.util.conf.ConfigurationEditor in project alluxio by Alluxio.
the class AgentProcessContext method updateConf.
/**
* Update alluxio site property values.
* @param props properties to be updated
* @return true if property is updated
*/
public boolean updateConf(Properties props) {
Properties fileProps = null;
if (!validateConf(props)) {
return false;
}
try {
fileProps = ConfigurationUtils.loadProperties(new ByteArrayInputStream(getConf().getSiteProperties().getBytes()));
} catch (Exception e) {
LOG.info("Exception when reading old configuration " + e);
}
if (fileProps == null) {
fileProps = props;
} else {
fileProps.putAll(props);
}
try (StringWriter stringWriter = new StringWriter()) {
fileProps.store(stringWriter, "Updated Alluxio site properties generated by Alluxio hub agent");
AlluxioConfigurationSet conf = AlluxioConfigurationSet.newBuilder().setSiteProperties(stringWriter.toString()).build();
Path path = Paths.get(mConf.getString(PropertyKey.CONF_DIR), ConfigurationEditor.SITE_PROPERTIES);
if (Files.notExists(path)) {
Files.createFile(path);
}
new ConfigurationEditor(mConf.getString(PropertyKey.SITE_CONF_DIR)).writeConf(conf);
} catch (IOException e) {
return false;
}
return true;
}
Aggregations