Search in sources :

Example 36 with TestProcessorContext

use of com.hazelcast.jet.core.test.TestProcessorContext in project hazelcast by hazelcast.

the class ProcessorTaskletTest_Blocking method setUp.

@Before
public void setUp() {
    this.processor = new PassThroughProcessor();
    this.context = new TestProcessorContext();
    this.mockInput = IntStream.range(0, MOCK_INPUT_SIZE).boxed().collect(toList());
    this.instreams = new ArrayList<>();
    this.outstreams = new ArrayList<>();
}
Also used : TestProcessorContext(com.hazelcast.jet.core.test.TestProcessorContext) Before(org.junit.Before)

Example 37 with TestProcessorContext

use of com.hazelcast.jet.core.test.TestProcessorContext in project hazelcast by hazelcast.

the class ProcessorTaskletTest_Watermarks method setUp.

@Before
public void setUp() {
    this.processor = new ProcessorWithWatermarks();
    this.context = new TestProcessorContext();
    this.instreams = new ArrayList<>();
    this.outstreams = new ArrayList<>();
    this.snapshotCollector = new MockOutboundCollector(0);
}
Also used : TestProcessorContext(com.hazelcast.jet.core.test.TestProcessorContext) Before(org.junit.Before)

Example 38 with TestProcessorContext

use of com.hazelcast.jet.core.test.TestProcessorContext in project hazelcast by hazelcast.

the class AbstractProcessorTest method before.

@Before
public void before() throws Exception {
    inbox = new TestInbox();
    inbox.add(MOCK_ITEM);
    int[] capacities = new int[OUTBOX_BUCKET_COUNT];
    Arrays.fill(capacities, 1);
    outbox = new TestOutbox(capacities);
    final Processor.Context ctx = new TestProcessorContext();
    p = new RegisteringMethodCallsP();
    p.init(outbox, ctx);
    tryProcessP = new SpecializedByOrdinalP();
    tryProcessP.init(outbox, ctx);
    nothingOverriddenP = new NothingOverriddenP();
    nothingOverriddenP.init(outbox, ctx);
}
Also used : TestInbox(com.hazelcast.jet.core.test.TestInbox) TestOutbox(com.hazelcast.jet.core.test.TestOutbox) TestProcessorContext(com.hazelcast.jet.core.test.TestProcessorContext) Before(org.junit.Before)

Example 39 with TestProcessorContext

use of com.hazelcast.jet.core.test.TestProcessorContext in project hazelcast by hazelcast.

the class StreamEventJournalP_WmCoalescingTest method when_allPartitionsIdleAndThenRecover_then_wmOutput.

@Test
public void when_allPartitionsIdleAndThenRecover_then_wmOutput() throws Exception {
    // Insert to map in parallel to verifyProcessor.
    CountDownLatch latch = new CountDownLatch(1);
    Thread updatingThread = new Thread(() -> uncheckRun(() -> {
        // We will start after a delay so that the source will first become idle and then recover.
        latch.await();
        for (; ; ) {
            map.put(partitionKeys[0], 12);
            Thread.sleep(100);
        }
    }));
    updatingThread.start();
    Processor processor = createSupplier(asList(0, 1), 2000).get();
    TestOutbox outbox = new TestOutbox(1024);
    Queue<Object> outbox0 = outbox.queue(0);
    processor.init(outbox, new TestProcessorContext().setHazelcastInstance(instance));
    assertTrueEventually(() -> {
        processor.complete();
        // after we have the IDLE_MESSAGE, release the latch to let the other thread produce events
        if (IDLE_MESSAGE.equals(outbox0.peek())) {
            latch.countDown();
        }
        assertEquals(asList(IDLE_MESSAGE, wm(12), 12), outbox0.stream().distinct().collect(toList()));
    });
    updatingThread.interrupt();
    updatingThread.join();
}
Also used : Processor(com.hazelcast.jet.core.Processor) TestOutbox(com.hazelcast.jet.core.test.TestOutbox) TestProcessorContext(com.hazelcast.jet.core.test.TestProcessorContext) CountDownLatch(java.util.concurrent.CountDownLatch) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 40 with TestProcessorContext

use of com.hazelcast.jet.core.test.TestProcessorContext in project hazelcast by hazelcast.

the class StreamJmsPTest method initializeProcessor.

private void initializeProcessor(String destinationName, boolean isQueue, FunctionEx<Message, String> projectionFn) throws Exception {
    processorConnection = getConnectionFactory().createConnection();
    processorConnection.start();
    FunctionEx<Session, MessageConsumer> consumerFn = s -> s.createConsumer(isQueue ? s.createQueue(destinationName) : s.createTopic(destinationName));
    if (projectionFn == null) {
        projectionFn = m -> ((TextMessage) m).getText();
    }
    processor = new StreamJmsP<>(processorConnection, consumerFn, Message::getJMSMessageID, projectionFn, noEventTime(), NONE);
    outbox = new TestOutbox(1);
    processor.init(outbox, new TestProcessorContext());
}
Also used : Address(com.hazelcast.cluster.Address) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) RunWith(org.junit.runner.RunWith) TestOutbox(com.hazelcast.jet.core.test.TestOutbox) StreamSource(com.hazelcast.jet.pipeline.StreamSource) ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) Function(java.util.function.Function) TestProcessorContext(com.hazelcast.jet.core.test.TestProcessorContext) ArrayList(java.util.ArrayList) Collections.singletonList(java.util.Collections.singletonList) Session(javax.jms.Session) Arrays.asList(java.util.Arrays.asList) After(org.junit.After) MessageProducer(javax.jms.MessageProducer) ClassRule(org.junit.ClassRule) Message(javax.jms.Message) ProcessorSupplier(com.hazelcast.jet.core.ProcessorSupplier) EventTimePolicy.noEventTime(com.hazelcast.jet.core.EventTimePolicy.noEventTime) FunctionEx(com.hazelcast.function.FunctionEx) Connection(javax.jms.Connection) JetTestSupport(com.hazelcast.jet.core.JetTestSupport) TextMessage(javax.jms.TextMessage) ProcessorMetaSupplier(com.hazelcast.jet.core.ProcessorMetaSupplier) Test(org.junit.Test) Category(org.junit.experimental.categories.Category) EmbeddedActiveMQResource(org.apache.activemq.artemis.junit.EmbeddedActiveMQResource) NONE(com.hazelcast.jet.config.ProcessingGuarantee.NONE) Sources(com.hazelcast.jet.pipeline.Sources) List(java.util.List) MessageConsumer(javax.jms.MessageConsumer) Destination(javax.jms.Destination) HazelcastParallelClassRunner(com.hazelcast.test.HazelcastParallelClassRunner) StreamSourceTransform(com.hazelcast.jet.impl.pipeline.transform.StreamSourceTransform) Queue(java.util.Queue) ConnectionFactory(javax.jms.ConnectionFactory) Assert.assertEquals(org.junit.Assert.assertEquals) MessageConsumer(javax.jms.MessageConsumer) TestOutbox(com.hazelcast.jet.core.test.TestOutbox) TestProcessorContext(com.hazelcast.jet.core.test.TestProcessorContext) Session(javax.jms.Session)

Aggregations

TestProcessorContext (com.hazelcast.jet.core.test.TestProcessorContext)58 TestOutbox (com.hazelcast.jet.core.test.TestOutbox)50 Test (org.junit.Test)39 QuickTest (com.hazelcast.test.annotation.QuickTest)22 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)21 Processor (com.hazelcast.jet.core.Processor)17 TestInbox (com.hazelcast.jet.core.test.TestInbox)16 Watermark (com.hazelcast.jet.core.Watermark)13 ArrayList (java.util.ArrayList)12 Before (org.junit.Before)10 Entry (java.util.Map.Entry)9 Outbox (com.hazelcast.jet.core.Outbox)7 Context (com.hazelcast.jet.core.Processor.Context)6 ProcessorMetaSupplier (com.hazelcast.jet.core.ProcessorMetaSupplier)6 ProcessorSupplier (com.hazelcast.jet.core.ProcessorSupplier)6 FunctionEx (com.hazelcast.function.FunctionEx)4 SimpleTestInClusterSupport (com.hazelcast.jet.SimpleTestInClusterSupport)4 Traverser (com.hazelcast.jet.Traverser)4 LongAccumulator (com.hazelcast.jet.accumulator.LongAccumulator)4 HashSet (java.util.HashSet)4