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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations