use of org.apache.geode.internal.stats50.VMStats50 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.stats50.VMStats50 in project geode by apache.
the class MemberMBeanBridge method addVMStats.
public void addVMStats() {
VMStatsContract vmStatsContract = system.getStatSampler().getVMStats();
if (vmStatsContract != null && vmStatsContract instanceof VMStats50) {
VMStats50 vmStats50 = (VMStats50) vmStatsContract;
Statistics vmStats = vmStats50.getVMStats();
if (vmStats != null) {
vmStatsMonitor.addStatisticsToMonitor(vmStats);
}
Statistics vmHeapStats = vmStats50.getVMHeapStats();
if (vmHeapStats != null) {
vmStatsMonitor.addStatisticsToMonitor(vmHeapStats);
}
StatisticsType gcType = VMStats50.getGCType();
if (gcType != null) {
Statistics[] gcStats = system.findStatisticsByType(gcType);
if (gcStats != null && gcStats.length > 0) {
for (Statistics gcStat : gcStats) {
if (gcStat != null) {
gcMonitor.addStatisticsToMonitor(gcStat);
}
}
}
}
}
}
use of org.apache.geode.internal.stats50.VMStats50 in project geode by apache.
the class SimpleStatSamplerIntegrationTest method testBasics.
/**
* Tests the majority of getters and the basic functionality of the sampler.
*/
@Test
public void testBasics() throws Exception {
initStatisticsFactory();
SimpleStatSampler statSampler = getSimpleStatSampler();
assertTrue(statSampler.waitForInitialization(5000));
assertEquals(new File(System.getProperty(SimpleStatSampler.ARCHIVE_FILE_NAME_PROPERTY)), statSampler.getArchiveFileName());
assertEquals(0, statSampler.getArchiveFileSizeLimit());
assertEquals(0, statSampler.getArchiveDiskSpaceLimit());
assertEquals(SimpleStatSampler.DEFAULT_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);
assertTrue(statsCount > 0);
Assert.assertEquals(getStatisticsManager().getId(), statSampler.getSystemId());
assertTrue(statSampler.getSystemStartTime() <= System.currentTimeMillis());
assertEquals(SocketCreator.getHostName(SocketCreator.getLocalHost()), statSampler.getSystemDirectoryPath());
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 = null;
try {
getProcessStats = SimpleStatSampler.class.getMethod("getProcessStats");
fail("SimpleStatSampler should not have the method getProcessStats()");
} catch (NoSuchMethodException exected) {
// passed
}
assertNull(getProcessStats);
assertEquals("Unknown product", statSampler.getProductDescription());
}
use of org.apache.geode.internal.stats50.VMStats50 in project geode by apache.
the class MemberLevelStatsJUnitTest method init.
public void init() {
cachePerfStats = new CachePerfStats(system);
funcServiceStats = new FunctionServiceStats(system, "FunctionExecution");
long statId = OSProcess.getId();
distributionStats = new DistributionStats(system, statId);
DistributionStats.enableClockStats = true;
dlockStats = new DLockStats(system, statId);
bridge = new MemberMBeanBridge();
bridge.addCacheStats(cachePerfStats);
bridge.addFunctionStats(funcServiceStats);
bridge.addDistributionStats(distributionStats);
bridge.addLockServiceStats(dlockStats);
VMStatsContract vmstats = system.getStatSampler().getVMStats();
assertTrue(vmstats instanceof VMStats50);
bridge.addSystemStats();
bridge.addVMStats();
for (int i = 0; i < 4; i++) {
DiskStoreStats stats = new DiskStoreStats(system, name.getMethodName() + i);
diskStatsList.add(stats);
bridge.addDiskStoreStats(stats);
}
for (int i = 0; i < 4; i++) {
PartitionedRegionStats stats = new PartitionedRegionStats(system, name.getMethodName() + i);
parRegionStatsList.add(stats);
bridge.addPartionRegionStats(stats);
}
}
Aggregations