Search in sources :

Example 36 with StreamOperatorTask

use of org.apache.samza.task.StreamOperatorTask in project samza by apache.

the class TestJoinOperator method joinNoMatchReverse.

@Test
public void joinNoMatchReverse() throws Exception {
    StreamApplicationDescriptorImpl streamAppDesc = this.getTestJoinStreamGraph(new TestJoinFunction());
    StreamOperatorTask sot = createStreamOperatorTask(new SystemClock(), streamAppDesc);
    List<Integer> output = new ArrayList<>();
    MessageCollector messageCollector = envelope -> output.add((Integer) envelope.getMessage());
    // push messages to second stream
    numbers.forEach(n -> sot.processAsync(new SecondStreamIME(n, n), messageCollector, taskCoordinator, taskCallback));
    // push messages to first stream with different keys
    numbers.forEach(n -> sot.processAsync(new FirstStreamIME(n + 100, n), messageCollector, taskCoordinator, taskCallback));
    assertTrue(output.isEmpty());
}
Also used : StreamApplicationDescriptorImpl(org.apache.samza.application.descriptors.StreamApplicationDescriptorImpl) StreamOperatorTask(org.apache.samza.task.StreamOperatorTask) GenericSystemDescriptor(org.apache.samza.system.descriptors.GenericSystemDescriptor) TaskModel(org.apache.samza.job.model.TaskModel) HashMap(java.util.HashMap) SystemStreamPartition(org.apache.samza.system.SystemStreamPartition) GenericInputDescriptor(org.apache.samza.system.descriptors.GenericInputDescriptor) ArrayList(java.util.ArrayList) StreamTestUtils(org.apache.samza.testUtils.StreamTestUtils) MessageCollector(org.apache.samza.task.MessageCollector) SystemStream(org.apache.samza.system.SystemStream) Matchers.eq(org.mockito.Matchers.eq) MockContext(org.apache.samza.context.MockContext) Duration(java.time.Duration) Map(java.util.Map) MapConfig(org.apache.samza.config.MapConfig) IntegerSerde(org.apache.samza.serializers.IntegerSerde) TaskCallback(org.apache.samza.task.TaskCallback) ImmutableSet(com.google.common.collect.ImmutableSet) IncomingMessageEnvelope(org.apache.samza.system.IncomingMessageEnvelope) Partition(org.apache.samza.Partition) Set(java.util.Set) Assert.assertTrue(org.junit.Assert.assertTrue) Clock(org.apache.samza.util.Clock) Test(org.junit.Test) IOException(java.io.IOException) Mockito.times(org.mockito.Mockito.times) Mockito.when(org.mockito.Mockito.when) JoinFunction(org.apache.samza.operators.functions.JoinFunction) SamzaException(org.apache.samza.SamzaException) TaskCoordinator(org.apache.samza.task.TaskCoordinator) Mockito.verify(org.mockito.Mockito.verify) Context(org.apache.samza.context.Context) TimestampedValueSerde(org.apache.samza.operators.impl.store.TimestampedValueSerde) Matchers.any(org.mockito.Matchers.any) List(java.util.List) SystemClock(org.apache.samza.util.SystemClock) TestClock(org.apache.samza.testUtils.TestClock) OutgoingMessageEnvelope(org.apache.samza.system.OutgoingMessageEnvelope) TestInMemoryStore(org.apache.samza.operators.impl.store.TestInMemoryStore) Config(org.apache.samza.config.Config) KVSerde(org.apache.samza.serializers.KVSerde) Assert.assertEquals(org.junit.Assert.assertEquals) MetricsRegistryMap(org.apache.samza.metrics.MetricsRegistryMap) Mockito.mock(org.mockito.Mockito.mock) SystemClock(org.apache.samza.util.SystemClock) StreamApplicationDescriptorImpl(org.apache.samza.application.descriptors.StreamApplicationDescriptorImpl) StreamOperatorTask(org.apache.samza.task.StreamOperatorTask) MessageCollector(org.apache.samza.task.MessageCollector) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

StreamOperatorTask (org.apache.samza.task.StreamOperatorTask)36 Partition (org.apache.samza.Partition)33 SystemStreamPartition (org.apache.samza.system.SystemStreamPartition)33 Test (org.junit.Test)33 Config (org.apache.samza.config.Config)32 MetricsRegistryMap (org.apache.samza.metrics.MetricsRegistryMap)32 MessageCollector (org.apache.samza.task.MessageCollector)32 ArrayList (java.util.ArrayList)31 List (java.util.List)31 IncomingMessageEnvelope (org.apache.samza.system.IncomingMessageEnvelope)31 OutgoingMessageEnvelope (org.apache.samza.system.OutgoingMessageEnvelope)31 ImmutableSet (com.google.common.collect.ImmutableSet)30 Duration (java.time.Duration)30 SystemStream (org.apache.samza.system.SystemStream)30 TaskCoordinator (org.apache.samza.task.TaskCoordinator)30 TestClock (org.apache.samza.testUtils.TestClock)30 Mockito.mock (org.mockito.Mockito.mock)30 Mockito.when (org.mockito.Mockito.when)30 HashMap (java.util.HashMap)25 Map (java.util.Map)24