@Override protected void processPath(PathData item) throws IOException { if (ViewFileSystemUtil.isViewFileSystem(item.fs)) { ViewFileSystem viewFileSystem = (ViewFileSystem) item.fs; Map<ViewFileSystem.MountPoint, FsStatus> fsStatusMap = ViewFileSystemUtil.getStatus(viewFileSystem, item.path); for (Map.Entry<ViewFileSystem.MountPoint, FsStatus> entry : fsStatusMap.entrySet()) { ViewFileSystem.MountPoint viewFsMountPoint = entry.getKey(); FsStatus fsStatus = entry.getValue(); // Add the viewfs mount point status to report URI[] mountPointFileSystemURIs = viewFsMountPoint.getTargetFileSystemURIs(); // Since LinkMerge is not supported yet, we // should ideally see mountPointFileSystemURIs // array with only one element. addToUsagesTable(mountPointFileSystemURIs[0], fsStatus, viewFsMountPoint.getMountedOnPath().toString()); } } else { // Hide the columns specific to ViewFileSystem getUsagesTable().setColumnHide(5, true); FsStatus fsStatus = item.fs.getStatus(item.path); addToUsagesTable(item.fs.getUri(), fsStatus, "/"); } }
/** * Add a new row to the usages table for the given FileSystem URI. * * @param uri - FileSystem URI * @param fsStatus - FileSystem status * @param mountedOnPath - FileSystem mounted on path */ private void addToUsagesTable(URI uri, FsStatus fsStatus, String mountedOnPath) { long size = fsStatus.getCapacity(); long used = fsStatus.getUsed(); long free = fsStatus.getRemaining(); getUsagesTable().addRow( uri, formatSize(size), formatSize(used), formatSize(free), StringUtils.formatPercent((double) used / (double) size, 0), mountedOnPath ); }
@Override protected void processArguments(LinkedList<PathData> args) throws IOException { setUsagesTable(new TableBuilder( "Filesystem", "Size", "Used", "Available", "Use%", "Mounted on")); getUsagesTable().setRightAlign(1, 2, 3, 4); super.processArguments(args); if (!getUsagesTable().isEmpty()) { getUsagesTable().printToStream(out); } }