@Test public void allInMem() { AlluxioURI rootpath = new AlluxioURI("/"); List<FileInfo> infos = new ArrayList<>(); infos.add( new FileInfo().setLength(10).setInAlluxioPercentage(100).setInMemoryPercentage(100)); infos.add( new FileInfo().setLength(30).setInAlluxioPercentage(100).setInMemoryPercentage(100)); infos.add( new FileInfo().setLength(20).setInAlluxioPercentage(100).setInMemoryPercentage(100)); List<URIStatus> statuses = infos.stream().map(URIStatus::new).collect(Collectors.toList()); DuCommand.getSizeInfo(rootpath, statuses, false, true, true); String output = mOutput.toString().trim(); assertPercentage(output, 100, 100); }
protected static void getSizeInfo(AlluxioURI path, List<URIStatus> statuses, boolean readable, boolean summarize, boolean addMemory) { if (summarize) { long totalSize = 0; long sizeInAlluxio = 0; long sizeInMem = 0; for (URIStatus status : statuses) { if (!status.isFolder()) { long size = status.getLength(); totalSize += size; sizeInMem += size * status.getInMemoryPercentage(); sizeInAlluxio += size * status.getInAlluxioPercentage(); } } String sizeMessage = readable ? FormatUtils.getSizeFromBytes(totalSize) : String.valueOf(totalSize); String inAlluxioMessage = getFormattedValues(readable, sizeInAlluxio / 100, totalSize); String inMemMessage = addMemory ? getFormattedValues(readable, sizeInMem / 100, totalSize) : ""; printInfo(sizeMessage, inAlluxioMessage, inMemMessage, path.toString()); } else { for (URIStatus status : statuses) { if (!status.isFolder()) { long totalSize = status.getLength(); String sizeMessage = readable ? FormatUtils.getSizeFromBytes(totalSize) : String.valueOf(totalSize); String inAlluxioMessage = getFormattedValues(readable, status.getInAlluxioPercentage() * totalSize / 100, totalSize); String inMemMessage = addMemory ? getFormattedValues(readable, status.getInMemoryPercentage() * totalSize / 100, totalSize) : ""; printInfo(sizeMessage, inAlluxioMessage, inMemMessage, status.getPath()); } } } }
DuCommand extends AbstractFileSystemCommand { protected static void getSizeInfo(AlluxioURI path, List<URIStatus> statuses, boolean readable, boolean summarize, boolean addMemory) { if (summarize) { long totalSize = 0; long sizeInAlluxio = 0; long sizeInMem = 0; for (URIStatus status : statuses) { if (!status.isFolder()) { long size = status.getLength(); totalSize += size; sizeInMem += size * status.getInMemoryPercentage(); sizeInAlluxio += size * status.getInAlluxioPercentage(); } } String sizeMessage = readable ? FormatUtils.getSizeFromBytes(totalSize) : String.valueOf(totalSize); String inAlluxioMessage = getFormattedValues(readable, sizeInAlluxio / 100, totalSize); String inMemMessage = addMemory ? getFormattedValues(readable, sizeInMem / 100, totalSize) : ""; printInfo(sizeMessage, inAlluxioMessage, inMemMessage, path.toString()); } else { for (URIStatus status : statuses) { if (!status.isFolder()) { long totalSize = status.getLength(); String sizeMessage = readable ? FormatUtils.getSizeFromBytes(totalSize) : String.valueOf(totalSize); String inAlluxioMessage = getFormattedValues(readable, status.getInAlluxioPercentage() * totalSize / 100, totalSize); String inMemMessage = addMemory ? getFormattedValues(readable, status.getInMemoryPercentage() * totalSize / 100, totalSize) : ""; printInfo(sizeMessage, inAlluxioMessage, inMemMessage, status.getPath()); } } } } }
DuCommand extends AbstractFileSystemCommand { protected static void getSizeInfo(AlluxioURI path, List<URIStatus> statuses, boolean readable, boolean summarize, boolean addMemory) { if (summarize) { long totalSize = 0; long sizeInAlluxio = 0; long sizeInMem = 0; for (URIStatus status : statuses) { if (!status.isFolder()) { long size = status.getLength(); totalSize += size; sizeInMem += size * status.getInMemoryPercentage(); sizeInAlluxio += size * status.getInAlluxioPercentage(); } } String sizeMessage = readable ? FormatUtils.getSizeFromBytes(totalSize) : String.valueOf(totalSize); String inAlluxioMessage = getFormattedValues(readable, sizeInAlluxio / 100, totalSize); String inMemMessage = addMemory ? getFormattedValues(readable, sizeInMem / 100, totalSize) : ""; printInfo(sizeMessage, inAlluxioMessage, inMemMessage, path.toString()); } else { for (URIStatus status : statuses) { if (!status.isFolder()) { long totalSize = status.getLength(); String sizeMessage = readable ? FormatUtils.getSizeFromBytes(totalSize) : String.valueOf(totalSize); String inAlluxioMessage = getFormattedValues(readable, status.getInAlluxioPercentage() * totalSize / 100, totalSize); String inMemMessage = addMemory ? getFormattedValues(readable, status.getInMemoryPercentage() * totalSize / 100, totalSize) : ""; printInfo(sizeMessage, inAlluxioMessage, inMemMessage, status.getPath()); } } } } DuCommand(FileSystemContext fsContext); }
DuCommand extends AbstractFileSystemCommand { protected static void getSizeInfo(AlluxioURI path, List<URIStatus> statuses, boolean readable, boolean summarize, boolean addMemory) { if (summarize) { long totalSize = 0; long sizeInAlluxio = 0; long sizeInMem = 0; for (URIStatus status : statuses) { if (!status.isFolder()) { long size = status.getLength(); totalSize += size; sizeInMem += size * status.getInMemoryPercentage(); sizeInAlluxio += size * status.getInAlluxioPercentage(); } } String sizeMessage = readable ? FormatUtils.getSizeFromBytes(totalSize) : String.valueOf(totalSize); String inAlluxioMessage = getFormattedValues(readable, sizeInAlluxio / 100, totalSize); String inMemMessage = addMemory ? getFormattedValues(readable, sizeInMem / 100, totalSize) : ""; printInfo(sizeMessage, inAlluxioMessage, inMemMessage, path.toString()); } else { for (URIStatus status : statuses) { if (!status.isFolder()) { long totalSize = status.getLength(); String sizeMessage = readable ? FormatUtils.getSizeFromBytes(totalSize) : String.valueOf(totalSize); String inAlluxioMessage = getFormattedValues(readable, status.getInAlluxioPercentage() * totalSize / 100, totalSize); String inMemMessage = addMemory ? getFormattedValues(readable, status.getInMemoryPercentage() * totalSize / 100, totalSize) : ""; printInfo(sizeMessage, inAlluxioMessage, inMemMessage, status.getPath()); } } } } DuCommand(FileSystemContext fsContext); @Override String getCommandName(); @Override String getUsage(); @Override String getDescription(); @Override void validateArgs(CommandLine cl); @Override Options getOptions(); @Override int run(CommandLine cl); }
DuCommand extends AbstractFileSystemCommand { protected static void getSizeInfo(AlluxioURI path, List<URIStatus> statuses, boolean readable, boolean summarize, boolean addMemory) { if (summarize) { long totalSize = 0; long sizeInAlluxio = 0; long sizeInMem = 0; for (URIStatus status : statuses) { if (!status.isFolder()) { long size = status.getLength(); totalSize += size; sizeInMem += size * status.getInMemoryPercentage(); sizeInAlluxio += size * status.getInAlluxioPercentage(); } } String sizeMessage = readable ? FormatUtils.getSizeFromBytes(totalSize) : String.valueOf(totalSize); String inAlluxioMessage = getFormattedValues(readable, sizeInAlluxio / 100, totalSize); String inMemMessage = addMemory ? getFormattedValues(readable, sizeInMem / 100, totalSize) : ""; printInfo(sizeMessage, inAlluxioMessage, inMemMessage, path.toString()); } else { for (URIStatus status : statuses) { if (!status.isFolder()) { long totalSize = status.getLength(); String sizeMessage = readable ? FormatUtils.getSizeFromBytes(totalSize) : String.valueOf(totalSize); String inAlluxioMessage = getFormattedValues(readable, status.getInAlluxioPercentage() * totalSize / 100, totalSize); String inMemMessage = addMemory ? getFormattedValues(readable, status.getInMemoryPercentage() * totalSize / 100, totalSize) : ""; printInfo(sizeMessage, inAlluxioMessage, inMemMessage, status.getPath()); } } } } DuCommand(FileSystemContext fsContext); @Override String getCommandName(); @Override String getUsage(); @Override String getDescription(); @Override void validateArgs(CommandLine cl); @Override Options getOptions(); @Override int run(CommandLine cl);  }