Search in sources :

Example 1 with InstancedConfiguration

use of alluxio.conf.InstancedConfiguration in project presto by prestodb.

the class AlluxioMetastoreModule method provideCatalogMasterClient.

@Provides
@Inject
TableMasterClient provideCatalogMasterClient(AlluxioHiveMetastoreConfig config) {
    InstancedConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults());
    if (config.isZookeeperEnabled()) {
        conf.set(PropertyKey.ZOOKEEPER_ENABLED, true);
        conf.set(PropertyKey.ZOOKEEPER_ADDRESS, config.getZookeeperAddress());
    } else {
        String address = config.getMasterAddress();
        String[] parts = address.split(":", 2);
        conf.set(PropertyKey.MASTER_HOSTNAME, parts[0]);
        if (parts.length > 1) {
            conf.set(PropertyKey.MASTER_RPC_PORT, parts[1]);
        }
    }
    MasterClientContext context = MasterClientContext.newBuilder(ClientContext.create(conf)).build();
    return new RetryHandlingTableMasterClient(context);
}
Also used : InstancedConfiguration(alluxio.conf.InstancedConfiguration) MasterClientContext(alluxio.master.MasterClientContext) RetryHandlingTableMasterClient(alluxio.client.table.RetryHandlingTableMasterClient) Inject(com.google.inject.Inject) Provides(com.google.inject.Provides)

Example 2 with InstancedConfiguration

use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.

the class HadoopUtils method toAlluxioConf.

/**
 * @param conf Hadoop conf
 * @return Alluxio configuration merged from Hadoop conf
 */
public static AlluxioConfiguration toAlluxioConf(Configuration conf) {
    // Take hadoop configuration to merge to Alluxio configuration
    Map<String, Object> hadoopConfProperties = HadoopConfigurationUtils.getConfigurationFromHadoop(conf);
    AlluxioProperties alluxioProps = ConfigurationUtils.defaults();
    // Merge relevant Hadoop configuration into Alluxio's configuration.
    alluxioProps.merge(hadoopConfProperties, Source.RUNTIME);
    // Creating a new instanced configuration from an AlluxioProperties object isn't expensive.
    return new InstancedConfiguration(alluxioProps);
}
Also used : InstancedConfiguration(alluxio.conf.InstancedConfiguration) AlluxioProperties(alluxio.conf.AlluxioProperties)

Example 3 with InstancedConfiguration

use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.

the class MasterProcess method configureAddress.

private static InetSocketAddress configureAddress(ServiceType service) {
    InstancedConfiguration conf = ServerConfiguration.global();
    int port = NetworkAddressUtils.getPort(service, conf);
    if (!ConfigurationUtils.isHaMode(conf) && port == 0) {
        throw new RuntimeException(String.format("%s port must be nonzero in single-master mode", service));
    }
    if (port == 0) {
        try (ServerSocket s = new ServerSocket(0)) {
            s.setReuseAddress(true);
            conf.set(service.getPortKey(), s.getLocalPort());
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    return NetworkAddressUtils.getBindAddress(service, conf);
}
Also used : InstancedConfiguration(alluxio.conf.InstancedConfiguration) ServerSocket(java.net.ServerSocket) IOException(java.io.IOException)

Example 4 with InstancedConfiguration

use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.

the class GetMasterWorkerAddressTest method getMasterAddress.

/**
 * Tests the
 * {@link NetworkAddressUtils#getConnectAddress(ServiceType, alluxio.conf.AlluxioConfiguration)}
 * method for a master node.
 */
@Test
public void getMasterAddress() {
    InstancedConfiguration conf = ConfigurationTestUtils.defaults();
    // connect host and port
    conf.set(PropertyKey.MASTER_HOSTNAME, "RemoteMaster1");
    conf.set(PropertyKey.MASTER_RPC_PORT, "10000");
    int resolveTimeout = (int) conf.getMs(PropertyKey.NETWORK_HOST_RESOLUTION_TIMEOUT_MS);
    String defaultHostname = NetworkAddressUtils.getLocalHostName(resolveTimeout);
    int defaultPort = Integer.parseInt(PropertyKey.MASTER_RPC_PORT.getDefaultStringValue());
    InetSocketAddress masterAddress = NetworkAddressUtils.getConnectAddress(ServiceType.MASTER_RPC, conf);
    assertEquals(InetSocketAddress.createUnresolved("RemoteMaster1", 10000), masterAddress);
    conf = ConfigurationTestUtils.defaults();
    // port only
    conf.set(PropertyKey.MASTER_RPC_PORT, "20000");
    masterAddress = NetworkAddressUtils.getConnectAddress(ServiceType.MASTER_RPC, conf);
    assertEquals(InetSocketAddress.createUnresolved(defaultHostname, 20000), masterAddress);
    conf = ConfigurationTestUtils.defaults();
    // connect host only
    conf.set(PropertyKey.MASTER_HOSTNAME, "RemoteMaster3");
    masterAddress = NetworkAddressUtils.getConnectAddress(ServiceType.MASTER_RPC, conf);
    assertEquals(InetSocketAddress.createUnresolved("RemoteMaster3", defaultPort), masterAddress);
    conf = ConfigurationTestUtils.defaults();
    // all default
    masterAddress = NetworkAddressUtils.getConnectAddress(ServiceType.MASTER_RPC, conf);
    assertEquals(InetSocketAddress.createUnresolved(defaultHostname, defaultPort), masterAddress);
}
Also used : InstancedConfiguration(alluxio.conf.InstancedConfiguration) InetSocketAddress(java.net.InetSocketAddress) Test(org.junit.Test)

Example 5 with InstancedConfiguration

use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.

the class CommonUtilsTest method getGroups.

/**
 * Test for the {@link CommonUtils#getGroups(String)} and
 * {@link CommonUtils#getPrimaryGroupName(String)} method.
 */
@Test
public void getGroups() throws Throwable {
    InstancedConfiguration conf = ConfigurationTestUtils.defaults();
    String userName = "alluxio-user1";
    String userGroup1 = "alluxio-user1-group1";
    String userGroup2 = "alluxio-user1-group2";
    List<String> userGroups = new ArrayList<>();
    userGroups.add(userGroup1);
    userGroups.add(userGroup2);
    CachedGroupMapping cachedGroupService = PowerMockito.mock(CachedGroupMapping.class);
    PowerMockito.when(cachedGroupService.getGroups(Mockito.anyString())).thenReturn(Lists.newArrayList(userGroup1, userGroup2));
    PowerMockito.mockStatic(GroupMappingService.Factory.class);
    Mockito.when(GroupMappingService.Factory.get(conf)).thenReturn(cachedGroupService);
    List<String> groups = CommonUtils.getGroups(userName, conf);
    assertEquals(Arrays.asList(userGroup1, userGroup2), groups);
    String primaryGroup = CommonUtils.getPrimaryGroupName(userName, conf);
    assertNotNull(primaryGroup);
    assertEquals(userGroup1, primaryGroup);
}
Also used : GroupMappingService(alluxio.security.group.GroupMappingService) InstancedConfiguration(alluxio.conf.InstancedConfiguration) ArrayList(java.util.ArrayList) CachedGroupMapping(alluxio.security.group.CachedGroupMapping) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

InstancedConfiguration (alluxio.conf.InstancedConfiguration)94 Test (org.junit.Test)35 AlluxioConfiguration (alluxio.conf.AlluxioConfiguration)16 AlluxioURI (alluxio.AlluxioURI)14 AlluxioProperties (alluxio.conf.AlluxioProperties)11 ArrayList (java.util.ArrayList)11 IOException (java.io.IOException)10 HashMap (java.util.HashMap)9 BaseHubTest (alluxio.hub.test.BaseHubTest)8 InetSocketAddress (java.net.InetSocketAddress)8 FileSystemShell (alluxio.cli.fs.FileSystemShell)6 FileSystemContext (alluxio.client.file.FileSystemContext)6 HealthCheckClient (alluxio.HealthCheckClient)5 AbstractFileSystemShellTest (alluxio.client.cli.fs.AbstractFileSystemShellTest)5 FileSystemShellUtilsTest (alluxio.client.cli.fs.FileSystemShellUtilsTest)5 MasterInquireClient (alluxio.master.MasterInquireClient)5 Properties (java.util.Properties)5 ParseException (org.apache.commons.cli.ParseException)5 ClientContext (alluxio.ClientContext)4 FileSystem (alluxio.client.file.FileSystem)4