private Capacity getUfsCapacityInternal() { MountPointInfo mountInfo = mFileSystemMaster.getMountTable().get(MountTable.ROOT); if (mountInfo == null) { return new Capacity().setTotal(-1).setUsed(-1); } long capacityBytes = mountInfo.getUfsCapacityBytes(); long usedBytes = mountInfo.getUfsUsedBytes(); return new Capacity().setTotal(capacityBytes).setUsed(usedBytes); }
/** * @summary get the free ufs capacity in bytes, a negative value means the capacity is unknown. * @return the response object * @deprecated since version 1.4 and will be removed in version 2.0 * @see #getInfo(Boolean) */ @GET @Path(GET_UFS_FREE_BYTES) @ReturnType("java.lang.Long") @Deprecated public Response getUfsFreeBytes() { return RestUtils.call(() -> { Capacity capacity = getUfsCapacityInternal(); if (capacity.getTotal() >= 0 && capacity.getUsed() >= 0 && capacity.getTotal() >= capacity .getUsed()) { return capacity.getTotal() - capacity.getUsed(); } return -1; }, ServerConfiguration.global()); }
/** * @summary get the used disk capacity, a negative value means the capacity is unknown. * @return the response object * @deprecated since version 1.4 and will be removed in version 2.0 * @see #getInfo(Boolean) */ @GET @Path(GET_UFS_USED_BYTES) @ReturnType("java.lang.Long") @Deprecated public Response getUfsUsedBytes() { return RestUtils.call(() -> getUfsCapacityInternal().getUsed(), ServerConfiguration.global()); }
/** * @summary get the total ufs capacity in bytes, a negative value means the capacity is * unknown. * @return the response object * @deprecated since version 1.4 and will be removed in version 2.0 * @see #getInfo(Boolean) */ @GET @Path(GET_UFS_CAPACITY_BYTES) @ReturnType("java.lang.Long") @Deprecated public Response getUfsCapacityBytes() { return RestUtils.call(() -> getUfsCapacityInternal().getTotal(), ServerConfiguration.global()); }
/** * @summary get the used disk capacity, a negative value means the capacity is unknown. * @return the response object * @deprecated since version 1.4 and will be removed in version 2.0 * @see #getInfo(Boolean) */ @GET @Path(GET_UFS_USED_BYTES) @ReturnType("java.lang.Long") @Deprecated public Response getUfsUsedBytes() { return RestUtils.call(() -> getUfsCapacityInternal().getUsed()); }
/** * @summary get the total ufs capacity in bytes, a negative value means the capacity is unknown. * @return the response object * @deprecated since version 1.4 and will be removed in version 2.0 * @see #getInfo(Boolean) */ @GET @Path(GET_UFS_CAPACITY_BYTES) @ReturnType("java.lang.Long") @Deprecated public Response getUfsCapacityBytes() { return RestUtils.call(() -> getUfsCapacityInternal().getTotal()); }
/** * Checks if the two Capacity objects are equal. * * @param a the first Capacity object to be checked * @param b the second Capacity object to be checked */ private void checkEquality(Capacity a, Capacity b) { assertEquals(a.getTotal(), b.getTotal()); assertEquals(a.getUsed(), b.getUsed()); assertEquals(a, b); }
/** * @summary get the free ufs capacity in bytes, a negative value means the capacity is unknown. * @return the response object * @deprecated since version 1.4 and will be removed in version 2.0 * @see #getInfo(Boolean) */ @GET @Path(GET_UFS_FREE_BYTES) @ReturnType("java.lang.Long") @Deprecated public Response getUfsFreeBytes() { return RestUtils.call(() -> { Capacity capacity = getUfsCapacityInternal(); if (capacity.getTotal() >= 0 && capacity.getUsed() >= 0 && capacity.getTotal() >= capacity .getUsed()) { return capacity.getTotal() - capacity.getUsed(); } return -1; }); }
private Map<String, Capacity> getTierCapacityInternal() { SortedMap<String, Capacity> tierCapacity = new TreeMap<>(getTierAliasComparator()); Map<String, Long> capacityBytesOnTiers = mStoreMeta.getCapacityBytesOnTiers(); Map<String, Long> usedBytesOnTiers = mStoreMeta.getUsedBytesOnTiers(); for (Map.Entry<String, Long> entry : capacityBytesOnTiers.entrySet()) { tierCapacity.put(entry.getKey(), new Capacity().setTotal(entry.getValue()).setUsed(usedBytesOnTiers.get(entry.getKey()))); } return tierCapacity; }
private Map<String, Capacity> getTierCapacityInternal() { SortedMap<String, Capacity> tierCapacity = new TreeMap<>(); Map<String, Long> totalTierCapacity = mBlockMaster.getTotalBytesOnTiers(); Map<String, Long> usedTierCapacity = mBlockMaster.getUsedBytesOnTiers(); for (String tierAlias : mBlockMaster.getGlobalStorageTierAssoc().getOrderedStorageAliases()) { long total = totalTierCapacity.containsKey(tierAlias) ? totalTierCapacity.get(tierAlias) : 0; long used = usedTierCapacity.containsKey(tierAlias) ? usedTierCapacity.get(tierAlias) : 0; tierCapacity.put(tierAlias, new Capacity().setTotal(total).setUsed(used)); } return tierCapacity; }
/** * Randomly creates a Capacity object. * * @return the created Capacity object */ protected static Capacity createRandom() { Capacity result = new Capacity(); Random random = new Random(); long total = random.nextLong(); long used = random.nextLong(); result.setTotal(total); result.setUsed(used); return result; } }
private Capacity getUfsCapacityInternal() { MountPointInfo mountInfo = mFileSystemMaster.getMountTable().get(MountTable.ROOT); if (mountInfo == null) { return new Capacity().setTotal(-1).setUsed(-1); } long capacityBytes = mountInfo.getUfsCapacityBytes(); long usedBytes = mountInfo.getUfsUsedBytes(); return new Capacity().setTotal(capacityBytes).setUsed(usedBytes); }
private Map<String, Capacity> getTierCapacityInternal() { SortedMap<String, Capacity> tierCapacity = new TreeMap<>(); Map<String, Long> totalTierCapacity = mBlockMaster.getTotalBytesOnTiers(); Map<String, Long> usedTierCapacity = mBlockMaster.getUsedBytesOnTiers(); for (String tierAlias : mBlockMaster.getGlobalStorageTierAssoc().getOrderedStorageAliases()) { long total = totalTierCapacity.containsKey(tierAlias) ? totalTierCapacity.get(tierAlias) : 0; long used = usedTierCapacity.containsKey(tierAlias) ? usedTierCapacity.get(tierAlias) : 0; tierCapacity.put(tierAlias, new Capacity().setTotal(total).setUsed(used)); } return tierCapacity; }