Skip to content

Commit

Permalink
Fix free meta memory report of health monitor (#18953)
Browse files Browse the repository at this point in the history
By starting 4.2 `maxMetadata` is a soft limit used for informative purposes, when needed we exceed
beyond that configured `maxMetadata`. But health monitor doesn't log this truly. This commit fixes it by doing calculations against `maxNative` stats
  • Loading branch information
ahmetmircik committed Jun 23, 2021
1 parent d4e7544 commit 65cd1ef
Showing 1 changed file with 12 additions and 13 deletions.
Expand Up @@ -19,19 +19,19 @@
import com.hazelcast.instance.impl.Node;
import com.hazelcast.instance.impl.NodeState;
import com.hazelcast.instance.impl.OutOfMemoryErrorDispatcher;
import com.hazelcast.internal.memory.MemoryStats;
import com.hazelcast.internal.metrics.DoubleGauge;
import com.hazelcast.internal.metrics.LongGauge;
import com.hazelcast.internal.metrics.MetricsRegistry;
import com.hazelcast.logging.ILogger;
import com.hazelcast.internal.memory.MemoryStats;
import com.hazelcast.spi.properties.ClusterProperty;

import static com.hazelcast.internal.diagnostics.HealthMonitorLevel.OFF;
import static com.hazelcast.internal.diagnostics.HealthMonitorLevel.valueOf;
import static com.hazelcast.internal.util.ThreadUtil.createThreadName;
import static com.hazelcast.spi.properties.ClusterProperty.HEALTH_MONITORING_DELAY_SECONDS;
import static com.hazelcast.spi.properties.ClusterProperty.HEALTH_MONITORING_THRESHOLD_CPU_PERCENTAGE;
import static com.hazelcast.spi.properties.ClusterProperty.HEALTH_MONITORING_THRESHOLD_MEMORY_PERCENTAGE;
import static com.hazelcast.internal.util.ThreadUtil.createThreadName;
import static java.lang.String.format;
import static java.lang.Thread.currentThread;
import static java.util.concurrent.TimeUnit.SECONDS;
Expand Down Expand Up @@ -445,25 +445,24 @@ private void renderNativeMemory() {
return;
}

final long maxNative = memoryStats.getMaxNative();
final long usedNative = memoryStats.getUsedNative();
final long usedMeta = memoryStats.getUsedMetadata();

sb.append("native.memory.used=")
.append(numberToUnit(usedNative)).append(", ");
sb.append("native.memory.free=")
.append(numberToUnit(memoryStats.getFreeNative())).append(", ");
sb.append("native.memory.total=")
.append(numberToUnit(memoryStats.getCommittedNative())).append(", ");
sb.append("native.memory.max=")
.append(numberToUnit(memoryStats.getMaxNative())).append(", ");
final long maxMeta = memoryStats.getMaxMetadata();
if (maxMeta > 0) {
final long usedMeta = memoryStats.getUsedMetadata();
sb.append("native.meta.memory.used=")
.append(numberToUnit(usedMeta)).append(", ");
sb.append("native.meta.memory.free=")
.append(numberToUnit(maxMeta - usedMeta)).append(", ");
sb.append("native.meta.memory.percentage=")
.append(percentageString(PERCENTAGE_MULTIPLIER * usedMeta / (usedNative + usedMeta))).append(", ");
}
.append(numberToUnit(maxNative)).append(", ");
sb.append("native.meta.memory.used=")
.append(numberToUnit(usedMeta)).append(", ");
sb.append("native.meta.memory.free=")
.append(numberToUnit(maxNative - usedMeta)).append(", ");
sb.append("native.meta.memory.percentage=")
.append(percentageString(PERCENTAGE_MULTIPLIER * usedMeta / maxNative)).append(", ");
}

private void renderExecutors() {
Expand Down

0 comments on commit 65cd1ef

Please sign in to comment.