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());
}
}
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);
}
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());
}
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);
}
Aggregations