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

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

Introduction

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

Prototype

public void initialize(URI name, Configuration conf) throws IOException 

Source Link

Document

Initialize a FileSystem.

Usage

From source file:org.smartfrog.services.hadoop.junitmr.AbstractHadoopTest.java

License:Open Source License

/**
 * Create a DFS client instance from a given URL; initialize it from the configuration
 *
 * @param filesystemURL the URL of the filesystem
 * @return a filesystem client// w w  w  .ja  v a 2s  .c o m
 * @throws IOException if things go wrong
 */
public FileSystem createFileSystem(String filesystemURL) throws IOException {
    Configuration conf = getConfiguration();
    URI uri;
    try {
        uri = new URI(filesystemURL);
    } catch (URISyntaxException e) {
        throw new IOException("Invalid " + FS_DEFAULT_NAME + " URI: " + filesystemURL + ":" + e);
    }
    FileSystem dfs = FileSystem.get(uri, conf);
    dfs.initialize(uri, conf);
    return dfs;
}

From source file:voldemort.store.readonly.mr.utils.HadoopUtils.java

License:Apache License

public static FileSystem getFileSystem(String hdfsUrl, boolean isLocal) throws IOException {
    // Initialize fs
    FileSystem fs;
    if (isLocal) {
        fs = FileSystem.getLocal(new Configuration());
    } else {/* w  w  w . j  a  v a 2s. co  m*/
        fs = new DistributedFileSystem();
        try {
            fs.initialize(new URI(hdfsUrl), new Configuration());
        } catch (URISyntaxException e) {
            throw new IllegalArgumentException(e);
        }
    }
    return fs;
}