use of alluxio.hub.proto.AlluxioConfigurationSet in project alluxio by Alluxio.
the class ManagerProcessContext method getFileSystem.
/**
* Get an instance of the alluxio file system.
*
* @return alluxio file system or null
*/
public FileSystem getFileSystem() {
if (mFileSystem == null) {
AlluxioConfigurationSet configSet = configurationSetFor(AlluxioNodeType.MASTER);
updateFileSystemClient(configSet);
}
return mFileSystem;
}
use of alluxio.hub.proto.AlluxioConfigurationSet in project alluxio by Alluxio.
the class ManagerProcessContext method configurationSetFor.
/**
* Gets the configuration for a given alluxio node type.
*
* @param type the type of node to get the configuration from
* @return a mapping of responses from each hub agent the action was executed on to the
* agent's address
*/
public AlluxioConfigurationSet configurationSetFor(AlluxioNodeType type) {
Set<HubNodeAddress> nodes = mHubCluster.nodesFromAlluxio(mAlluxioCluster, type);
Iterator<HubNodeAddress> iter = nodes.iterator();
if (!iter.hasNext()) {
throw new IllegalStateException("No nodes of type " + type + " to get configuration in the " + "cluster.");
}
HubNodeAddress addr = iter.next();
Map<HubNodeAddress, AlluxioConfigurationSet> confSet = mHubCluster.exec(Collections.singleton(addr), mConf, (client) -> client.getConfigurationSet(AgentGetConfigurationSetRequest.newBuilder().build()).getConfSet(), mSvc);
return confSet.get(addr);
}
use of alluxio.hub.proto.AlluxioConfigurationSet in project alluxio by Alluxio.
the class AgentManagerServiceTest method testGetConf.
@Test
public void testGetConf() throws Exception {
AlluxioConfigurationSet s = AlluxioConfigurationSet.newBuilder().setSiteProperties("testProps").setAlluxioEnv("testEnv").build();
doReturn(s).when(mContext).getConf();
AgentGetConfigurationSetRequest r = AgentGetConfigurationSetRequest.newBuilder().build();
assertEquals(s, mClient.getConfigurationSet(r).getConfSet());
}
use of alluxio.hub.proto.AlluxioConfigurationSet in project alluxio by Alluxio.
the class AgentManagerServiceTest method testWriteConf.
@Test
public void testWriteConf() throws Exception {
AlluxioConfigurationSet s = AlluxioConfigurationSet.newBuilder().setSiteProperties("testProps").setAlluxioEnv("testEnv").build();
doNothing().when(mContext).writeConf(ArgumentMatchers.any());
AgentWriteConfigurationSetRequest r = AgentWriteConfigurationSetRequest.newBuilder().setConfSet(s).build();
mClient.writeConfigurationSet(r);
verify(mContext).writeConf(s);
}
use of alluxio.hub.proto.AlluxioConfigurationSet 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