Example usage for org.apache.hadoop.hdfs DistributedFileSystem getStatus

List of usage examples for org.apache.hadoop.hdfs DistributedFileSystem getStatus

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs DistributedFileSystem getStatus.

Prototype

public FsStatus getStatus() throws IOException 

Source Link

Document

Returns a status object describing the use and capacity of the filesystem.

Usage

From source file:org.apache.crunchts.CrunchTSApp.java

License:Apache License

/**
 * Gives a report for a time series bucket.
 *
 * @exception IOException if the tsbucket does not exist.
 *//* w  w w  .ja  va2 s. c om*/
public void report(String tsbFilePath) throws IOException {

    System.out.println("Time-Series-Bucket report (TSBr) is comming soon ...");

    System.out.println("> path: " + tsbFilePath);

    if (fs instanceof DistributedFileSystem) {

        DistributedFileSystem dfs = (DistributedFileSystem) fs;
        FsStatus ds = dfs.getStatus();

        long capacity = ds.getCapacity();
        long used = ds.getUsed();
        long remaining = ds.getRemaining();
        long presentCapacity = used + remaining;

        System.out.println("FS Configured Capacity: " + capacity + " (" + StringUtils.byteDesc(capacity) + ")");
        System.out.println(
                "FS Present Capacity: " + presentCapacity + " (" + StringUtils.byteDesc(presentCapacity) + ")");
        System.out.println("DFS Remaining: " + remaining + " (" + StringUtils.byteDesc(remaining) + ")");
        System.out.println("DFS Used: " + used + " (" + StringUtils.byteDesc(used) + ")");
        System.out.println(
                "DFS Used%: " + StringUtils.limitDecimalTo2(((1.0 * used) / presentCapacity) * 100) + "%");
    }
}