Search in sources :

Example 1 with Meter

use of org.apache.calcite.avatica.metrics.Meter in project calcite-avatica by apache.

the class DropwizardMetricsSystemTest method testMeter.

@Test
public void testMeter() {
    final String name = "meter";
    final com.codahale.metrics.Meter mockMeter = mock(com.codahale.metrics.Meter.class);
    when(mockRegistry.meter(name)).thenReturn(mockMeter);
    Meter meter = metrics.getMeter(name);
    final long count = 5;
    meter.mark(count);
    verify(mockMeter, times(1)).mark(count);
    meter.mark();
    verify(mockMeter, times(1)).mark();
}
Also used : Meter(org.apache.calcite.avatica.metrics.Meter) Test(org.junit.Test)

Example 2 with Meter

use of org.apache.calcite.avatica.metrics.Meter in project calcite-avatica by apache.

the class DropwizardMetricsSystemTest method testMeter.

@Test
public void testMeter() {
    final String name = "meter";
    final com.codahale.metrics.Meter mockMeter = mock(com.codahale.metrics.Meter.class);
    when(mockRegistry.meter(name)).thenReturn(mockMeter);
    Meter meter = metrics.getMeter(name);
    final long count = 5;
    meter.mark(count);
    verify(mockMeter, times(1)).mark(count);
    meter.mark();
    verify(mockMeter, times(1)).mark();
}
Also used : Meter(org.apache.calcite.avatica.metrics.Meter) Test(org.junit.Test)

Example 3 with Meter

use of org.apache.calcite.avatica.metrics.Meter in project calcite-avatica by apache.

the class NoopMetricsSystemTest method testNoNulls.

@Test
public void testNoNulls() {
    // The NOOP implementation should act as a real implementation, no "nulls" allowed.
    MetricsSystem metrics = NoopMetricsSystem.getInstance();
    Counter counter = metrics.getCounter("counter");
    counter.decrement();
    counter.increment();
    counter.decrement(1L);
    counter.increment(1L);
    Histogram histogram = metrics.getHistogram("histogram");
    histogram.update(1);
    histogram.update(1L);
    Timer timer = metrics.getTimer("timer");
    Context context = timer.start();
    context.close();
    Context contextTwo = timer.start();
    assertTrue("Timer's context should be a singleton", context == contextTwo);
    Meter meter = metrics.getMeter("meter");
    meter.mark();
    meter.mark(5L);
    metrics.register("gauge", new Gauge<Long>() {

        @Override
        public Long getValue() {
            return 42L;
        }
    });
}
Also used : Context(org.apache.calcite.avatica.metrics.Timer.Context) Histogram(org.apache.calcite.avatica.metrics.Histogram) Counter(org.apache.calcite.avatica.metrics.Counter) Timer(org.apache.calcite.avatica.metrics.Timer) Meter(org.apache.calcite.avatica.metrics.Meter) MetricsSystem(org.apache.calcite.avatica.metrics.MetricsSystem) Test(org.junit.Test)

Aggregations

Meter (org.apache.calcite.avatica.metrics.Meter)3 Test (org.junit.Test)3 Counter (org.apache.calcite.avatica.metrics.Counter)1 Histogram (org.apache.calcite.avatica.metrics.Histogram)1 MetricsSystem (org.apache.calcite.avatica.metrics.MetricsSystem)1 Timer (org.apache.calcite.avatica.metrics.Timer)1 Context (org.apache.calcite.avatica.metrics.Timer.Context)1