Package org.apache.s4.comm.tools

Examples of org.apache.s4.comm.tools.TaskSetup


        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

    }

    public void injectSentence(String sentence) throws IOException {
        Event event = new Event();
        event.put("sentence", String.class, sentence);
        emitter.send(0, new EventMessage("-1", "inputStream", injector.getInstance(SerializerDeserializer.class)
                .serialize(event)));
    }
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();

        app.testStream.receiveEvent(new EventMessage(APP_NAME, STREAM_NAME, app.getSerDeser().serialize(new 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

    public void run() {
        // TODO: this thread never seems to get interrupted. SHould we catch an interrupted exception from listener
        // here?
        while (!Thread.interrupted()) {
            byte[] message = listener.recv();
            EventMessage event = (EventMessage) serDeser.deserialize(message);

            int appId = Integer.valueOf(event.getAppName());
            String streamId = event.getStreamName();

            /*
             * Match appId and 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

                    /*
                     * Sender checked and decided that the target is local so we simply put the event in the queue and
                     * we save the trip over the network.
                     */
                    queue.put(new EventMessage(String.valueOf(event.getAppId()), event.getStreamName(), app
                            .getSerDeser().serialize(event)));
                }

            } else {

                /*
                 * We are broadcasting this event to all PE instance. In a cluster, we need to send the event to every
                 * node. The sender method takes care of the remote partitions an we take care of putting the event into
                 * the queue.
                 */
                sender.sendToRemotePartitions(event);
                queue.put(new EventMessage(String.valueOf(event.getAppId()), event.getStreamName(), app.getSerDeser()
                        .serialize(event)));
            }
        } catch (InterruptedException e) {
            logger.error("Interrupted while waiting to put an event in the queue: {}.", e.getMessage());
            Thread.currentThread().interrupt();
View Full Code Here

    @Override
    public void run() {
        while (true) {
            try {
                /* Get oldest event in queue. */
                EventMessage eventMessage = queue.take();

                @SuppressWarnings("unchecked")
                T event = (T) app.getSerDeser().deserialize(eventMessage.getSerializedEvent());

                /* Send event to each target PE. */
                for (int i = 0; i < targetPEs.length; i++) {

                    if (key == null) {
View Full Code Here

        @Override
        public void run() {
            try {
                for (int i = 0; i < numMessages; i++) {
                    for (int partition = 0; partition < emitter.getPartitionCount(); partition++) {
                        EventMessage message = new EventMessage("app1", "stream1",
                                new String(partitionId + " " + i).getBytes());
                        for (int retries = 0; retries < numRetries; retries++) {
                            if (emitter.send(partition, message)) {
                                sendCounts[partition]++;
                                break;
View Full Code Here

TOP

Related Classes of org.apache.s4.comm.tools.TaskSetup

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.