During the development and review process of the disk health indicator we noticed that it was hard to understand. Since we learnt a lot from the first round of development we want to go through the code one more time and restructure it.
server/src/main/java/org/elasticsearch/health/node/DiskHealthIndicatorService.java
String nodesWithMissingData = nodesInClusterState.stream()
                    .filter(node -> nodeIdsInHealthInfo.contains(node.getId()) == false)
                    .map(HealthIndicatorDisplayValues::getNodeName)
                    .collect(Collectors.joining(", "));
                logger.debug("The following nodes are in the cluster state but not reporting health data: [{}]", nodesWithMissingData);
            }
        }
    }
    private HealthIndicatorDetails getDetails(boolean explain, Map<String, DiskHealthInfo> diskHealthInfoMap, Set<String> blockedIndices) {
        if (explain == false) {
            return HealthIndicatorDetails.EMPTY;
        }
        Map<HealthStatus, Integer> healthNodesCount = new HashMap<>();
        for (HealthStatus healthStatus : HealthStatus.values()) {
            healthNodesCount.put(healthStatus, 0);
        }
        for (DiskHealthInfo diskHealthInfo : diskHealthInfoMap.values()) {
            healthNodesCount.computeIfPresent(diskHealthInfo.healthStatus(), (key, oldCount) -> oldCount + 1);
        }
        return ((builder, params) -> {
            builder.startObject();
            builder.field("blocked_indices", blockedIndices.size());
            for (HealthStatus healthStatus : HealthStatus.values()) {
                builder.field(healthStatus.name().toLowerCase(Locale.ROOT) + "_nodes", healthNodesCount.get(healthStatus));
            }
            return builder.endObject();
        });
    }
}