Search in sources :

Example 16 with InstancedConfiguration

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());
}
Also used : InstancedConfiguration(alluxio.conf.InstancedConfiguration) Test(org.junit.Test)

Example 17 with InstancedConfiguration

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");
    }
}
Also used : MasterInquireClient(alluxio.master.MasterInquireClient) InstancedConfiguration(alluxio.conf.InstancedConfiguration) MultiMasterAuthority(alluxio.uri.MultiMasterAuthority) SystemPropertyRule(alluxio.SystemPropertyRule) Closeable(java.io.Closeable) IOException(java.io.IOException) Test(org.junit.Test)

Example 18 with InstancedConfiguration

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());
}
Also used : InstancedConfiguration(alluxio.conf.InstancedConfiguration) WorkerNetAddress(alluxio.wire.WorkerNetAddress) BlockWorkerInfo(alluxio.client.block.BlockWorkerInfo) ArrayList(java.util.ArrayList) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration) Pair(alluxio.collections.Pair) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 19 with InstancedConfiguration

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;
}
Also used : InstancedConfiguration(alluxio.conf.InstancedConfiguration) PropertyKey(alluxio.conf.PropertyKey) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration)

Example 20 with InstancedConfiguration

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());
}
Also used : InstancedConfiguration(alluxio.conf.InstancedConfiguration) IdentityUserGroupsMapping(alluxio.security.group.provider.IdentityUserGroupsMapping) 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