Package org.apache.s4.base

Examples of org.apache.s4.base.Event


        Assert.assertEquals("be=2;da=2;doobie=5;not=1;or=1;to=2;", results);

    }

    private void injectSentence(Injector injector, TCPEmitter emitter, String sentence) throws InterruptedException {
        Event event;
        event = new Event();
        event.setStreamId("inputStream");
        event.put("sentence", String.class, sentence);
        emitter.send(
                0,
                injector.getInstance(SerializerDeserializerFactory.class)
                        .createSerializerDeserializer(Thread.currentThread().getContextClassLoader()).serialize(event));
    }
View Full Code Here


                new MockCoreModuleWithFileBaseCheckpointingBackend(), new AppModule(getClass().getClassLoader()));
        TestApp app = injector.getInstance(TestApp.class);
        app.init();
        app.start();

        Event event = new Event();
        event.setStreamId("stream1");
        event.put("command", String.class, "setValue1");
        event.put("value", String.class, "message1");

        app.testStream.receiveEvent(event);

        signalValue1Set.await();

        StatefulTestPE pe = (StatefulTestPE) app.getPE("statefulPE1").getInstanceForKey("X");

        Assert.assertEquals("message1", pe.getValue1());
        Assert.assertEquals("", pe.getValue2());

        // 3. generate a checkpoint event
        event = new Event();
        event.setStreamId("stream1");
        event.put("command", String.class, "checkpoint");
        app.testStream.receiveEvent(event);
        Assert.assertTrue(signalCheckpointed.await(10, TimeUnit.SECONDS));

        // NOTE: the backend has asynchronous save operations
        Thread.sleep(1000);
View Full Code Here

        TestApp app = injector.getInstance(TestApp.class);
        app.count = 2; // One for the event, another for the timer
        app.init();
        app.start();

        Event event = new Event();
        event.setStreamId(STREAM_NAME);
        app.testStream.receiveEvent(event);

        /*
         * This must raise a timeout, since the onTime() event is blocked waiting for the onEvent() call to finish. If
         * it completes before the timeout, it means onEvent() and onTime() weren't synchronized
View Full Code Here

        TestTimeWindowedApp app = injector.getInstance(TestTimeWindowedApp.class);
        app.init();
        app.start();

        for (int i = 0; i < NB_EVENTS; i++) {
            Event e = new Event();
            e.setStreamId(STREAM_NAME);
            e.put("value", Integer.class, (Integer) i);
            app.stream1.receiveEvent(e);
        }

        try {
            Assert.assertTrue(signalAllEventsProcessed.await(30, TimeUnit.SECONDS));
View Full Code Here

        String results = new String(zk.getData("/results", false, null));
        Assert.assertEquals("be=2;da=2;doobie=5;not=1;or=1;to=2;", results);
    }

    public void injectSentence(String sentence) throws IOException, InterruptedException {
        Event event = new Event();
        event.setStreamId("inputStream");
        event.put("sentence", String.class, sentence);

        // NOTE: we send to partition 0 since partition 1 hosts the emitter
        emitter.send(
                0,
                injector.getInstance(SerializerDeserializerFactory.class)
View Full Code Here

        public void run() {
            try {
                for (int partition = 0; partition < emitter.getPartitionCount(); partition++) {
                    for (int i = 0; i < numMessages; i++) {
                        byte[] message = (new String("message-" + i)).getBytes();
                        emitter.send(partition, new EventMessage(null, null, message));
                        Thread.sleep(interval);
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
View Full Code Here

        if (partition == localPartitionId) {
            /* Hey we are in the same JVM, don't use the network. */
            return false;
        }
        send(partition,
                new EventMessage(String.valueOf(event.getAppId()), event.getStreamName(), serDeser.serialize(event)));
        return true;
    }
View Full Code Here

            /* Don't use the comm layer when we send to the same partition. */
            if (localPartitionId != i)
                emitter.send(
                        i,
                        new EventMessage(String.valueOf(event.getAppId()), event.getStreamName(), serDeser
                                .serialize(event)));
        }
    }
View Full Code Here

                sendersByTopology.put(consumer.getClusterName(), sender);
            }
            // we must set the app id of the consumer app for correct dispatch within the consumer node
            // NOTE: this implies multiple serializations, there might be an optimization
            event.setAppId(consumer.getAppId());
            EventMessage eventMessage = new EventMessage(String.valueOf(event.getAppId()), event.getStreamName(),
                    serDeser.serialize(event));
            sender.send(hashKey, eventMessage);
        }

    }
View Full Code Here

        CommTestUtils.watchAndSignalCreation("/onEvent@" + time1, signalEvent1Processed, zk);

        CountDownLatch signalEvent1Triggered = new CountDownLatch(1);
        CommTestUtils.watchAndSignalCreation("/onTrigger[StringEvent]@" + time1, signalEvent1Triggered, zk);

        app.stream.receiveEvent(new EventMessage("-1", "stream", app.getSerDeser().serialize(new StringEvent(time1))));

        // check event processed
        Assert.assertTrue(signalEvent1Processed.await(5, TimeUnit.SECONDS));

        // return latch on trigger signal
View Full Code Here

TOP

Related Classes of org.apache.s4.base.Event

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.