Search in sources :

Example 1 with AbsoluteValueWatermarkSettings

use of org.graylog2.indexer.cluster.health.AbsoluteValueWatermarkSettings in project graylog2-server by Graylog2.

the class IndexerClusterCheckerThread method checkDiskUsage.

@VisibleForTesting()
void checkDiskUsage() {
    final Map<Notification.Type, List<String>> notificationTypePerNodeIdentifier = new HashMap<>();
    try {
        ClusterAllocationDiskSettings settings = cluster.getClusterAllocationDiskSettings();
        if (settings.ThresholdEnabled()) {
            final Set<NodeDiskUsageStats> diskUsageStats = cluster.getDiskUsageStats();
            for (NodeDiskUsageStats nodeDiskUsageStats : diskUsageStats) {
                if (!nodeHoldsData(nodeDiskUsageStats)) {
                    LOG.debug("Ignoring non-data ES node <{}/{}> with roles <{}> for disk usage check.", nodeDiskUsageStats.host(), nodeDiskUsageStats.ip(), nodeDiskUsageStats.roles());
                    continue;
                }
                Notification.Type currentNodeNotificationType = null;
                WatermarkSettings<?> watermarkSettings = settings.watermarkSettings();
                if (watermarkSettings instanceof PercentageWatermarkSettings) {
                    currentNodeNotificationType = getDiskUsageNotificationTypeByPercentage((PercentageWatermarkSettings) watermarkSettings, nodeDiskUsageStats);
                } else if (watermarkSettings instanceof AbsoluteValueWatermarkSettings) {
                    currentNodeNotificationType = getDiskUsageNotificationTypeByAbsoluteValues((AbsoluteValueWatermarkSettings) watermarkSettings, nodeDiskUsageStats);
                }
                if (currentNodeNotificationType != null) {
                    String nodeIdentifier = firstNonNull(nodeDiskUsageStats.host(), nodeDiskUsageStats.ip());
                    notificationTypePerNodeIdentifier.merge(currentNodeNotificationType, Collections.singletonList(nodeIdentifier), (prev, cur) -> ImmutableList.<String>builder().addAll(prev).addAll(cur).build());
                }
            }
            if (notificationTypePerNodeIdentifier.isEmpty()) {
                fixAllDiskUsageNotifications();
            } else {
                publishDiskUsageNotifications(notificationTypePerNodeIdentifier);
            }
        }
    } catch (Exception e) {
        LOG.error("Error while trying to check Elasticsearch disk usage.Details: " + e.getMessage());
    }
}
Also used : HashMap(java.util.HashMap) Notification(org.graylog2.notifications.Notification) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) NodeDiskUsageStats(org.graylog2.indexer.cluster.health.NodeDiskUsageStats) ClusterAllocationDiskSettings(org.graylog2.indexer.cluster.health.ClusterAllocationDiskSettings) PercentageWatermarkSettings(org.graylog2.indexer.cluster.health.PercentageWatermarkSettings) AbsoluteValueWatermarkSettings(org.graylog2.indexer.cluster.health.AbsoluteValueWatermarkSettings) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableList (com.google.common.collect.ImmutableList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 AbsoluteValueWatermarkSettings (org.graylog2.indexer.cluster.health.AbsoluteValueWatermarkSettings)1 ClusterAllocationDiskSettings (org.graylog2.indexer.cluster.health.ClusterAllocationDiskSettings)1 NodeDiskUsageStats (org.graylog2.indexer.cluster.health.NodeDiskUsageStats)1 PercentageWatermarkSettings (org.graylog2.indexer.cluster.health.PercentageWatermarkSettings)1 Notification (org.graylog2.notifications.Notification)1