Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ public final class IgniteNodeAttributes {
/** Allows to override {@link #ATTR_MACS} by adding this attribute in the user attributes. */
public static final String ATTR_MACS_OVERRIDE = "override." + ATTR_MACS;

/** Internal attribute name constant. */
public static final String ATTR_PHY_RAM = ATTR_PREFIX + ".phy.ram";

/** Internal attribute name constant. */
public static final String ATTR_OFFHEAP_SIZE = ATTR_PREFIX + ".offheap.size";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PHY_RAM;
import static org.apache.ignite.internal.processors.metric.impl.MetricUtils.customName;
import static org.apache.ignite.internal.processors.metric.impl.MetricUtils.fromFullName;
import static org.apache.ignite.internal.processors.metric.impl.MetricUtils.metricName;
Expand Down Expand Up @@ -225,8 +224,6 @@ public GridMetricManager(GridKernalContext ctx) {

sunOs = sunOperatingSystemMXBeanAccessor();

ctx.addNodeAttribute(ATTR_PHY_RAM, totalSysMemory());

heap = new MemoryUsageMetrics(SYS_METRICS, metricName("memory", "heap"));
nonHeap = new MemoryUsageMetrics(SYS_METRICS, metricName("memory", "nonheap"));

Expand Down Expand Up @@ -640,18 +637,6 @@ private <T extends Metric> void ensureMetricRegistered(String name, Class<T> cls
throw new IgniteException("Failed to find registered metric with specified name [metricName=" + name + ']');
}

/**
* @return Total system memory.
*/
private long totalSysMemory() {
try {
return sunOs.getTotalPhysicalMemorySize();
}
catch (RuntimeException ignored) {
return -1;
}
}

/** @return Accessor for {@link com.sun.management.OperatingSystemMXBean}. */
private SunOperatingSystemMXBeanAccessor sunOperatingSystemMXBeanAccessor() {
try {
Expand All @@ -662,10 +647,6 @@ private SunOperatingSystemMXBeanAccessor sunOperatingSystemMXBeanAccessor() {
@Override public long getProcessCpuTime() {
return sunOs.getProcessCpuTime();
}

@Override public long getTotalPhysicalMemorySize() {
return sunOs.getTotalPhysicalMemorySize();
}
};
}
}
Expand All @@ -678,10 +659,6 @@ private SunOperatingSystemMXBeanAccessor sunOperatingSystemMXBeanAccessor() {
@Override public long getProcessCpuTime() {
return U.<Long>property(os, "processCpuTime");
}

@Override public long getTotalPhysicalMemorySize() {
return U.<Long>property(os, "totalPhysicalMemorySize");
}
};
}

Expand Down Expand Up @@ -806,9 +783,6 @@ public void update(MemoryUsage usage) {
private interface SunOperatingSystemMXBeanAccessor {
/** @see com.sun.management.OperatingSystemMXBean#getProcessCpuTime() */
long getProcessCpuTime();

/** @see com.sun.management.OperatingSystemMXBean#getTotalPhysicalMemorySize() */
long getTotalPhysicalMemorySize();
}

/** Custom metrics impl. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_JVM_PID;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_MACS;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_OFFHEAP_SIZE;
import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PHY_RAM;
import static org.apache.ignite.internal.util.GridUnsafe.putObjectVolatile;
import static org.apache.ignite.internal.util.GridUnsafe.staticFieldBase;
import static org.apache.ignite.internal.util.GridUnsafe.staticFieldOffset;
Expand Down Expand Up @@ -8113,7 +8112,7 @@ public static BinaryContext binaryContext(
*/
@SuppressWarnings("ConstantConditions")
public static String validateRamUsage(GridKernalContext ctx) {
long ram = ctx.discovery().localNode().attribute(ATTR_PHY_RAM);
long ram = getTotalMemoryAvailable();

if (ram != -1) {
String macs = ctx.discovery().localNode().attribute(ATTR_MACS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import org.apache.ignite.testframework.LogListener;
import org.junit.Test;

import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_PHY_RAM;
import static org.apache.ignite.internal.util.IgniteUtils.getTotalMemoryAvailable;
import static org.apache.ignite.testframework.GridTestUtils.waitForCondition;

/**
Expand Down Expand Up @@ -221,7 +221,7 @@ public void testConfigurationOomError() throws Exception {

IgniteEx ignite0 = startGrid(0);

long ram = ignite0.localNode().attribute(ATTR_PHY_RAM);
long ram = getTotalMemoryAvailable();

IgniteConfiguration cfg = getConfiguration(getTestIgniteInstanceName(1))
.setDataStorageConfiguration(new DataStorageConfiguration()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@

package org.apache.ignite.internal.metric;

import org.apache.ignite.internal.IgniteNodeAttributes;
import org.apache.ignite.internal.processors.metric.GridMetricManager;
import org.apache.ignite.internal.processors.metric.MetricRegistryImpl;
import org.apache.ignite.spi.metric.DoubleMetric;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
import org.junit.Test;

import static org.apache.ignite.internal.util.IgniteUtils.getTotalMemoryAvailable;

/** */
public class SystemMetricsTest extends GridCommonAbstractTest {
/** {@inheritDoc} */
Expand Down Expand Up @@ -55,11 +56,11 @@ public void testCpuLoadMetric() {
}

/**
* Checks that the total physical memory node attribute has a positive value.
* Checks that the total physical memory has a positive value.
*/
@Test
public void testTotalSystemMemory() {
long phyMem = (long)grid(0).context().nodeAttribute(IgniteNodeAttributes.ATTR_PHY_RAM);
long phyMem = getTotalMemoryAvailable();

assertTrue("Total system memory size is negative: " + phyMem, phyMem >= 0);
}
Expand Down
Loading