Package org.apache.s4.comm.topology

Examples of org.apache.s4.comm.topology.ZNRecord


            processes = zkClient.getChildren(processPath);

            taskNumber = tasks.size();

            for (int i = 0; i < processes.size(); i++) {
                ZNRecord process = zkClient.readData(processPath + "/" + processes.get(i), true);
                if (process != null) {
                    int partition = Integer.parseInt(process.getSimpleField("partition"));
                    String host = process.getSimpleField("host");
                    int port = Integer.parseInt(process.getSimpleField("port"));
                    String taskId = process.getSimpleField("taskId");
                    ClusterNode node = new ClusterNode(partition, port, host, taskId);
                    nodes.add(node);
                }
            }

            app = new App();
            app.cluster = clusterName;
            try {
                ZNRecord appRecord = zkClient.readData(appPath);
                app.name = appRecord.getSimpleField("name");
                app.uri = appRecord.getSimpleField("s4r_uri");
            } catch (ZkNoNodeException e) {
                logger.warn(appPath + " doesn't exist");
            }
        }
View Full Code Here


        System.out.println("Initing CounterApp...");

        ZkClient zkClient = new ZkClient("localhost:2181");

        zkClient.setZkSerializer(new ZNRecordSerializer());
        ZNRecord record = new ZNRecord(Thread.currentThread().getContextClassLoader().getClass().getName());
        zkClient.create("/s4/classLoader", record, CreateMode.PERSISTENT);

        producerPE = createPE(ProducerPE.class, "producer");
        producerPE.setStreams(createOutputStream("tickStream"));
View Full Code Here

        DeploymentUtils.initAppConfig(new AppConfig.Builder().appURI(uriProducer).build(), PRODUCER_CLUSTER, true,
                "localhost:2181");

        Object classLoaderRecord = queue.poll(20, TimeUnit.SECONDS);
        assertTrue("Stored record has unexpected type", classLoaderRecord instanceof ZNRecord);
        ZNRecord record = (ZNRecord) classLoaderRecord;

        assertEquals("Unexpected classloader runs the app init()", S4RLoader.class.getName(), record.getId());
    }
View Full Code Here

        }

        private void readStreamFromZk() throws Exception {
            List<String> consumerNodes = zkClient.getChildren(consumerPath);
            for (String node : consumerNodes) {
                ZNRecord consumer = zkClient.readData(consumerPath + "/" + node, true);
                consumers.add(consumer.getSimpleField("clusterName"));
            }

            List<String> producerNodes = zkClient.getChildren(producerPath);
            for (String node : producerNodes) {
                ZNRecord consumer = zkClient.readData(producerPath + "/" + node, true);
                producers.add(consumer.getSimpleField("clusterName"));
            }

            getAppNames();
        }
View Full Code Here

            processes = zkClient.getChildren(processPath);

            taskNumber = tasks.size();

            for (int i = 0; i < processes.size(); i++) {
                ZNRecord process = zkClient.readData(processPath + "/" + processes.get(i), true);
                if (process != null) {
                    int partition = Integer.parseInt(process.getSimpleField("partition"));
                    String host = process.getSimpleField("host");
                    int port = Integer.parseInt(process.getSimpleField("port"));
                    String taskId = process.getSimpleField("taskId");
                    ClusterNode node = new ClusterNode(partition, port, host, taskId);
                    nodes.add(node);
                }
            }

            app = new App();
            app.cluster = clusterName;
            try {
                ZNRecord appRecord = zkClient.readData(appPath);
                AppConfig appConfig = new AppConfig(appRecord);
                app.name = appConfig.getAppName();
                app.uri = appConfig.getAppURI();
            } catch (ZkNoNodeException e) {
                logger.warn(appPath + " doesn't exist");
View Full Code Here

        zkclient.createPersistent("/" + clusterName + "/tasks", true);
        zkclient.createPersistent("/" + clusterName + "/process", true);
        zkclient.createPersistent("/" + clusterName, true);
        for (int i = 0; i < tasks; i++) {
            String taskId = "Task-" + i;
            ZNRecord record = new ZNRecord(taskId);
            record.setSimpleField("taskId", taskId);
            record.setSimpleField("port", String.valueOf(1300 + i));
            record.setSimpleField("partition", String.valueOf(i));
            record.setSimpleField("cluster", clusterName);
            zkclient.createPersistent("/" + clusterName + "/tasks/" + taskId,
                    record);
        }
    }
View Full Code Here

        signalOneAppLoaded.await();
    }

    private void loadModulesAndStartApp(final Injector parentInjector) throws ArchiveFetchException {

        final ZNRecord appData = zkClient.readData(appPath);
        // can be null
        final AppConfig appConfig = new AppConfig(appData);

        String appName = appConfig.getAppName();
View Full Code Here

        zkclient.createPersistent("/s4/clusters/" + cluster + "/tasks", true);
        zkclient.createPersistent("/s4/clusters/" + cluster + "/process", true);
        zkclient.createPersistent("/s4/clusters/" + cluster + "/app", true);
        for (int i = 0; i < tasks; i++) {
            String taskId = "Task-" + i;
            ZNRecord record = new ZNRecord(taskId);
            record.putSimpleField("taskId", taskId);
            record.putSimpleField("port", String.valueOf(initialPort + i));
            record.putSimpleField("partition", String.valueOf(i));
            record.putSimpleField("cluster", cluster);
            zkclient.createPersistent("/s4/clusters/" + cluster + "/tasks/" + taskId, record);
        }
    }
View Full Code Here

        }
        return sb.toString();
    }

    public ZNRecord asZNRecord(String id) {
        ZNRecord record = new ZNRecord(id);
        if (appClassName != null) {
            record.putSimpleField(APP_CLASS, appClassName);
        }
        if (appName != null) {
            record.putSimpleField(APP_NAME, appName);
        }
        if (appURI != null) {
            record.putSimpleField(APP_URI, appURI);
        }
        if (customModulesNames != null) {
            record.putListField(MODULES_CLASSES, customModulesNames);
        }
        if (customModulesURIs != null) {
            record.putListField(MODULES_URIS, customModulesURIs);
        }
        if (namedParameters != null) {
            record.putMapField(NAMED_PARAMETERS, namedParameters);
        }
        return record;
    }
View Full Code Here

        this.clusterName = clusterName;
        this.server = server;

        zkClient = new ZkClient(zookeeperAddress, sessionTimeout, connectionTimeout);
        zkClient.setZkSerializer(new ZNRecordSerializer());
        String appDir = "/s4/clusters/" + clusterName + "/app";
        if (!zkClient.exists(appDir)) {
            zkClient.create(appDir, null, CreateMode.PERSISTENT);
        }
        appPath = appDir + "/s4App";
View Full Code Here

TOP

Related Classes of org.apache.s4.comm.topology.ZNRecord

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.