Search in sources :

Example 1 with ClusterAllocationDiskSettings

use of org.graylog2.indexer.cluster.health.ClusterAllocationDiskSettings 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)

Example 2 with ClusterAllocationDiskSettings

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

the class IndexerClusterCheckerThreadTest method noChecksWhenDiskAllocationThresholdIsDisabled.

@Test
public void noChecksWhenDiskAllocationThresholdIsDisabled() throws Exception {
    ClusterAllocationDiskSettings clusterAllocationDiskSettings = mock(ClusterAllocationDiskSettings.class);
    when(clusterAllocationDiskSettings.ThresholdEnabled()).thenReturn(false);
    when(cluster.getClusterAllocationDiskSettings()).thenReturn(clusterAllocationDiskSettings);
    indexerClusterCheckerThread.checkDiskUsage();
    verify(clusterAllocationDiskSettings, times(1)).ThresholdEnabled();
    verifyNoMoreInteractions(clusterAllocationDiskSettings);
    verify(cluster, times(1)).getClusterAllocationDiskSettings();
    verifyNoMoreInteractions(cluster);
}
Also used : ClusterAllocationDiskSettings(org.graylog2.indexer.cluster.health.ClusterAllocationDiskSettings) Test(org.junit.Test)

Example 3 with ClusterAllocationDiskSettings

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

the class IndexerClusterCheckerThreadTest method buildThresholdTriggeredClusterAllocationDiskSettingsAbsolute.

private ClusterAllocationDiskSettings buildThresholdTriggeredClusterAllocationDiskSettingsAbsolute(Notification.Type expectedNotificationType) {
    ByteSize low;
    ByteSize high;
    ByteSize floodStage;
    if (expectedNotificationType == ES_NODE_DISK_WATERMARK_LOW) {
        low = SIUnitParser.parseBytesSizeValue("35GB");
        high = SIUnitParser.parseBytesSizeValue("10GB");
        floodStage = SIUnitParser.parseBytesSizeValue("5GB");
    } else if (expectedNotificationType == Notification.Type.ES_NODE_DISK_WATERMARK_HIGH) {
        low = SIUnitParser.parseBytesSizeValue("45GB");
        high = SIUnitParser.parseBytesSizeValue("35GB");
        floodStage = SIUnitParser.parseBytesSizeValue("5GB");
    } else {
        low = SIUnitParser.parseBytesSizeValue("55GB");
        high = SIUnitParser.parseBytesSizeValue("45GB");
        floodStage = SIUnitParser.parseBytesSizeValue("35GB");
    }
    return ClusterAllocationDiskSettings.create(true, new AbsoluteValueWatermarkSettings.Builder().low(low).high(high).floodStage(floodStage).build());
}
Also used : ByteSize(org.graylog2.indexer.cluster.health.ByteSize) AbsoluteValueWatermarkSettings(org.graylog2.indexer.cluster.health.AbsoluteValueWatermarkSettings)

Example 4 with ClusterAllocationDiskSettings

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

the class ClusterIT method getDefaultClusterAllocationDiskSettings.

@Test
public void getDefaultClusterAllocationDiskSettings() {
    final ClusterAllocationDiskSettings clusterAllocationDiskSettings = cluster.getClusterAllocationDiskSettings();
    assertThat(clusterAllocationDiskSettings.ThresholdEnabled()).isTrue();
    assertThat(clusterAllocationDiskSettings.watermarkSettings().type()).isEqualTo(WatermarkSettings.SettingsType.PERCENTAGE);
    assertThat(clusterAllocationDiskSettings.watermarkSettings().low()).isEqualTo(85D);
    assertThat(clusterAllocationDiskSettings.watermarkSettings().high()).isEqualTo(90D);
    assertThat(clusterAllocationDiskSettings.watermarkSettings().floodStage()).isEqualTo(95D);
}
Also used : ClusterAllocationDiskSettings(org.graylog2.indexer.cluster.health.ClusterAllocationDiskSettings) Test(org.junit.Test) ElasticsearchBaseTest(org.graylog.testing.elasticsearch.ElasticsearchBaseTest)

Aggregations

ClusterAllocationDiskSettings (org.graylog2.indexer.cluster.health.ClusterAllocationDiskSettings)3 AbsoluteValueWatermarkSettings (org.graylog2.indexer.cluster.health.AbsoluteValueWatermarkSettings)2 Test (org.junit.Test)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableList (com.google.common.collect.ImmutableList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ElasticsearchBaseTest (org.graylog.testing.elasticsearch.ElasticsearchBaseTest)1 ByteSize (org.graylog2.indexer.cluster.health.ByteSize)1 NodeDiskUsageStats (org.graylog2.indexer.cluster.health.NodeDiskUsageStats)1 PercentageWatermarkSettings (org.graylog2.indexer.cluster.health.PercentageWatermarkSettings)1 Notification (org.graylog2.notifications.Notification)1