Package org.apache.s4.base

Examples of org.apache.s4.base.Event


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

        Event event = new Event();
        event.put("command", String.class, "setValue1");
        event.put("value", String.class, "message1");
        emitter.send(0, new EventMessage("-1", "inputStream", injector.getInstance(SerializerDeserializer.class)
                .serialize(event)));

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

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

        forkedS4App.destroy();

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

        signalConsumerReady = getConsumerReadySignal("inputStream");
        forkedS4App = CoreTestUtils.forkS4Node(new String[] { "-c", "cluster1", "-appClass",
                S4AppWithManualCheckpointing.class.getName(), "-extraModulesClasses", backendModuleClass.getName() });

        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.put("command", String.class, "setValue2");
        event.put("value", String.class, "message2");
        emitter.send(0, new EventMessage("-1", "inputStream", injector.getInstance(SerializerDeserializer.class)
                .serialize(event)));

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

        Assert.assertEquals(expectedFinalResult, new String(zk.getData("/data", false, null)));
View Full Code Here


    private void injectSentence(Injector injector, TCPEmitter emitter, String sentence) {
        Event 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

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

        app.testStream.receiveEvent(new EventMessage("", "stream1", app.getSerDeser().serialize(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.put("command", String.class, "checkpoint");
        app.testStream.receiveEvent(new EventMessage("", "stream1", app.getSerDeser().serialize(event)));
        Assert.assertTrue(signalCheckpointed.await(10, TimeUnit.SECONDS));

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

    @Inject
    RemoteEmitterFactory emitterFactory;

    public RemoteEmitter getEmitter(Cluster topology) {
        RemoteEmitter emitter = emitters.get(topology);
        if (emitter == null) {
            emitter = emitterFactory.createRemoteEmitter(topology);
            emitters.put(topology, emitter);
        }
        return emitter;
View Full Code Here

        // TODO handle application upgrade
        logger.info("Loading application [{}] from file [{}]", appName, s4r.getAbsolutePath());

        S4RLoaderFactory loaderFactory = injector.getInstance(S4RLoaderFactory.class);
        S4RLoader cl = loaderFactory.createS4RLoader(s4r.getAbsolutePath());
        try {
            JarFile s4rFile = new JarFile(s4r);
            if (s4rFile.getManifest() == null) {
                logger.warn("Cannot load s4r archive [{}] : missing manifest file");
                return null;
            }
            if (!s4rFile.getManifest().getMainAttributes().containsKey(new Name(MANIFEST_S4_APP_CLASS))) {
                logger.warn("Cannot load s4r archive [{}] : missing attribute [{}] in manifest", s4r.getAbsolutePath(),
                        MANIFEST_S4_APP_CLASS);
                return null;
            }
            String appClassName = s4rFile.getManifest().getMainAttributes().getValue(MANIFEST_S4_APP_CLASS);
            logger.info("App class name is: " + appClassName);
            App app = null;

            try {
                Object o = (cl.loadClass(appClassName)).newInstance();
                app = (App) o;
                injector.injectMembers(app);
            } catch (Exception e) {
                logger.error("Could not load s4 application form s4r file [{" + s4r.getAbsolutePath() + "}]", e);
                return null;
View Full Code Here

    public App loadApp(File s4r, String appName) {

        // TODO handle application upgrade
        logger.info("Loading application [{}] from file [{}]", appName, s4r.getAbsolutePath());

        S4RLoaderFactory loaderFactory = injector.getInstance(S4RLoaderFactory.class);
        S4RLoader cl = loaderFactory.createS4RLoader(s4r.getAbsolutePath());
        try {
            JarFile s4rFile = new JarFile(s4r);
            if (s4rFile.getManifest() == null) {
                logger.warn("Cannot load s4r archive [{}] : missing manifest file");
                return null;
View Full Code Here

    //
    // }

    @Before
    public void prepareEmitter() throws IOException {
        injector = Guice.createInjector(new DefaultCommModule(Resources.getResource("default.s4.comm.properties")
                .openStream(), "cluster1"), new DefaultCoreModule(Resources.getResource("default.s4.core.properties")
                .openStream()));

        emitter = injector.getInstance(TCPEmitter.class);
View Full Code Here

    }

    public static Injector createInjectorWithNonFailFastZKClients() throws IOException {
        return Guice.createInjector(Modules.override(
                new DefaultCommModule(Resources.getResource("default.s4.comm.properties").openStream(), "cluster1"),
                new DefaultCoreModule(Resources.getResource("default.s4.core.properties").openStream())).with(
                new NonFailFastZookeeperClientsModule()));
    }
View Full Code Here

        super(numTasks);
    }

    public Injector newInjector() {
        try {
            return Guice.createInjector(new DefaultCommModule(Resources.getResource("default.s4.comm.properties")
                    .openStream(), CLUSTER_NAME));
        } catch (IOException e) {
            Assert.fail();
            return null;
        }
View Full Code Here

        super(numTasks);
    }

    @Override
    protected Injector newInjector() throws IOException {
        return Guice.createInjector(new DefaultCommModule(Resources.getResource("udp.s4.comm.properties").openStream(),
                "cluster1"), new UDPCommTestModule());
    }
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.