Search in sources :

Example 56 with InstancedConfiguration

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

the class MetricsHeartbeatContextTest method testExecutorInitialized.

@Test
public void testExecutorInitialized() {
    InstancedConfiguration conf = ConfigurationTestUtils.defaults();
    conf.set(PropertyKey.MASTER_HOSTNAME, "localhost");
    conf.set(PropertyKey.USER_RPC_RETRY_MAX_DURATION, "1s");
    ClientContext ctx = ClientContext.create(conf);
    MasterInquireClient client = MasterInquireClient.Factory.create(ctx.getClusterConf(), ctx.getUserState());
    // Add and delete a single context, make sure it is non null after adding, and then null after
    // removing
    MetricsHeartbeatContext.addHeartbeat(ctx, client);
    assertNotNull(getInternalExecutor());
    MetricsHeartbeatContext.removeHeartbeat(ctx);
    assertNull(getInternalExecutor());
    // Add a few, then remove and check for the state in between
    MetricsHeartbeatContext.addHeartbeat(ctx, client);
    MetricsHeartbeatContext.addHeartbeat(ctx, client);
    MetricsHeartbeatContext.addHeartbeat(ctx, client);
    MetricsHeartbeatContext.addHeartbeat(ctx, client);
    assertNotNull(getInternalExecutor());
    MetricsHeartbeatContext.removeHeartbeat(ctx);
    assertNotNull(getInternalExecutor());
    MetricsHeartbeatContext.removeHeartbeat(ctx);
    assertNotNull(getInternalExecutor());
    MetricsHeartbeatContext.removeHeartbeat(ctx);
    assertNotNull(getInternalExecutor());
    MetricsHeartbeatContext.removeHeartbeat(ctx);
    assertNull(getInternalExecutor());
}
Also used : MasterInquireClient(alluxio.master.MasterInquireClient) InstancedConfiguration(alluxio.conf.InstancedConfiguration) ClientContext(alluxio.ClientContext) Test(org.junit.Test)

Example 57 with InstancedConfiguration

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

the class GroupMappingServiceTest method group.

/**
 * Tests the {@link GroupMappingService#getGroups(String)} method.
 */
@Test
public void group() throws Throwable {
    String userName = "alluxio-user1";
    InstancedConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults());
    try (Closeable mConfigurationRule = new ConfigurationRule(PropertyKey.SECURITY_GROUP_MAPPING_CLASS, IdentityUserGroupsMapping.class.getName(), conf).toResource()) {
        GroupMappingService groups = GroupMappingService.Factory.get(conf);
        assertNotNull(groups);
        assertNotNull(groups.getGroups(userName));
        assertEquals(groups.getGroups(userName).size(), 1);
        assertEquals(groups.getGroups(userName).get(0), userName);
    }
}
Also used : InstancedConfiguration(alluxio.conf.InstancedConfiguration) Closeable(java.io.Closeable) ConfigurationRule(alluxio.ConfigurationRule) Test(org.junit.Test)

Example 58 with InstancedConfiguration

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

the class ValidateHdfsMount method main.

/**
 * The entrance.
 *
 * @param args command line arguments
 */
public static void main(String[] args) throws Exception {
    CommandLineParser parser = new DefaultParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(OPTIONS, args, true);
    } catch (ParseException e) {
        printHelp(String.format("Failed to parse arguments %s%n", Arrays.toString(args)));
        System.exit(1);
    }
    if (cmd.hasOption(HELP_OPTION.getLongOpt())) {
        printHelp("Showing usage for the command");
        System.exit(0);
    }
    args = cmd.getArgs();
    if (args.length < 1) {
        printHelp("Need at least 1 argument for <hdfsURI>!");
        System.exit(1);
    }
    String ufsPath = args[0];
    InstancedConfiguration conf = InstancedConfiguration.defaults();
    // Merge options from the command line option
    UnderFileSystemConfiguration ufsConf = UnderFileSystemConfiguration.defaults(conf);
    if (cmd.hasOption(READONLY_OPTION.getLongOpt())) {
        ufsConf.setReadOnly(true);
    }
    if (cmd.hasOption(SHARED_OPTION.getLongOpt())) {
        ufsConf.setShared(true);
    }
    if (cmd.hasOption(OPTION_OPTION.getLongOpt())) {
        Properties properties = cmd.getOptionProperties(OPTION_OPTION.getLongOpt());
        ufsConf.merge(properties, Source.MOUNT_OPTION);
        LOG.debug("Options from cmdline: {}", properties);
    }
    ValidationToolRegistry registry = new ValidationToolRegistry(new InstancedConfiguration(ConfigurationUtils.defaults()));
    // Load hdfs validation tool from alluxio lib directory
    registry.refresh();
    Map<Object, Object> configMap = new HashMap<>();
    configMap.put(ValidationConfig.UFS_PATH, ufsPath);
    configMap.put(ValidationConfig.UFS_CONFIG, ufsConf);
    ValidationTool tests = registry.create(ValidationConfig.HDFS_TOOL_TYPE, configMap);
    String result = ValidationTool.toJson(ValidationTool.convertResults(tests.runAllTests()));
    System.out.println(result);
    System.exit(0);
}
Also used : UnderFileSystemConfiguration(alluxio.underfs.UnderFileSystemConfiguration) HashMap(java.util.HashMap) Properties(java.util.Properties) InstancedConfiguration(alluxio.conf.InstancedConfiguration) CommandLine(org.apache.commons.cli.CommandLine) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException) DefaultParser(org.apache.commons.cli.DefaultParser)

Example 59 with InstancedConfiguration

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

the class ValidateConf method main.

/**
 * Console program that validates the configuration.
 *
 * @param args there are no arguments needed
 */
public static void main(String[] args) {
    LOG.info("Validating configuration.");
    try {
        new InstancedConfiguration(ConfigurationUtils.defaults()).validate();
        LOG.info("Configuration is valid.");
    } catch (IllegalStateException e) {
        LOG.error("Configuration is invalid", e);
        System.exit(-1);
    }
    System.exit(0);
}
Also used : InstancedConfiguration(alluxio.conf.InstancedConfiguration)

Example 60 with InstancedConfiguration

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

the class ConfigurationDocGenerator method generate.

/**
 * Generates the configuration docs.
 */
public static void generate() throws IOException {
    Collection<? extends PropertyKey> defaultKeys = PropertyKey.defaultKeys();
    defaultKeys.removeIf(key -> key.isHidden());
    String homeDir = new InstancedConfiguration(ConfigurationUtils.defaults()).getString(PropertyKey.HOME);
    // generate CSV files
    String filePath = PathUtils.concatPath(homeDir, CSV_FILE_DIR);
    writeCSVFile(defaultKeys, filePath);
    // generate YML files
    filePath = PathUtils.concatPath(homeDir, YML_FILE_DIR);
    writeYMLFile(defaultKeys, filePath);
}
Also used : InstancedConfiguration(alluxio.conf.InstancedConfiguration)

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