Example usage for org.apache.hadoop.util StringUtils limitDecimalTo2

List of usage examples for org.apache.hadoop.util StringUtils limitDecimalTo2

Introduction

In this page you can find the example usage for org.apache.hadoop.util StringUtils limitDecimalTo2.

Prototype

@Deprecated
public static String limitDecimalTo2(double d) 

Source Link

Usage

From source file:com.cloudera.crunchts.CrunchTSApp.java

License:Apache License

/**
 * Gives a report for a time series bucket.
 *
 * @exception IOException if the tsbucket does not exist.
 *///from  www.j ava  2s  . 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;

        long capacity = dfs.getDiskStatus().getCapacity();
        long used = dfs.getDiskStatus().getDfsUsed();
        long remaining = dfs.getDiskStatus().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) + "%");
    }
}

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.
 *///from w  ww .j a  va2 s  .  c  o 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) + "%");
    }
}