Search in sources :

Example 1 with Counter

use of org.apache.beam.sdk.extensions.euphoria.core.client.accumulators.Counter in project beam by apache.

the class SingleValueCollectorTest method testBasicAccumulatorsAccess.

@Test
public void testBasicAccumulatorsAccess() {
    final AccumulatorProvider accumulators = accumulatorFactory.create();
    SingleValueCollector collector = new SingleValueCollector(accumulators, "test-no_op_name");
    Counter counter = collector.getCounter(TEST_COUNTER_NAME);
    Assert.assertNotNull(counter);
    Histogram histogram = collector.getHistogram(TEST_HISTOGRAM_NAME);
    Assert.assertNotNull(histogram);
// collector.getTimer() <- not yet supported
}
Also used : Histogram(org.apache.beam.sdk.extensions.euphoria.core.client.accumulators.Histogram) Counter(org.apache.beam.sdk.extensions.euphoria.core.client.accumulators.Counter) SingleJvmAccumulatorProvider(org.apache.beam.sdk.extensions.euphoria.core.testkit.accumulators.SingleJvmAccumulatorProvider) AccumulatorProvider(org.apache.beam.sdk.extensions.euphoria.core.client.accumulators.AccumulatorProvider) Test(org.junit.Test)

Example 2 with Counter

use of org.apache.beam.sdk.extensions.euphoria.core.client.accumulators.Counter in project beam by apache.

the class SingleJvmAccumulatorProviderTest method testBasicAccumulatorsFunction.

@Test
public void testBasicAccumulatorsFunction() {
    final AccumulatorProvider accumulators = accFactory.create();
    Counter counter = accumulators.getCounter(TEST_COUNTER_NAME);
    Assert.assertNotNull(counter);
    counter.increment();
    counter.increment(2);
    Map<String, Long> counterSnapshots = accFactory.getCounterSnapshots();
    long counterValue = counterSnapshots.get(TEST_COUNTER_NAME);
    Assert.assertEquals(3L, counterValue);
    Histogram histogram = accumulators.getHistogram(TEST_HISTOGRAM_NAME);
    Assert.assertNotNull(histogram);
    histogram.add(1);
    histogram.add(2, 2);
    Map<String, Map<Long, Long>> histogramSnapshots = accFactory.getHistogramSnapshots();
    Map<Long, Long> histogramValue = histogramSnapshots.get(TEST_HISTOGRAM_NAME);
    long numOfValuesOfOne = histogramValue.get(1L);
    Assert.assertEquals(1L, numOfValuesOfOne);
    long numOfValuesOfTwo = histogramValue.get(2L);
    Assert.assertEquals(2L, numOfValuesOfTwo);
// collector.getTimer() <- not yet supported
}
Also used : Histogram(org.apache.beam.sdk.extensions.euphoria.core.client.accumulators.Histogram) Counter(org.apache.beam.sdk.extensions.euphoria.core.client.accumulators.Counter) Map(java.util.Map) SingleJvmAccumulatorProvider(org.apache.beam.sdk.extensions.euphoria.core.testkit.accumulators.SingleJvmAccumulatorProvider) AccumulatorProvider(org.apache.beam.sdk.extensions.euphoria.core.client.accumulators.AccumulatorProvider) Test(org.junit.Test)

Example 3 with Counter

use of org.apache.beam.sdk.extensions.euphoria.core.client.accumulators.Counter in project beam by apache.

the class SingleValueCollectorTest method testBasicAccumulatorsFunction.

@Test
public void testBasicAccumulatorsFunction() {
    final AccumulatorProvider accumulators = accumulatorFactory.create();
    SingleValueCollector collector = new SingleValueCollector(accumulators, "test-no_op_name");
    Counter counter = collector.getCounter(TEST_COUNTER_NAME);
    Assert.assertNotNull(counter);
    counter.increment();
    counter.increment(2);
    Map<String, Long> counterSnapshots = accumulatorFactory.getCounterSnapshots();
    long counteValue = counterSnapshots.get(TEST_COUNTER_NAME);
    Assert.assertEquals(3L, counteValue);
    Histogram histogram = collector.getHistogram(TEST_HISTOGRAM_NAME);
    Assert.assertNotNull(histogram);
    histogram.add(1);
    histogram.add(2, 2);
    Map<String, Map<Long, Long>> histogramSnapshots = accumulatorFactory.getHistogramSnapshots();
    Map<Long, Long> histogramValue = histogramSnapshots.get(TEST_HISTOGRAM_NAME);
    long numOfValuesOfOne = histogramValue.get(1L);
    Assert.assertEquals(1L, numOfValuesOfOne);
    long numOfValuesOfTwo = histogramValue.get(2L);
    Assert.assertEquals(2L, numOfValuesOfTwo);
// collector.getTimer() <- not yet supported
}
Also used : Histogram(org.apache.beam.sdk.extensions.euphoria.core.client.accumulators.Histogram) Counter(org.apache.beam.sdk.extensions.euphoria.core.client.accumulators.Counter) Map(java.util.Map) SingleJvmAccumulatorProvider(org.apache.beam.sdk.extensions.euphoria.core.testkit.accumulators.SingleJvmAccumulatorProvider) AccumulatorProvider(org.apache.beam.sdk.extensions.euphoria.core.client.accumulators.AccumulatorProvider) Test(org.junit.Test)

Aggregations

AccumulatorProvider (org.apache.beam.sdk.extensions.euphoria.core.client.accumulators.AccumulatorProvider)3 Counter (org.apache.beam.sdk.extensions.euphoria.core.client.accumulators.Counter)3 Histogram (org.apache.beam.sdk.extensions.euphoria.core.client.accumulators.Histogram)3 SingleJvmAccumulatorProvider (org.apache.beam.sdk.extensions.euphoria.core.testkit.accumulators.SingleJvmAccumulatorProvider)3 Test (org.junit.Test)3 Map (java.util.Map)2