Search in sources :

Example 1 with StorageTierInfo

use of alluxio.util.webui.StorageTierInfo in project alluxio by Alluxio.

the class AlluxioMasterRestServiceHandler method getWebUIOverview.

/**
 * Gets Web UI overview page data.
 *
 * @return the response object
 */
@GET
@Path(WEBUI_OVERVIEW)
public Response getWebUIOverview() {
    return RestUtils.call(() -> {
        MasterWebUIOverview response = new MasterWebUIOverview();
        response.setDebug(ServerConfiguration.getBoolean(PropertyKey.DEBUG)).setMasterNodeAddress(mMasterProcess.getRpcAddress().toString()).setUptime(CommonUtils.convertMsToClockTime(System.currentTimeMillis() - mMetaMaster.getStartTimeMs())).setStartTime(CommonUtils.convertMsToDate(mMetaMaster.getStartTimeMs(), ServerConfiguration.getString(PropertyKey.USER_DATE_FORMAT_PATTERN))).setVersion(RuntimeConstants.VERSION).setLiveWorkerNodes(Integer.toString(mBlockMaster.getWorkerCount())).setCapacity(FormatUtils.getSizeFromBytes(mBlockMaster.getCapacityBytes())).setClusterId(mMetaMaster.getClusterID()).setReplicaBlockCount(Long.toString(mBlockMaster.getBlockReplicaCount())).setUniqueBlockCount(Long.toString(mBlockMaster.getUniqueBlockCount())).setTotalPath(Long.toString(mFileSystemMaster.getInodeCount())).setUsedCapacity(FormatUtils.getSizeFromBytes(mBlockMaster.getUsedBytes())).setFreeCapacity(FormatUtils.getSizeFromBytes(mBlockMaster.getCapacityBytes() - mBlockMaster.getUsedBytes()));
        ConfigCheckReport report = mMetaMaster.getConfigCheckReport();
        response.setConfigCheckStatus(report.getConfigStatus()).setConfigCheckErrors(report.getConfigErrors()).setConfigCheckWarns(report.getConfigWarns()).setConfigCheckErrorNum(report.getConfigErrors().values().stream().mapToInt(List::size).sum()).setConfigCheckWarnNum(report.getConfigWarns().values().stream().mapToInt(List::size).sum());
        StorageTierAssoc globalStorageTierAssoc = mBlockMaster.getGlobalStorageTierAssoc();
        List<StorageTierInfo> infosList = new ArrayList<>();
        Map<String, Long> totalBytesOnTiers = mBlockMaster.getTotalBytesOnTiers();
        Map<String, Long> usedBytesOnTiers = mBlockMaster.getUsedBytesOnTiers();
        for (int ordinal = 0; ordinal < globalStorageTierAssoc.size(); ordinal++) {
            String tierAlias = globalStorageTierAssoc.getAlias(ordinal);
            if (totalBytesOnTiers.containsKey(tierAlias) && totalBytesOnTiers.get(tierAlias) > 0) {
                StorageTierInfo info = new StorageTierInfo(tierAlias, totalBytesOnTiers.get(tierAlias), usedBytesOnTiers.get(tierAlias));
                infosList.add(info);
            }
        }
        response.setStorageTierInfos(infosList);
        MountPointInfo mountInfo;
        try {
            mountInfo = mFileSystemMaster.getDisplayMountPointInfo(new AlluxioURI(MountTable.ROOT));
            long capacityBytes = mountInfo.getUfsCapacityBytes();
            long usedBytes = mountInfo.getUfsUsedBytes();
            long freeBytes = -1;
            if (usedBytes >= 0 && capacityBytes >= usedBytes) {
                freeBytes = capacityBytes - usedBytes;
            }
            String totalSpace = "UNKNOWN";
            if (capacityBytes >= 0) {
                totalSpace = FormatUtils.getSizeFromBytes(capacityBytes);
            }
            response.setDiskCapacity(totalSpace);
            String usedSpace = "UNKNOWN";
            if (usedBytes >= 0) {
                usedSpace = FormatUtils.getSizeFromBytes(usedBytes);
            }
            response.setDiskUsedCapacity(usedSpace);
            String freeSpace = "UNKNOWN";
            if (freeBytes >= 0) {
                freeSpace = FormatUtils.getSizeFromBytes(freeBytes);
            }
            response.setDiskFreeCapacity(freeSpace);
        } catch (Throwable e) {
            response.setDiskCapacity("UNKNOWN").setDiskUsedCapacity("UNKNOWN").setDiskFreeCapacity("UNKNOWN");
        }
        mMetaMaster.getJournalSpaceMonitor().map(monitor -> response.setJournalDiskWarnings(monitor.getJournalDiskWarnings()));
        Gauge entriesSinceGauge = MetricsSystem.METRIC_REGISTRY.getGauges().get(MetricKey.MASTER_JOURNAL_ENTRIES_SINCE_CHECKPOINT.getName());
        Gauge lastCkPtGauge = MetricsSystem.METRIC_REGISTRY.getGauges().get(MetricKey.MASTER_JOURNAL_LAST_CHECKPOINT_TIME.getName());
        if (entriesSinceGauge != null && lastCkPtGauge != null) {
            long entriesSinceCkpt = (Long) entriesSinceGauge.getValue();
            long lastCkptTime = (Long) lastCkPtGauge.getValue();
            long timeSinceCkpt = System.currentTimeMillis() - lastCkptTime;
            boolean overThreshold = timeSinceCkpt > ServerConfiguration.getMs(PropertyKey.MASTER_WEB_JOURNAL_CHECKPOINT_WARNING_THRESHOLD_TIME);
            boolean passedThreshold = entriesSinceCkpt > ServerConfiguration.getLong(PropertyKey.MASTER_JOURNAL_CHECKPOINT_PERIOD_ENTRIES);
            if (passedThreshold && overThreshold) {
                String time = lastCkptTime > 0 ? ZonedDateTime.ofInstant(Instant.ofEpochMilli(lastCkptTime), ZoneOffset.UTC).format(DateTimeFormatter.ISO_INSTANT) : "N/A";
                String advice = ConfigurationUtils.isHaMode(ServerConfiguration.global()) ? "" : "It is recommended to use the fsadmin tool to checkpoint the journal. This will " + "prevent the master from serving requests while checkpointing.";
                response.setJournalCheckpointTimeWarning(String.format("Journal has not checkpointed in " + "a timely manner since passing the checkpoint threshold (%d/%d). Last checkpoint:" + " %s. %s", entriesSinceCkpt, ServerConfiguration.getLong(PropertyKey.MASTER_JOURNAL_CHECKPOINT_PERIOD_ENTRIES), time, advice));
            }
        }
        Gauge masterRoleIdGauge = MetricsSystem.METRIC_REGISTRY.getGauges().get(MetricKey.MASTER_ROLE_ID.getName());
        Gauge leaderIdGauge = MetricsSystem.METRIC_REGISTRY.getGauges().get(MetricKey.CLUSTER_LEADER_ID.getName());
        if (masterRoleIdGauge != null) {
            response.setMasterRole(RaftProtos.RaftPeerRole.forNumber((Integer) masterRoleIdGauge.getValue()).name());
        }
        if (leaderIdGauge != null) {
            response.setLeaderId((String) leaderIdGauge.getValue());
        }
        return response;
    }, ServerConfiguration.global());
}
Also used : MasterStorageTierAssoc(alluxio.MasterStorageTierAssoc) StorageTierAssoc(alluxio.StorageTierAssoc) ArrayList(java.util.ArrayList) Gauge(com.codahale.metrics.Gauge) MountPointInfo(alluxio.wire.MountPointInfo) ConfigCheckReport(alluxio.wire.ConfigCheckReport) MasterWebUIOverview(alluxio.wire.MasterWebUIOverview) ArrayList(java.util.ArrayList) List(java.util.List) StorageTierInfo(alluxio.util.webui.StorageTierInfo) AlluxioURI(alluxio.AlluxioURI) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Aggregations

AlluxioURI (alluxio.AlluxioURI)1 MasterStorageTierAssoc (alluxio.MasterStorageTierAssoc)1 StorageTierAssoc (alluxio.StorageTierAssoc)1 StorageTierInfo (alluxio.util.webui.StorageTierInfo)1 ConfigCheckReport (alluxio.wire.ConfigCheckReport)1 MasterWebUIOverview (alluxio.wire.MasterWebUIOverview)1 MountPointInfo (alluxio.wire.MountPointInfo)1 Gauge (com.codahale.metrics.Gauge)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1