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();
}
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();
}
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);
}
}
}
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;
}
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);
}
Aggregations