Package org.apache.s4.util.clock

Examples of org.apache.s4.util.clock.EventClock


        final CountDownLatch signalCheckpointed = new CountDownLatch(1);
        CoreTestUtils.watchAndSignalCreation("/checkpointed", signalCheckpointed, zk);

        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");
        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


    @Test
    public void testCheckpointAndRecovery() throws Exception {

        Injector injector = CoreTestUtils.createInjectorWithNonFailFastZKClients();

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

        final ZooKeeper zk = CoreTestUtils.createZkClient();

        restartNode();
View Full Code Here

    public void prepare() throws IOException, InterruptedException, KeeperException {
        CommTestUtils.cleanupTmpDirs();

        zkFactory = CommTestUtils.startZookeeperServer();

        TaskSetup taskSetup = new TaskSetup("localhost:" + CommTestUtils.ZK_PORT);
        taskSetup.clean("s4");
        taskSetup.setup("cluster1", numTasks, 1300);
    }
View Full Code Here

*/
public class AssignmentsFromZKTest1 extends ZKBaseTest {

    @Test
    public void testAssignmentFor1Cluster() throws Exception {
        TaskSetup taskSetup = new TaskSetup(CommTestUtils.ZK_STRING);
        final String topologyNames = "cluster1";
        testAssignment(taskSetup, topologyNames);
    }
View Full Code Here

public class ClustersFromZKTest extends ZKBaseTest {

    @Test
    @Ignore
    public void testAssignmentFor1Topology() throws InterruptedException, Exception {
        TaskSetup taskSetup = new TaskSetup(CommTestUtils.ZK_STRING);
        final String clustersString = "cluster1";
        testAssignment(taskSetup, clustersString);
    }
View Full Code Here

    }

    @Test
    public void testAssignmentFor2Topologies() throws Exception {
        Thread.sleep(2000);
        TaskSetup taskSetup = new TaskSetup(CommTestUtils.ZK_STRING);
        final String clustersString = "cluster2, cluster3";
        testAssignment(taskSetup, clustersString);

    }
View Full Code Here

    }

    private void initializeS4Node() throws ConfigurationException, IOException, InterruptedException, KeeperException {
        // 1. start s4 nodes. Check that no app is deployed.
        TaskSetup taskSetup = new TaskSetup("localhost:" + CommTestUtils.ZK_PORT);
        taskSetup.clean("s4");
        taskSetup.setup(PRODUCER_CLUSTER, 1, 1300);

        TaskSetup taskSetup2 = new TaskSetup("localhost:" + CommTestUtils.ZK_PORT);
        taskSetup2.setup(CONSUMER_CLUSTER, 1, 1400);

        zkClient = new ZkClient("localhost:" + CommTestUtils.ZK_PORT);
        zkClient.setZkSerializer(new ZNRecordSerializer());
        List<String> processes = zkClient.getChildren("/s4/clusters/" + PRODUCER_CLUSTER + "/process");
        Assert.assertTrue(processes.size() == 0);
View Full Code Here

        Tools.parseArgs(clusterArgs, args);
        try {

            logger.info("preparing new cluster [{}] with [{}] node(s)", clusterArgs.clusterName, clusterArgs.nbTasks);

            TaskSetup taskSetup = new TaskSetup(clusterArgs.zkConnectionString);
            taskSetup.clean(clusterArgs.clusterName);
            taskSetup.setup(clusterArgs.clusterName, clusterArgs.nbTasks, clusterArgs.firstListeningPort);
            logger.info("New cluster configuration uploaded into zookeeper");
        } catch (Exception e) {
            logger.error("Cannot initialize zookeeper with specified configuration", e);
        }
View Full Code Here

                } else {
                    clusterConfigs = Collections.emptyList();
                }
            }
            for (ClusterConfig config : clusterConfigs) {
                TaskSetup taskSetup = new TaskSetup("localhost:" + zkArgs.zkPort);
                taskSetup.clean(config.clusterName);
                taskSetup.setup(config.clusterName, config.nbTasks, config.firstListeningPort);
                logger.info("Defined S4 cluster [{}] with [{}] tasks with first listening port [{}]", new String[] {
                        config.clusterName, String.valueOf(config.nbTasks), String.valueOf(config.firstListeningPort) });
            }

        } catch (Exception e) {
View Full Code Here

public class TopologyFromZKTest extends ZKBaseTest {

    @Test
    public void testAssignment() throws Exception {
        TaskSetup taskSetup = new TaskSetup(zookeeperAddress);
        final String clusterName = "test-s4-cluster";
        taskSetup.clean(clusterName);
        taskSetup.setup(clusterName, 10);

        final TopologyFromZK topologyFromZK = new TopologyFromZK(clusterName, zookeeperAddress, 30000, 30000);
        final Lock lock = new ReentrantLock();
        final Condition signal = lock.newCondition();
        TopologyChangeListener listener = new TopologyChangeListener() {
View Full Code Here

TOP

Related Classes of org.apache.s4.util.clock.EventClock

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.