Search in sources :

Example 1 with BlockMasterInfoField

use of alluxio.wire.BlockMasterInfo.BlockMasterInfoField in project alluxio by Alluxio.

the class SummaryCommand method printBlockMasterInfo.

/**
 * Prints Alluxio block master information.
 */
private void printBlockMasterInfo() throws IOException {
    Set<BlockMasterInfoField> blockMasterInfoFilter = new HashSet<>(Arrays.asList(BlockMasterInfoField.LIVE_WORKER_NUM, BlockMasterInfoField.LOST_WORKER_NUM, BlockMasterInfoField.CAPACITY_BYTES, BlockMasterInfoField.USED_BYTES, BlockMasterInfoField.FREE_BYTES, BlockMasterInfoField.CAPACITY_BYTES_ON_TIERS, BlockMasterInfoField.USED_BYTES_ON_TIERS));
    BlockMasterInfo blockMasterInfo = mBlockMasterClient.getBlockMasterInfo(blockMasterInfoFilter);
    print("Live Workers: " + blockMasterInfo.getLiveWorkerNum());
    print("Lost Workers: " + blockMasterInfo.getLostWorkerNum());
    print("Total Capacity: " + FormatUtils.getSizeFromBytes(blockMasterInfo.getCapacityBytes()));
    mIndentationLevel++;
    Map<String, Long> totalCapacityOnTiers = new TreeMap<>((a, b) -> (FileSystemAdminShellUtils.compareTierNames(a, b)));
    totalCapacityOnTiers.putAll(blockMasterInfo.getCapacityBytesOnTiers());
    for (Map.Entry<String, Long> capacityBytesTier : totalCapacityOnTiers.entrySet()) {
        print("Tier: " + capacityBytesTier.getKey() + "  Size: " + FormatUtils.getSizeFromBytes(capacityBytesTier.getValue()));
    }
    mIndentationLevel--;
    print("Used Capacity: " + FormatUtils.getSizeFromBytes(blockMasterInfo.getUsedBytes()));
    mIndentationLevel++;
    Map<String, Long> usedCapacityOnTiers = new TreeMap<>((a, b) -> (FileSystemAdminShellUtils.compareTierNames(a, b)));
    usedCapacityOnTiers.putAll(blockMasterInfo.getUsedBytesOnTiers());
    for (Map.Entry<String, Long> usedBytesTier : usedCapacityOnTiers.entrySet()) {
        print("Tier: " + usedBytesTier.getKey() + "  Size: " + FormatUtils.getSizeFromBytes(usedBytesTier.getValue()));
    }
    mIndentationLevel--;
    print("Free Capacity: " + FormatUtils.getSizeFromBytes(blockMasterInfo.getFreeBytes()));
}
Also used : BlockMasterInfo(alluxio.wire.BlockMasterInfo) BlockMasterInfoField(alluxio.wire.BlockMasterInfo.BlockMasterInfoField) TreeMap(java.util.TreeMap) TreeMap(java.util.TreeMap) Map(java.util.Map) HashSet(java.util.HashSet)

Aggregations

BlockMasterInfo (alluxio.wire.BlockMasterInfo)1 BlockMasterInfoField (alluxio.wire.BlockMasterInfo.BlockMasterInfoField)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1