use of alluxio.util.webui.UIStorageDir in project alluxio by Alluxio.
the class AlluxioWorkerRestServiceHandler method getWebUIOverview.
/**
* Gets web ui overview page data.
*
* @return the response object
*/
@GET
@Path(WEBUI_OVERVIEW)
public Response getWebUIOverview() {
return RestUtils.call(() -> {
WorkerWebUIOverview response = new WorkerWebUIOverview();
response.setWorkerInfo(new UIWorkerInfo(mWorkerProcess.getRpcAddress().toString(), mWorkerProcess.getStartTimeMs(), ServerConfiguration.getString(PropertyKey.USER_DATE_FORMAT_PATTERN)));
BlockStoreMeta storeMeta = mBlockWorker.getStoreMetaFull();
long capacityBytes = 0L;
long usedBytes = 0L;
Map<String, Long> capacityBytesOnTiers = storeMeta.getCapacityBytesOnTiers();
Map<String, Long> usedBytesOnTiers = storeMeta.getUsedBytesOnTiers();
List<UIUsageOnTier> usageOnTiers = new ArrayList<>();
for (Map.Entry<String, Long> entry : capacityBytesOnTiers.entrySet()) {
String tier = entry.getKey();
long capacity = entry.getValue();
Long nullableUsed = usedBytesOnTiers.get(tier);
long used = nullableUsed == null ? 0 : nullableUsed;
capacityBytes += capacity;
usedBytes += used;
usageOnTiers.add(new UIUsageOnTier(tier, capacity, used));
}
response.setCapacityBytes(FormatUtils.getSizeFromBytes(capacityBytes)).setUsedBytes(FormatUtils.getSizeFromBytes(usedBytes)).setUsageOnTiers(usageOnTiers).setBlockCount(Long.toString(storeMeta.getNumberOfBlocks())).setVersion(RuntimeConstants.VERSION);
List<UIStorageDir> storageDirs = new ArrayList<>(storeMeta.getCapacityBytesOnDirs().size());
for (Pair<String, String> tierAndDirPath : storeMeta.getCapacityBytesOnDirs().keySet()) {
storageDirs.add(new UIStorageDir(tierAndDirPath.getFirst(), tierAndDirPath.getSecond(), storeMeta.getCapacityBytesOnDirs().get(tierAndDirPath), storeMeta.getUsedBytesOnDirs().get(tierAndDirPath)));
}
response.setStorageDirs(storageDirs);
return response;
}, ServerConfiguration.global());
}
Aggregations