Example usage for org.apache.hadoop.fs HarFileSystem listStatus

List of usage examples for org.apache.hadoop.fs HarFileSystem listStatus

Introduction

In this page you can find the example usage for org.apache.hadoop.fs HarFileSystem listStatus.

Prototype

@Override
public FileStatus[] listStatus(Path f) throws IOException 

Source Link

Document

liststatus returns the children of a directory after looking up the index files.

Usage

From source file:com.github.dongjinleekr.hadoop.examples.DistributedCacheExample.java

License:Apache License

public static void printCachePath(Configuration conf) throws IOException, URISyntaxException {
    FileSystem fs = FileSystem.get(conf);
    URI[] archives = DistributedCache.getCacheArchives(conf);

    for (URI archive : archives) {
        HarFileSystem hfs = new HarFileSystem();
        String cacheUri = String.format("har://hdfs-%s:%d%s", fs.getUri().getHost(), fs.getUri().getPort(),
                archive.toString());//from   w  w  w. jav  a2  s .  c o  m
        System.out.println(cacheUri);

        hfs.initialize(new URI(cacheUri), conf);

        FileStatus root = hfs.listStatus(new Path("."))[0];
        FileStatus[] children = hfs.listStatus(root.getPath());

        for (FileStatus child : children) {
            System.out.println(child.getPath());
        }

        IOUtils.closeStream(hfs);
    }
}