Search in sources :

Example 1 with HandlesSplits

use of org.apache.beam.fn.harness.HandlesSplits in project beam by apache.

the class PCollectionConsumerRegistryTest method testHandlesSplitsPassedToOriginalConsumer.

@Test
public void testHandlesSplitsPassedToOriginalConsumer() throws Exception {
    final String pCollectionA = "pCollectionA";
    final String pTransformIdA = "pTransformIdA";
    MetricsContainerStepMap metricsContainerRegistry = new MetricsContainerStepMap();
    PCollectionConsumerRegistry consumers = new PCollectionConsumerRegistry(metricsContainerRegistry, mock(ExecutionStateTracker.class));
    SplittingReceiver consumerA1 = mock(SplittingReceiver.class);
    consumers.register(pCollectionA, pTransformIdA, consumerA1, StringUtf8Coder.of());
    FnDataReceiver<WindowedValue<String>> wrapperConsumer = (FnDataReceiver<WindowedValue<String>>) (FnDataReceiver) consumers.getMultiplexingConsumer(pCollectionA);
    assertTrue(wrapperConsumer instanceof HandlesSplits);
    ((HandlesSplits) wrapperConsumer).getProgress();
    verify(consumerA1).getProgress();
    ((HandlesSplits) wrapperConsumer).trySplit(0.3);
    verify(consumerA1).trySplit(0.3);
}
Also used : MetricsContainerStepMap(org.apache.beam.runners.core.metrics.MetricsContainerStepMap) FnDataReceiver(org.apache.beam.sdk.fn.data.FnDataReceiver) ExecutionStateTracker(org.apache.beam.runners.core.metrics.ExecutionStateTracker) WindowedValue(org.apache.beam.sdk.util.WindowedValue) HandlesSplits(org.apache.beam.fn.harness.HandlesSplits) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

HandlesSplits (org.apache.beam.fn.harness.HandlesSplits)1 ExecutionStateTracker (org.apache.beam.runners.core.metrics.ExecutionStateTracker)1 MetricsContainerStepMap (org.apache.beam.runners.core.metrics.MetricsContainerStepMap)1 FnDataReceiver (org.apache.beam.sdk.fn.data.FnDataReceiver)1 WindowedValue (org.apache.beam.sdk.util.WindowedValue)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1