/** * {@inheritDoc} */ @Override protected String valueToHumanReadableImpl(double value) { return NumberFormatter.humanReadableByteCount((long) (value * MEGABYTE_BYTE_COUNT)); }
/** * Returns the human readable bytes number with one decimal place. * * @param bytes * Bytes to transform. * @return Human readable string. */ public static String humanReadableByteCount(long bytes) { return humanReadableByteCount(bytes, 1); }
stringBuilder.append(files.size()); stringBuilder.append(" ("); stringBuilder.append(NumberFormatter.humanReadableByteCount(totalBytesTransfered)); if (!gzipCompression) { stringBuilder.append(" out of "); stringBuilder.append(NumberFormatter.humanReadableByteCount(totalSize)); stringBuilder.append(NumberFormatter.humanReadableByteCount((long) getAverageTransferRate())); stringBuilder.append("/s) Remaining time: "); if (gzipCompression) {
@Test public void validResultTerraBytes() { long input = (long) Math.pow(1024D, 4D); String result = NumberFormatter.humanReadableByteCount(input); assertThat(result, is(equalTo("1.0 TiB"))); }
@Test public void validResultBytes() { String result = NumberFormatter.humanReadableByteCount(512L); assertThat(result, is(equalTo("512 B"))); }
@Test public void validResultWithOneDecimalPlace() { String result = NumberFormatter.humanReadableByteCount(1900L); assertThat(result, is(equalTo("1.9 KiB"))); }
@Test public void validResultWithMultipleDecimalPlaces() { String result = NumberFormatter.humanReadableByteCount(1900L, 3); assertThat(result, is(equalTo("1.855 KiB"))); }
@Test public void validResultWithoutDecimalPlaces() { String result = NumberFormatter.humanReadableByteCount(1900L, 0); assertThat(result, is(equalTo("2 KiB"))); }
@Test public void validResultMaxLong() { String result = NumberFormatter.humanReadableByteCount(Long.MAX_VALUE); assertThat(result, is(equalTo("8.0 EiB"))); } }
@Test public void validResultGigaBytes() { long input = (long) Math.pow(1024D, 3D); String result = NumberFormatter.humanReadableByteCount(input); assertThat(result, is(equalTo("1.0 GiB"))); }
@Test public void validResultMegaBytes() { long input = (long) Math.pow(1024D, 2D); String result = NumberFormatter.humanReadableByteCount(input); assertThat(result, is(equalTo("1.0 MiB"))); }
@Test public void validResultPetaBytes() { long input = (long) Math.pow(1024D, 5D); String result = NumberFormatter.humanReadableByteCount(input); assertThat(result, is(equalTo("1.0 PiB"))); }
@Test public void validResultExaBytes() { long input = (long) Math.pow(1024D, 6D); String result = NumberFormatter.humanReadableByteCount(input); assertThat(result, is(equalTo("1.0 EiB"))); }
description.setText("", false, false); size.setText(NumberFormatter.humanReadableByteCount(storageData.getDiskSize())); if (StringUtils.isNotEmpty(storageData.getCmrVersion())) { cmrVersion.setText(storageData.getCmrVersion());
int occupancy = (int) ((100 * Math.round(bufferCurrentOccupancy)) / Math.round(bufferMaxOccupancy)); String occMb = NumberFormatter.humanReadableByteCount(cmrStatusData.getCurrentBufferSize()); String maxMb = NumberFormatter.humanReadableByteCount(cmrStatusData.getMaxBufferSize()); String string = occupancy + "% (" + occMb + " / " + maxMb + ")"; bufferSize.setText(string); StringBuilder spaceLeftStringBuilder = new StringBuilder(String.valueOf(spaceOccupancy)); spaceLeftStringBuilder.append("% ("); spaceLeftStringBuilder.append(NumberFormatter.humanReadableByteCount(cmrStatusData.getStorageDataSpaceLeft())); spaceLeftStringBuilder.append(" / "); spaceLeftStringBuilder.append(NumberFormatter.humanReadableByteCount(cmrStatusData.getStorageMaxDataSpace())); spaceLeftStringBuilder.append(')'); spaceLeftLabel.setText(spaceLeftStringBuilder.toString()); databaseSizeLabel.setText(NumberFormatter.humanReadableByteCount(databaseSize.longValue())); } else { databaseSizeLabel.setText("n/a");
CmrStatusData cmrStatusData = cmrRepositoryDefinition.getCmrManagementService().getCmrStatusData(); if (cmrStatusData.isWarnSpaceLeftActive()) { String leftSpace = NumberFormatter.humanReadableByteCount(cmrStatusData.getStorageDataSpaceLeft()); if (!MessageDialog.openQuestion(HandlerUtil.getActiveShell(event), "Confirm", "For selected CMR there is an active warning about insufficient storage space left. Only " + leftSpace + " are left on the target server, are you sure you want to continue?")) {
/** * Returns the styled string for the {@link LocalStorageData}. * * @param localStorageData * Local storage data. * @return Styled string for nicer representation. */ public static StyledString getStyledStorageDataString(LocalStorageData localStorageData) { StyledString styledString = new StyledString(); styledString.append(localStorageData.getName()); styledString.append(" "); styledString.append("[Local Disk]", StyledString.QUALIFIER_STYLER); styledString.append(" - "); styledString.append(NumberFormatter.humanReadableByteCount(localStorageData.getDiskSize()), StyledString.DECORATIONS_STYLER); return styledString; }
/** * Returns the styled string for the storage data and its CMR repository definition. * * @param storageData * {@link StorageData}. * @param cmrRepositoryDefinition * {@link CmrRepositoryDefinition}. * @return Styled string for nicer representation. */ public static StyledString getStyledStorageDataString(StorageData storageData, CmrRepositoryDefinition cmrRepositoryDefinition) { StyledString styledString = new StyledString(); styledString.append(storageData.getName()); styledString.append(" "); styledString.append("[" + cmrRepositoryDefinition.getName() + "]", StyledString.QUALIFIER_STYLER); styledString.append(" - "); styledString.append(getStorageStateTextualRepresentation(storageData.getState()), StyledString.DECORATIONS_STYLER); if (InspectIT.getDefault().getInspectITStorageManager().isFullyDownloaded(storageData)) { styledString.append(", Downloaded", StyledString.DECORATIONS_STYLER); } styledString.append(", " + NumberFormatter.humanReadableByteCount(storageData.getDiskSize()), StyledString.DECORATIONS_STYLER); return styledString; }
CmrStatusData cmrStatusData = suggestedCmrRepositoryDefinition.getCmrManagementService().getCmrStatusData(); if (cmrStatusData.isWarnSpaceLeftActive()) { String leftSpace = NumberFormatter.humanReadableByteCount(cmrStatusData.getStorageDataSpaceLeft()); if (!MessageDialog.openQuestion(HandlerUtil.getActiveShell(event), "Confirm", "For selected CMR there is an active warning about insufficient storage space left. Only " + leftSpace + " are left on the target server, are you sure you want to continue?")) {
CmrStatusData cmrStatusData = cmrRepositoryDefinition.getCmrManagementService().getCmrStatusData(); if (cmrStatusData.isWarnSpaceLeftActive()) { String leftSpace = NumberFormatter.humanReadableByteCount(cmrStatusData.getStorageDataSpaceLeft()); if (!MessageDialog.openQuestion(HandlerUtil.getActiveShell(event), "Confirm", "For selected CMR there is an active warning about insufficient storage space left. Only " + leftSpace + " are left on the target server, are you sure you want to continue?")) {