Search in sources :

Example 1 with UIStorageDir

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());
}
Also used : ArrayList(java.util.ArrayList) UIStorageDir(alluxio.util.webui.UIStorageDir) UIWorkerInfo(alluxio.util.webui.UIWorkerInfo) UIUsageOnTier(alluxio.util.webui.UIUsageOnTier) Map(java.util.Map) SortedMap(java.util.SortedMap) TreeMap(java.util.TreeMap) BlockStoreMeta(alluxio.worker.block.BlockStoreMeta) WorkerWebUIOverview(alluxio.wire.WorkerWebUIOverview) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

UIStorageDir (alluxio.util.webui.UIStorageDir)1 UIUsageOnTier (alluxio.util.webui.UIUsageOnTier)1 UIWorkerInfo (alluxio.util.webui.UIWorkerInfo)1 WorkerWebUIOverview (alluxio.wire.WorkerWebUIOverview)1 BlockStoreMeta (alluxio.worker.block.BlockStoreMeta)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1