Search in sources :

Example 11 with CounterName

use of org.apache.beam.runners.dataflow.worker.counters.CounterName in project beam by apache.

the class DataflowCounterUpdateExtractorTest method testExtractUnstructuredNameCorrectly.

@Test
public void testExtractUnstructuredNameCorrectly() {
    CounterName unstructuredName = CounterName.named(COUNTER_NAME);
    Counter<?, ?> unstructured = counterFactory.intSum(unstructuredName);
    // unstructured counter should not have a structured name
    CounterUpdate counterUpdate = unstructured.extractUpdate(true, DataflowCounterUpdateExtractor.INSTANCE);
    assertThat(counterUpdate, not(hasStructuredName()));
    assertThat(counterUpdate, hasName(COUNTER_NAME));
}
Also used : CounterName(org.apache.beam.runners.dataflow.worker.counters.CounterName) CounterUpdate(com.google.api.services.dataflow.model.CounterUpdate) NameContextsForTests.nameContextForTest(org.apache.beam.runners.dataflow.worker.NameContextsForTests.nameContextForTest) Test(org.junit.Test)

Example 12 with CounterName

use of org.apache.beam.runners.dataflow.worker.counters.CounterName in project beam by apache.

the class DataflowCounterUpdateExtractorTest method testExtractStructuredNameCorrectly.

@Test
public void testExtractStructuredNameCorrectly() {
    CounterName unstructuredName = CounterName.named(COUNTER_NAME);
    CounterName structuredOriginalName = unstructuredName.withOriginalName(nameContextForTest());
    CounterName structuredSystemName = unstructuredName.withSystemName(nameContextForTest());
    Counter<?, ?> structuredOriginal = counterFactory.intSum(structuredOriginalName);
    Counter<?, ?> structuredSystem = counterFactory.intSum(structuredSystemName);
    // Other two counters should be structured and should not conflict
    assertThat(structuredOriginal.extractUpdate(true, DataflowCounterUpdateExtractor.INSTANCE), hasStructuredName(structuredOriginalName, "SUM"));
    assertThat(structuredSystem.extractUpdate(true, DataflowCounterUpdateExtractor.INSTANCE), hasStructuredName(structuredSystemName, "SUM"));
}
Also used : CounterName(org.apache.beam.runners.dataflow.worker.counters.CounterName) NameContextsForTests.nameContextForTest(org.apache.beam.runners.dataflow.worker.NameContextsForTests.nameContextForTest) Test(org.junit.Test)

Aggregations

CounterName (org.apache.beam.runners.dataflow.worker.counters.CounterName)12 Test (org.junit.Test)9 CounterUpdate (com.google.api.services.dataflow.model.CounterUpdate)4 NameContextsForTests.nameContextForTest (org.apache.beam.runners.dataflow.worker.NameContextsForTests.nameContextForTest)4 CounterDistribution (org.apache.beam.runners.dataflow.worker.counters.CounterFactory.CounterDistribution)4 DataflowPipelineDebugOptions (org.apache.beam.runners.dataflow.options.DataflowPipelineDebugOptions)3 Counter (org.apache.beam.runners.dataflow.worker.counters.Counter)3 DataflowExecutionStateTracker (org.apache.beam.runners.dataflow.worker.DataflowExecutionContext.DataflowExecutionStateTracker)2 DataflowExecutionState (org.apache.beam.runners.dataflow.worker.DataflowOperationContext.DataflowExecutionState)2 TestDataflowExecutionState (org.apache.beam.runners.dataflow.worker.TestOperationContext.TestDataflowExecutionState)2 NameContext (org.apache.beam.runners.dataflow.worker.counters.NameContext)2 TestReader (org.apache.beam.runners.dataflow.worker.util.common.worker.ExecutorTestUtils.TestReader)2 PipelineOptions (org.apache.beam.sdk.options.PipelineOptions)2 CounterMetadata (com.google.api.services.dataflow.model.CounterMetadata)1 CounterStructuredName (com.google.api.services.dataflow.model.CounterStructuredName)1 CounterStructuredNameAndMetadata (com.google.api.services.dataflow.model.CounterStructuredNameAndMetadata)1 Source (com.google.api.services.dataflow.model.Source)1 SplitInt64 (com.google.api.services.dataflow.model.SplitInt64)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 Closeable (java.io.Closeable)1