Package org.apache.s4.base

Examples of org.apache.s4.base.Event


        this.targetStreams = targetStreams;
    }

    public void sendMessages() {
        for (long tick = 1; tick <= 100000; tick++) {
            Event event = new Event();
            event.put("tick", Long.class, tick);

            logger.trace("Sending event with tick {} and time {}.", event.get("tick", Long.class), event.getTime());
            for (int i = 0; i < targetStreams.length; i++) {
                targetStreams[i].put(event);
            }
        }
    }
View Full Code Here


        @Override
        public void run() {
            while (true) {
                try {
                    Status status = messageQueue.take();
                    Event event = new Event();
                    event.put("statusText", String.class, status.getText());
                    getRemoteStream().put(event);
                } catch (Exception e) {

                }
            }
View Full Code Here

                signalMessagesReceived, zk);

        SerializerDeserializer serDeser = injector.getInstance(SerializerDeserializerFactory.class)
                .createSerializerDeserializer(Thread.currentThread().getContextClassLoader());
        for (Long message : messages) {
            Event event = new Event();
            event.put("message", long.class, message);
            event.setStreamId("inputStream");
            emitter.send(0, serDeser.serialize(event));
        }

        // check sequential nodes in zk with correct data
        Assert.assertTrue(signalMessagesReceived.await(10, TimeUnit.SECONDS));
View Full Code Here

        testCheckpointingConfiguration(S4AppWithCountBasedCheckpointing.class,
                CheckpointingModuleWithUnrespondingFetchingStorageBackend.class, false, "value1= ; value2=message2");
    }

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

        Injector injector = CoreTestUtils.createInjectorWithNonFailFastZKClients();

        TCPEmitter emitter = injector.getInstance(TCPEmitter.class);

        Event event = new Event();
        event.put("command", String.class, "setValue1");
        event.put("value", String.class, "message1");
        event.setStreamId("inputStream");
        emitter.send(
                0,
                injector.getInstance(SerializerDeserializerFactory.class)
                        .createSerializerDeserializer(Thread.currentThread().getContextClassLoader()).serialize(event));

        if (manualCheckpointing) {
            insertCheckpointInstruction(injector, emitter);
        }

        Assert.assertTrue(signalCheckpointed.await(10, TimeUnit.SECONDS));

        forkedS4App.destroy();

        zk.delete("/data", -1);

        signalConsumerReady = getConsumerReadySignal("inputStream");
        DeploymentUtils.initAppConfig(
                new AppConfig.Builder()
                        .appClassName(S4AppWithManualCheckpointing.class.getName())
                        .namedParameters(
                                ImmutableMap.of("s4.checkpointing.filesystem.storageRootPath",
                                        CommTestUtils.DEFAULT_STORAGE_DIR.getAbsolutePath()))
                        .customModulesNames(ImmutableList.of(backendModuleClass.getName())).build(), "cluster1", true,
                "localhost:2181");

        forkedS4App = CoreTestUtils.forkS4Node(new String[] { "-c", "cluster1" }, new ZkClient("localhost:2181"), 10,
                "cluster1");

        Assert.assertTrue(signalConsumerReady.await(20, TimeUnit.SECONDS));
        // // trigger recovery by sending application event to set value 2
        CountDownLatch signalValue2Set = new CountDownLatch(1);
        CoreTestUtils.watchAndSignalCreation("/value2Set", signalValue2Set, zk);

        event = new Event();
        event.setStreamId("inputStream");
        event.put("command", String.class, "setValue2");
        event.put("value", String.class, "message2");
        emitter.send(
                0,
                injector.getInstance(SerializerDeserializerFactory.class)
                        .createSerializerDeserializer(Thread.currentThread().getContextClassLoader()).serialize(event));
View Full Code Here

        Injector injector = CoreTestUtils.createInjectorWithNonFailFastZKClients();

        TCPEmitter emitter = injector.getInstance(TCPEmitter.class);

        Event event = new Event();
        event.setStreamId("inputStream");
        event.put("line", String.class, time1);
        emitter.send(
                0,
                injector.getInstance(SerializerDeserializerFactory.class)
                        .createSerializerDeserializer(Thread.currentThread().getContextClassLoader()).serialize(event));
View Full Code Here

    }

    @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

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.