Example usage for org.apache.hadoop.fs FileSystem getDefaultUri

List of usage examples for org.apache.hadoop.fs FileSystem getDefaultUri

Introduction

In this page you can find the example usage for org.apache.hadoop.fs FileSystem getDefaultUri.

Prototype

public static URI getDefaultUri(Configuration conf) 

Source Link

Document

Get the default FileSystem URI from a configuration.

Usage

From source file:org.springframework.data.hadoop.fs.HdfsResourceLoader.java

License:Apache License

/**
 * Constructs a new <code>HdfsResourceLoader</code> instance.
 *
 * @param config Hadoop configuration to use.
 * @param uri Hadoop file system URI.//from   w w  w.j a v a2s.c  om
 * @param user Hadoop user for accessing the file system.
 */
@SuppressWarnings("resource")
public HdfsResourceLoader(Configuration config, URI uri, String user) {
    Assert.notNull(config, "a valid configuration is required");

    impersonatedUser = user;
    internalFS = true;
    FileSystem tempFS = null;
    codecsFactory = new CompressionCodecFactory(config);

    try {
        if (uri == null) {
            uri = FileSystem.getDefaultUri(config);
        }
        tempFS = (StringUtils.hasText(impersonatedUser) ? FileSystem.get(uri, config, impersonatedUser)
                : FileSystem.get(uri, config));
    } catch (Exception ex) {
        tempFS = null;
        throw new IllegalStateException("Cannot create filesystem", ex);
    } finally {
        fs = tempFS;
    }
}

From source file:org.trustedanalytics.metadata.filesystem.HdfsConfigProviderFromEnv.java

License:Apache License

@Override
public URI getDefaultFs() {
    return FileSystem.getDefaultUri(getHadoopConf());
}