Search in sources :

Example 1 with VMStats50

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()));
}
Also used : ProcessStats(org.apache.geode.internal.statistics.platform.ProcessStats) Method(java.lang.reflect.Method) VMStats50(org.apache.geode.internal.stats50.VMStats50) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 2 with VMStats50

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);
                    }
                }
            }
        }
    }
}
Also used : StatisticsType(org.apache.geode.StatisticsType) VMStatsContract(org.apache.geode.internal.statistics.VMStatsContract) Statistics(org.apache.geode.Statistics) LRUStatistics(org.apache.geode.internal.cache.lru.LRUStatistics) VMStats50(org.apache.geode.internal.stats50.VMStats50)

Example 3 with VMStats50

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());
}
Also used : Method(java.lang.reflect.Method) File(java.io.File) VMStats50(org.apache.geode.internal.stats50.VMStats50) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 4 with VMStats50

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);
    }
}
Also used : FunctionServiceStats(org.apache.geode.internal.cache.execute.FunctionServiceStats) CachePerfStats(org.apache.geode.internal.cache.CachePerfStats) MemberMBeanBridge(org.apache.geode.management.internal.beans.MemberMBeanBridge) VMStatsContract(org.apache.geode.internal.statistics.VMStatsContract) DLockStats(org.apache.geode.distributed.internal.locks.DLockStats) DiskStoreStats(org.apache.geode.internal.cache.DiskStoreStats) PartitionedRegionStats(org.apache.geode.internal.cache.PartitionedRegionStats) DistributionStats(org.apache.geode.distributed.internal.DistributionStats) VMStats50(org.apache.geode.internal.stats50.VMStats50)

Aggregations

VMStats50 (org.apache.geode.internal.stats50.VMStats50)4 Method (java.lang.reflect.Method)2 VMStatsContract (org.apache.geode.internal.statistics.VMStatsContract)2 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)2 Test (org.junit.Test)2 File (java.io.File)1 Statistics (org.apache.geode.Statistics)1 StatisticsType (org.apache.geode.StatisticsType)1 DistributionStats (org.apache.geode.distributed.internal.DistributionStats)1 DLockStats (org.apache.geode.distributed.internal.locks.DLockStats)1 CachePerfStats (org.apache.geode.internal.cache.CachePerfStats)1 DiskStoreStats (org.apache.geode.internal.cache.DiskStoreStats)1 PartitionedRegionStats (org.apache.geode.internal.cache.PartitionedRegionStats)1 FunctionServiceStats (org.apache.geode.internal.cache.execute.FunctionServiceStats)1 LRUStatistics (org.apache.geode.internal.cache.lru.LRUStatistics)1 ProcessStats (org.apache.geode.internal.statistics.platform.ProcessStats)1 MemberMBeanBridge (org.apache.geode.management.internal.beans.MemberMBeanBridge)1 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)1