Search in sources :

Example 6 with UnderFileSystemConfiguration

use of alluxio.underfs.UnderFileSystemConfiguration in project alluxio by Alluxio.

the class HdfsUnderFileSystemTest method before.

@Before
public final void before() throws Exception {
    UnderFileSystemConfiguration conf = UnderFileSystemConfiguration.defaults(ConfigurationTestUtils.defaults()).createMountSpecificConf(ImmutableMap.of("hadoop.security.group.mapping", "org.apache.hadoop.security.ShellBasedUnixGroupsMapping", "fs.hdfs.impl", PropertyKey.UNDERFS_HDFS_IMPL.getDefaultStringValue()));
    mHdfsUnderFileSystem = HdfsUnderFileSystem.createInstance(new AlluxioURI(mTemporaryFolder.getRoot().getAbsolutePath()), conf);
}
Also used : UnderFileSystemConfiguration(alluxio.underfs.UnderFileSystemConfiguration) AlluxioURI(alluxio.AlluxioURI) Before(org.junit.Before)

Example 7 with UnderFileSystemConfiguration

use of alluxio.underfs.UnderFileSystemConfiguration in project alluxio by Alluxio.

the class UfsJournalConfTest method emptyConfiguration.

@Test
public void emptyConfiguration() throws Exception {
    UnderFileSystemConfiguration conf = UfsJournal.getJournalUfsConf();
    Assert.assertTrue(conf.getMountSpecificConf().isEmpty());
}
Also used : UnderFileSystemConfiguration(alluxio.underfs.UnderFileSystemConfiguration) Test(org.junit.Test)

Example 8 with UnderFileSystemConfiguration

use of alluxio.underfs.UnderFileSystemConfiguration in project alluxio by Alluxio.

the class AbfsUnderFileSystem method createAbfsConfiguration.

private static Configuration createAbfsConfiguration(UnderFileSystemConfiguration conf) {
    Configuration abfsConf = HdfsUnderFileSystem.createConfiguration(conf);
    boolean sharedKey = false;
    for (Map.Entry<String, Object> entry : conf.toMap().entrySet()) {
        String key = entry.getKey();
        Object value = entry.getValue();
        if (PropertyKey.Template.UNDERFS_ABFS_ACCOUNT_KEY.matches(key)) {
            abfsConf.set(key, (String) value);
            final String authTypeKey = key.replace(".key", ".auth.type");
            abfsConf.set(authTypeKey, "SharedKey");
            sharedKey = true;
            break;
        }
    }
    if (!sharedKey) {
        if (conf.isSet(PropertyKey.ABFS_CLIENT_ENDPOINT) && conf.isSet(PropertyKey.ABFS_CLIENT_ID) && conf.isSet(PropertyKey.ABFS_CLIENT_SECRET)) {
            abfsConf.set("fs.azure.account.auth.type", "OAuth");
            abfsConf.set("fs.azure.account.oauth.provider.type", "org.apache.hadoop.fs.azurebfs.oauth2.ClientCredsTokenProvider");
            abfsConf.set(PropertyKey.ABFS_CLIENT_ENDPOINT.getName(), conf.getString(PropertyKey.ABFS_CLIENT_ENDPOINT));
            abfsConf.set(PropertyKey.ABFS_CLIENT_ID.getName(), conf.getString(PropertyKey.ABFS_CLIENT_ID));
            abfsConf.set(PropertyKey.ABFS_CLIENT_SECRET.getName(), conf.getString(PropertyKey.ABFS_CLIENT_SECRET));
        }
    }
    return abfsConf;
}
Also used : UnderFileSystemConfiguration(alluxio.underfs.UnderFileSystemConfiguration) Configuration(org.apache.hadoop.conf.Configuration) Map(java.util.Map)

Example 9 with UnderFileSystemConfiguration

use of alluxio.underfs.UnderFileSystemConfiguration in project alluxio by Alluxio.

the class WasbUnderFileSystem method createConfiguration.

/**
 * Prepares the configuration for this Wasb as an HDFS configuration.
 *
 * @param conf the configuration for this UFS
 * @param isSecure whether blob storage is using https
 * @return the created configuration
 */
public static Configuration createConfiguration(UnderFileSystemConfiguration conf, Boolean isSecure) {
    Configuration wasbConf = HdfsUnderFileSystem.createConfiguration(conf);
    for (Map.Entry<String, Object> entry : conf.toMap().entrySet()) {
        String key = entry.getKey();
        Object value = entry.getValue();
        if (PropertyKey.Template.UNDERFS_AZURE_ACCOUNT_KEY.matches(key)) {
            wasbConf.set(key, (String) value);
        }
    }
    if (isSecure) {
        wasbConf.set("fs.AbstractFileSystem.wasbs.impl", "org.apache.hadoop.fs.azure.Wasbs");
        wasbConf.set("fs.wasbs.impl", "org.apache.hadoop.fs.azure.NativeAzureFileSystem");
    } else {
        wasbConf.set("fs.AbstractFileSystem.wasb.impl", "org.apache.hadoop.fs.azure.Wasb");
        wasbConf.set("fs.wasb.impl", "org.apache.hadoop.fs.azure.NativeAzureFileSystem");
    }
    return wasbConf;
}
Also used : UnderFileSystemConfiguration(alluxio.underfs.UnderFileSystemConfiguration) Configuration(org.apache.hadoop.conf.Configuration) Map(java.util.Map)

Example 10 with UnderFileSystemConfiguration

use of alluxio.underfs.UnderFileSystemConfiguration 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)

Aggregations

UnderFileSystemConfiguration (alluxio.underfs.UnderFileSystemConfiguration)24 Test (org.junit.Test)8 AlluxioURI (alluxio.AlluxioURI)5 PropertyKey (alluxio.conf.PropertyKey)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 ConfigurationRule (alluxio.ConfigurationRule)4 InstancedConfiguration (alluxio.conf.InstancedConfiguration)4 UnderFileSystem (alluxio.underfs.UnderFileSystem)4 Closeable (java.io.Closeable)4 IOException (java.io.IOException)3 Configuration (org.apache.hadoop.conf.Configuration)3 ValidationUtils (alluxio.cli.ValidationUtils)2 IOTaskResult (alluxio.stress.worker.IOTaskResult)2 UfsIOParameters (alluxio.stress.worker.UfsIOParameters)2 ObjectUnderFileSystem (alluxio.underfs.ObjectUnderFileSystem)2 UnderFileSystemFactory (alluxio.underfs.UnderFileSystemFactory)2 CommonUtils (alluxio.util.CommonUtils)2 FormatUtils (alluxio.util.FormatUtils)2 ExecutorServiceFactories (alluxio.util.executor.ExecutorServiceFactories)2