use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.
the class FileSystemFactoryTest method uncachedFileSystemDoesntAffectCache.
@Test
public void uncachedFileSystemDoesntAffectCache() throws Exception {
FileSystem fs1 = FileSystem.Factory.get();
InstancedConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults());
conf.set(PropertyKey.USER_WORKER_LIST_REFRESH_INTERVAL, "1sec");
FileSystem fs2 = FileSystem.Factory.create(conf);
fs2.close();
FileSystem fs3 = FileSystem.Factory.get();
assertSame("closing custom config should result in same FileSystem", getDelegatedFileSystem(fs1), getDelegatedFileSystem(fs3));
assertFalse("FileSystem should not be closed", fs1.isClosed());
}
use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.
the class FileSystemFactoryTest method multiMasterFileSystemCacheTest.
@Test
public void multiMasterFileSystemCacheTest() {
try (Closeable p = new SystemPropertyRule(PropertyKey.MASTER_RPC_ADDRESSES.getName(), "192.168.0.1:1234,192.168.0.2:1445,192.168.0.3:9943").toResource()) {
ConfigurationUtils.reloadProperties();
InstancedConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults());
MasterInquireClient.ConnectDetails connectDetails = MasterInquireClient.Factory.getConnectDetails(conf);
// Make sure we have a MultiMaster authority
assertTrue(connectDetails.toAuthority() instanceof MultiMasterAuthority);
fileSystemCacheTest();
} catch (IOException e) {
fail("Unable to set system properties");
}
}
use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.
the class BlockLocationUtilsTest method chooseLocalAccessibleDomainSocket.
@Test
public void chooseLocalAccessibleDomainSocket() throws Exception {
List<BlockWorkerInfo> workers = new ArrayList<>();
workers.add(worker(Constants.GB, "node2", "rack2"));
// create worker info with domain socket path
BlockWorkerInfo workerWithDomainSocket = worker(Constants.GB, "node3", "rack3");
String domainSocketPath = "/tmp/domain/uuid-node3";
workerWithDomainSocket.getNetAddress().setDomainSocketPath(domainSocketPath);
workers.add(workerWithDomainSocket);
// mock NettyUtils
PowerMockito.mockStatic(NettyUtils.class);
when(NettyUtils.isDomainSocketAccessible(eq(workerWithDomainSocket.getNetAddress()), any(AlluxioConfiguration.class))).thenReturn(true);
// choose worker with domain socket accessible ignoring rack
InstancedConfiguration conf = ConfigurationTestUtils.defaults();
conf.set(PropertyKey.WORKER_DATA_SERVER_DOMAIN_SOCKET_AS_UUID, true);
List<WorkerNetAddress> addresses = workers.stream().map(worker -> worker.getNetAddress()).filter(Objects::nonNull).collect(Collectors.toList());
Optional<Pair<WorkerNetAddress, Boolean>> chosen = BlockLocationUtils.nearest(TieredIdentityFactory.fromString("node=node1,rack=rack2", conf), addresses, conf);
assertTrue(chosen.isPresent());
assertTrue(chosen.get().getSecond());
assertEquals(domainSocketPath, chosen.get().getFirst().getDomainSocketPath());
assertEquals("node3", chosen.get().getFirst().getHost());
}
use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.
the class MetricsSystem method constructSourceName.
/**
* Constructs the source name of metrics in this {@link MetricsSystem}.
*/
private static String constructSourceName() {
PropertyKey sourceKey = null;
switch(CommonUtils.PROCESS_TYPE.get()) {
case MASTER:
sourceKey = PropertyKey.MASTER_HOSTNAME;
break;
case WORKER:
sourceKey = PropertyKey.WORKER_HOSTNAME;
break;
case CLIENT:
sourceKey = PropertyKey.USER_APP_ID;
break;
case JOB_MASTER:
sourceKey = PropertyKey.JOB_MASTER_HOSTNAME;
break;
case JOB_WORKER:
sourceKey = PropertyKey.JOB_WORKER_HOSTNAME;
break;
default:
break;
}
AlluxioConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults());
if (sourceKey != null && conf.isSet(sourceKey)) {
return conf.getString(sourceKey);
}
String hostName;
// is not resolved on metrics reporting
try {
hostName = NetworkAddressUtils.getLocalHostMetricName(sResolveTimeout);
} catch (RuntimeException e) {
hostName = "unknown";
LOG.error("Can't find local host name", e);
}
return hostName;
}
use of alluxio.conf.InstancedConfiguration in project alluxio by Alluxio.
the class MkdirsOptionsTest method securityEnabled.
/**
* Tests for building an {@link MkdirsOptions} with a security enabled
* configuration.
*/
@Test
public void securityEnabled() throws IOException {
InstancedConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults());
conf.set(PropertyKey.SECURITY_AUTHENTICATION_TYPE, AuthType.SIMPLE.getAuthName());
conf.set(PropertyKey.SECURITY_LOGIN_USERNAME, "foo");
// Use IdentityUserGroupMapping to map user "foo" to group "foo".
conf.set(PropertyKey.SECURITY_GROUP_MAPPING_CLASS, IdentityUserGroupsMapping.class.getName());
MkdirsOptions options = MkdirsOptions.defaults(mConfiguration);
// Verify the default createParent is true.
assertTrue(options.getCreateParent());
// Verify that the owner and group are not set.
assertNull(options.getOwner());
assertNull(options.getGroup());
String umask = mConfiguration.getString(PropertyKey.SECURITY_AUTHORIZATION_PERMISSION_UMASK);
assertEquals(ModeUtils.applyDirectoryUMask(Mode.defaults(), umask), options.getMode());
}
Aggregations