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

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

Introduction

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

Prototype

Log LOG

To view the source code for org.apache.hadoop.fs FileSystem LOG.

Click Source Link

Document

This log is widely used in the org.apache.hadoop.fs code and tests, so must be considered something to only be changed with care.

Usage

From source file:com.trace.hadoop.TestDFSRename.java

License:Apache License

void list(FileSystem fs, String name) throws IOException {
    FileSystem.LOG.info("\n\n" + name);
    for (FileStatus s : fs.listStatus(dir)) {
        FileSystem.LOG.info("" + s.getPath());
    }/*from  ww w  .j  av  a2  s .c  o m*/
}

From source file:org.smartfrog.services.hadoop.operations.utils.DfsUtils.java

License:Open Source License

/**
 * This loads but does not initialise a filesystem.
 *
 * @param conf configuration//  ww w  .  j av a2  s  . co  m
 * @param uri URI of the filesystem
 * @return an instance of that filesystem
 * @throws IOException if there is no filesystem of that type
 */
public static FileSystem loadFS(final Configuration conf, final URI uri) throws IOException {
    String scheme = uri.getScheme();
    String authority = uri.getAuthority();

    if (scheme == null) { // no scheme: use default FS
        return FileSystem.get(conf);
    }

    if (authority == null) { // no authority
        URI defaultUri = FileSystem.getDefaultUri(conf);
        if (scheme.equals(defaultUri.getScheme()) // if scheme matches default
                && defaultUri.getAuthority() != null) { // & default has authority
            return loadFS(conf, defaultUri); // return default
        }
    }

    String filesystemProp = "fs." + uri.getScheme() + ".impl";
    String implclass = conf.get(filesystemProp);
    Class<?> clazz = conf.getClass(filesystemProp, null);
    FileSystem.LOG.debug("Creating filesystem for " + uri + " implementation is implclass");
    if (clazz == null) {
        throw new IOException(
                "No FileSystem for scheme: " + uri.getScheme() + " and configuration option " + filesystemProp);
    }
    try {
        FileSystem fs = (FileSystem) ReflectionUtils.newInstance(clazz, conf);
        return fs;
    } catch (RuntimeException e) {
        throw new IOException(
                "Failed to create an instance of " + implclass + " to process " + uri.getScheme() + " : " + e,
                e);
    }
}