Search in sources :

Example 1 with Statistics

use of org.apache.geode.Statistics in project geode by apache.

the class FileSystemStatsJUnitTest method createStats.

@Before
public void createStats() {
    StatisticsFactory statsFactory = mock(StatisticsFactory.class);
    statistics = mock(Statistics.class);
    when(statsFactory.createAtomicStatistics(any(), anyString())).thenReturn(statistics);
    stats = new FileSystemStats(statsFactory, "stats");
    ArgumentCaptor<StatisticsType> statsTypeCaptor = ArgumentCaptor.forClass(StatisticsType.class);
    verify(statsFactory).createAtomicStatistics(statsTypeCaptor.capture(), anyString());
    type = statsTypeCaptor.getValue();
}
Also used : StatisticsType(org.apache.geode.StatisticsType) StatisticsFactory(org.apache.geode.StatisticsFactory) Statistics(org.apache.geode.Statistics) Before(org.junit.Before)

Example 2 with Statistics

use of org.apache.geode.Statistics in project geode by apache.

the class LuceneIndexStatsJUnitTest method createStats.

@Before
public void createStats() {
    StatisticsFactory statsFactory = mock(StatisticsFactory.class);
    statistics = mock(Statistics.class);
    when(statsFactory.createAtomicStatistics(any(), anyString())).thenReturn(statistics);
    stats = new LuceneIndexStats(statsFactory, "region-index");
    ArgumentCaptor<StatisticsType> statsTypeCaptor = ArgumentCaptor.forClass(StatisticsType.class);
    verify(statsFactory).createAtomicStatistics(statsTypeCaptor.capture(), anyString());
    type = statsTypeCaptor.getValue();
}
Also used : StatisticsType(org.apache.geode.StatisticsType) StatisticsFactory(org.apache.geode.StatisticsFactory) Statistics(org.apache.geode.Statistics) Before(org.junit.Before)

Example 3 with Statistics

use of org.apache.geode.Statistics in project geode by apache.

the class DistributedSystemStatisticsIntegrationTest method testLongStatistics.

/**
   * Tests {@code long} statistics
   */
@Test
public void testLongStatistics() {
    Statistics stats = setUpLongStatistics(3);
    // Set/get some random long values
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < this.statNames.length; j++) {
            String statName = this.statNames[j];
            long value = this.random.nextLong();
            stats.setLong(statName, value);
            assertThat(stats.getLong(statName)).isEqualTo(value);
        }
    }
    // Increment by some random values
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < this.statNames.length; j++) {
            String statName = this.statNames[j];
            long inc = this.random.nextLong();
            long before = stats.getLong(statName);
            stats.incLong(statName, inc);
            assertThat(stats.getLong(statName)).isEqualTo(before + inc);
        }
    }
}
Also used : Statistics(org.apache.geode.Statistics) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 4 with Statistics

use of org.apache.geode.Statistics in project geode by apache.

the class DistributedSystemStatisticsIntegrationTest method setUpDoubleStatistics.

private Statistics setUpDoubleStatistics(final int count) {
    String[] descriptions = new String[] { "ONE", "TWO", "THREE" };
    StatisticDescriptor[] descriptors = new StatisticDescriptor[count];
    for (int i = 0; i < count; i++) {
        descriptors[i] = factory().createDoubleGauge(this.statNames[i], descriptions[i], "x");
    }
    StatisticsType type = factory().createType(getUniqueName(), "", descriptors);
    Statistics stats = factory().createStatistics(type, "Display");
    for (int i = 0; i < count; i++) {
        stats.setDouble(this.statNames[i], 0.0);
    }
    return stats;
}
Also used : StatisticsType(org.apache.geode.StatisticsType) Statistics(org.apache.geode.Statistics) StatisticDescriptor(org.apache.geode.StatisticDescriptor)

Example 5 with Statistics

use of org.apache.geode.Statistics in project geode by apache.

the class DistributedSystemStatisticsIntegrationTest method testAccessingIntStat.

/**
   * Tests that accessing an {@code int} stat throws the appropriate exceptions.
   */
@Test
public void testAccessingIntStat() {
    Statistics stats = setUpIntStatistics(1);
    assertThat(stats.getInt(this.statName1)).isEqualTo(0);
    assertThatThrownBy(() -> stats.getDouble(this.statName1)).isExactlyInstanceOf(IllegalArgumentException.class);
    assertThatThrownBy(() -> stats.getLong(this.statName1)).isExactlyInstanceOf(IllegalArgumentException.class);
    stats.setInt(this.statName1, 4);
    assertThatThrownBy(() -> stats.setDouble(this.statName1, 4.0)).isExactlyInstanceOf(IllegalArgumentException.class);
    assertThatThrownBy(() -> stats.setLong(this.statName1, 4L)).isExactlyInstanceOf(IllegalArgumentException.class);
    stats.incInt(this.statName1, 4);
    assertThatThrownBy(() -> stats.incDouble(this.statName1, 4.0)).isExactlyInstanceOf(IllegalArgumentException.class);
    assertThatThrownBy(() -> stats.incLong(this.statName1, 4L)).isExactlyInstanceOf(IllegalArgumentException.class);
}
Also used : Statistics(org.apache.geode.Statistics) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Aggregations

Statistics (org.apache.geode.Statistics)74 StatisticsType (org.apache.geode.StatisticsType)36 Test (org.junit.Test)34 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)29 StatisticDescriptor (org.apache.geode.StatisticDescriptor)18 File (java.io.File)17 ArrayList (java.util.ArrayList)12 List (java.util.List)12 StatValue (org.apache.geode.internal.statistics.StatArchiveReader.StatValue)11 TestStatArchiveWriter (org.apache.geode.internal.statistics.TestStatArchiveWriter)10 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)6 LRUStatistics (org.apache.geode.internal.cache.lru.LRUStatistics)6 HashMap (java.util.HashMap)5 LinuxProcFsStatistics (org.apache.geode.internal.statistics.platform.LinuxProcFsStatistics)5 Iterator (java.util.Iterator)4 Map (java.util.Map)4 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)4 MainWithChildrenRollingFileHandler (org.apache.geode.internal.io.MainWithChildrenRollingFileHandler)3 Before (org.junit.Before)3 IOException (java.io.IOException)2