Example usage for org.apache.hadoop.fs FsStatus getRemaining

List of usage examples for org.apache.hadoop.fs FsStatus getRemaining

Introduction

In this page you can find the example usage for org.apache.hadoop.fs FsStatus getRemaining.

Prototype

public long getRemaining() 

Source Link

Document

Return the number of remaining bytes on the file system

Usage

From source file:co.cask.cdap.operations.hdfs.HDFSStorage.java

License:Apache License

@Override
public synchronized void collect() throws IOException {
    try (DistributedFileSystem dfs = createDFS()) {
        if (dfs == null) {
            return;
        }/*from w  ww  . j a  v a 2s.  co  m*/
        FsStatus status = dfs.getStatus();
        this.totalBytes = status.getCapacity();
        this.availableBytes = status.getRemaining();
        this.usedBytes = status.getUsed();
        this.missingBlocks = dfs.getMissingBlocksCount();
        this.underReplicatedBlocks = dfs.getUnderReplicatedBlocksCount();
        this.corruptBlocks = dfs.getCorruptBlocksCount();
    }
}

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.
 *//*ww  w.j  a va  2  s.co  m*/
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) + "%");
    }
}