Search in sources :

Example 1 with AlluxioConfigurationSet

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;
}
Also used : AlluxioConfigurationSet(alluxio.hub.proto.AlluxioConfigurationSet)

Example 2 with AlluxioConfigurationSet

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);
}
Also used : HubNodeAddress(alluxio.hub.proto.HubNodeAddress) AlluxioConfigurationSet(alluxio.hub.proto.AlluxioConfigurationSet)

Example 3 with AlluxioConfigurationSet

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());
}
Also used : AgentGetConfigurationSetRequest(alluxio.hub.proto.AgentGetConfigurationSetRequest) AlluxioConfigurationSet(alluxio.hub.proto.AlluxioConfigurationSet) Test(org.junit.Test) BaseHubTest(alluxio.hub.test.BaseHubTest)

Example 4 with AlluxioConfigurationSet

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);
}
Also used : AgentWriteConfigurationSetRequest(alluxio.hub.proto.AgentWriteConfigurationSetRequest) AlluxioConfigurationSet(alluxio.hub.proto.AlluxioConfigurationSet) Test(org.junit.Test) BaseHubTest(alluxio.hub.test.BaseHubTest)

Example 5 with AlluxioConfigurationSet

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;
}
Also used : Path(java.nio.file.Path) StringWriter(java.io.StringWriter) ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException) Properties(java.util.Properties) ConfigurationEditor(alluxio.hub.agent.util.conf.ConfigurationEditor) TimeoutException(java.util.concurrent.TimeoutException) IOException(java.io.IOException) AlluxioConfigurationSet(alluxio.hub.proto.AlluxioConfigurationSet)

Aggregations

AlluxioConfigurationSet (alluxio.hub.proto.AlluxioConfigurationSet)8 Test (org.junit.Test)4 AgentGetConfigurationSetRequest (alluxio.hub.proto.AgentGetConfigurationSetRequest)2 BaseHubTest (alluxio.hub.test.BaseHubTest)2 ConfigurationEditor (alluxio.hub.agent.util.conf.ConfigurationEditor)1 RequestStreamObserver (alluxio.hub.manager.rpc.observer.RequestStreamObserver)1 AgentWriteConfigurationSetRequest (alluxio.hub.proto.AgentWriteConfigurationSetRequest)1 GetConfigurationSetRequest (alluxio.hub.proto.GetConfigurationSetRequest)1 GetConfigurationSetResponse (alluxio.hub.proto.GetConfigurationSetResponse)1 HostedManagerServiceGrpc (alluxio.hub.proto.HostedManagerServiceGrpc)1 HubNodeAddress (alluxio.hub.proto.HubNodeAddress)1 ByteString (com.google.protobuf.ByteString)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 Path (java.nio.file.Path)1 Properties (java.util.Properties)1 TimeoutException (java.util.concurrent.TimeoutException)1