Package org.apache.s4.base

Examples of org.apache.s4.base.Event$Data


    }

    @Override
    public void receive(ByteBuffer message) {
        metrics.receivedEventFromCommLayer(message.array().length);
        Event event = (Event) serDeser.deserialize(message);

        String streamId = event.getStreamId();

        /*
         * Match streamId in event to the target stream and pass the event to the target stream. TODO: make this more
         * efficient for the case in which we send the same event to multiple PEs.
         */
 
View Full Code Here


        @Override
        public void run() {
            for (long i = 0; i < iterations; i++) {
                for (int j = 0; j < keysCount; j++) {
                    long currentCount = counter.incrementAndGet();
                    Event event = new Event();
                    event.put("key", int.class, j);
                    event.put("value", long.class, currentCount);
                    event.put("injector", Integer.class, getReceiver().getPartitionId());
                    // logger.info("{}/{}/{}/",
                    // new String[] { Thread.currentThread().getName(), String.valueOf(i), String.valueOf(j),
                    // String.valueOf(event.get("value")) });
                    remoteStream.put(event);
                    eventCountPerInterval.incrementAndGet();
View Full Code Here

    public void onEvent(Event event) {

        Long value = event.get("value", long.class);
        logger.trace("FirstPE : {} -> {}", getId(), value);
        Event outputEvent = new Event();
        // if we reuse the same key, with the same key finder, this event goes to the current node
        outputEvent.put("key", int.class, event.get("key", int.class));
        outputEvent.put("value", String.class, "forwarded - " + value);
        downstream.put(outputEvent);
    }
View Full Code Here

    public void onEvent(Event event) {

        String value = event.get("value", String.class);
        logger.trace("PipePE : {} -> {}", getId(), value);
        Event outputEvent = new Event();
        // if we reuse the same key, with the same key finder, this event goes to the current node
        outputEvent.put("key", int.class, event.get("key", int.class));
        outputEvent.put("value", String.class, value + "->" + getId());
        downstream.put(outputEvent);
    }
View Full Code Here

        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

TOP

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

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.