use of org.apache.geode.internal.statistics.platform.ProcessStats in project geode by apache.
the class GemFireStatSamplerIntegrationTest method testBasics.
/**
* Tests the majority of getters and the basic functionality of the sampler.
*
* This test is skipped when running on Windows 7 because ProcessStats is not created for this OS.
* See #45395.
*/
@Test
public void testBasics() throws Exception {
final String osName = System.getProperty("os.name", "unknown");
assumeFalse(osName.equals("Windows 7"));
connect(createGemFireProperties());
GemFireStatSampler statSampler = getGemFireStatSampler();
assertTrue(statSampler.waitForInitialization(5000));
assertEquals(0, statSampler.getArchiveFileSizeLimit());
assertEquals(0, statSampler.getArchiveDiskSpaceLimit());
assertEquals(STAT_SAMPLE_RATE, statSampler.getSampleRate());
assertEquals(true, statSampler.isSamplingEnabled());
int statsCount = statSampler.getStatisticsManager().getStatisticsCount();
assertEquals(statsCount, statSampler.getStatisticsModCount());
assertEquals(statsCount, statSampler.getStatisticsManager().getStatisticsCount());
assertEquals(statsCount, statSampler.getStatistics().length);
Assert.assertEquals(getStatisticsManager().getId(), statSampler.getSystemId());
assertTrue(statSampler.getSystemStartTime() < System.currentTimeMillis());
Assert.assertEquals(SocketCreator.getHostName(SocketCreator.getLocalHost()), statSampler.getSystemDirectoryPath());
AllStatistics allStats = new AllStatistics(statSampler);
VMStatsContract vmStats = statSampler.getVMStats();
assertNotNull(vmStats);
assertTrue(vmStats instanceof VMStats50);
/*
* NOTE: VMStats50 is not an instance of Statistics but instead its instance contains 3
* instances of Statistics: 1) vmStats 2) heapMemStats 3) nonHeapMemStats
*/
Method getProcessStats = getGemFireStatSampler().getClass().getMethod("getProcessStats");
assertNotNull(getProcessStats);
ProcessStats processStats = statSampler.getProcessStats();
if (osName.equals("SunOS")) {
assertNotNull(processStats);
assertTrue(PureJavaMode.osStatsAreAvailable());
assertTrue(allStats.containsStatisticsType("SolarisProcessStats"));
assertTrue(allStats.containsStatisticsType("SolarisSystemStats"));
} else if (osName.startsWith("Windows")) {
// fails on Windows 7: 45395 "ProcessStats are not created on Windows 7"
assertNotNull("ProcessStats were not created on " + osName, processStats);
assertTrue(PureJavaMode.osStatsAreAvailable());
assertTrue(allStats.containsStatisticsType("WindowsProcessStats"));
assertTrue(allStats.containsStatisticsType("WindowsSystemStats"));
} else if (osName.startsWith("Linux")) {
assertNotNull(processStats);
assertTrue(PureJavaMode.osStatsAreAvailable());
assertTrue(allStats.containsStatisticsType("LinuxProcessStats"));
assertTrue(allStats.containsStatisticsType("LinuxSystemStats"));
} else if (osName.equals("Mac OS X")) {
assertNull(processStats);
assertFalse(PureJavaMode.osStatsAreAvailable());
assertFalse(allStats.containsStatisticsType("OSXProcessStats"));
assertFalse(allStats.containsStatisticsType("OSXSystemStats"));
} else {
assertNull(processStats);
}
String productDesc = statSampler.getProductDescription();
assertTrue(productDesc.contains(GemFireVersion.getGemFireVersion()));
assertTrue(productDesc.contains(GemFireVersion.getBuildId()));
assertTrue(productDesc.contains(GemFireVersion.getSourceDate()));
}
use of org.apache.geode.internal.statistics.platform.ProcessStats in project geode by apache.
the class MemberMBeanBridge method addSystemStats.
public void addSystemStats() {
GemFireStatSampler sampler = system.getStatSampler();
ProcessStats processStats = sampler.getProcessStats();
StatSamplerStats samplerStats = sampler.getStatSamplerStats();
if (processStats != null) {
systemStatsMonitor.addStatisticsToMonitor(processStats.getStatistics());
}
if (samplerStats != null) {
systemStatsMonitor.addStatisticsToMonitor(samplerStats.getStats());
}
}
use of org.apache.geode.internal.statistics.platform.ProcessStats in project geode by apache.
the class MemberHealthEvaluatorJUnitTest method testCheckVMProcessSize.
/**
* Tests that we are in {@link GemFireHealth#OKAY_HEALTH okay} health if the VM's process size is
* too big.
*
* @see MemberHealthEvaluator#checkVMProcessSize
*/
@Test
public void testCheckVMProcessSize() throws InterruptedException {
if (PureJavaMode.osStatsAreAvailable()) {
GemFireStatSampler sampler = system.getStatSampler();
assertNotNull(sampler);
// fix: remove infinite wait
sampler.waitForInitialization(10000);
ProcessStats stats = sampler.getProcessStats();
assertNotNull(stats);
List status = new ArrayList();
long threshold = stats.getProcessSize() * 2;
if (threshold <= 0) {
// The process size is zero on some Linux versions
return;
}
GemFireHealthConfig config = new GemFireHealthConfigImpl(null);
config.setMaxVMProcessSize(threshold);
MemberHealthEvaluator eval = new MemberHealthEvaluator(config, this.system.getDistributionManager());
eval.evaluate(status);
assertTrue(status.isEmpty());
status = new ArrayList();
long processSize = stats.getProcessSize();
threshold = processSize / 2;
assertTrue("Threshold (" + threshold + ") is > 0. " + "Process size is " + processSize, threshold > 0);
config = new GemFireHealthConfigImpl(null);
config.setMaxVMProcessSize(threshold);
eval = new MemberHealthEvaluator(config, this.system.getDistributionManager());
eval.evaluate(status);
assertEquals(1, status.size());
AbstractHealthEvaluator.HealthStatus ill = (AbstractHealthEvaluator.HealthStatus) status.get(0);
assertEquals(GemFireHealth.OKAY_HEALTH, ill.getHealthCode());
assertTrue(ill.getDiagnosis().indexOf("The size of this VM") != -1);
}
}
Aggregations