Package org.I0Itec.zkclient

Examples of org.I0Itec.zkclient.ZkClient


  public static void createTopic(String topicName) {
    int numPartitions = 5;
    int sessionTimeoutMs = 10000;
    int connectionTimeoutMs = 10000;
    ZkClient zkClient = new ZkClient(testUtil.getZkUrl(),
      sessionTimeoutMs, connectionTimeoutMs,
      ZKStringSerializer$.MODULE$);

    int replicationFactor = 1;
    Properties topicConfig = new Properties();
View Full Code Here


  }

  public static void deleteTopic(String topicName) {
    int sessionTimeoutMs = 10000;
    int connectionTimeoutMs = 10000;
    ZkClient zkClient = new ZkClient(testUtil.getZkUrl(),
      sessionTimeoutMs, connectionTimeoutMs,
      ZKStringSerializer$.MODULE$);
    AdminUtils.deleteTopic(zkClient, topicName);
  }
View Full Code Here

  public void createTopic(String topicName) {
    // Create a ZooKeeper client
    int sessionTimeoutMs = 10000;
    int connectionTimeoutMs = 10000;
    ZkClient zkClient = new ZkClient(zookeeper.getConnectString(),
            sessionTimeoutMs, connectionTimeoutMs,
            ZKStringSerializer$.MODULE$);

    int numPartitions = 1;
    int replicationFactor = 1;
View Full Code Here

            @Named("s4.cluster.zk_connection_timeout") int connectionTimeout, Server server) {

        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);
        }
View Full Code Here

            @Named("s4.cluster.name") String clusterName, @Named("s4.cluster.zk_address") String zookeeperAddress,
            @Named("s4.cluster.zk_session_timeout") int sessionTimeout,
            @Named("s4.cluster.zk_connection_timeout") int connectionTimeout) {
        this.logLevel = logLevel;

        zkClient = new ZkClient(zookeeperAddress, sessionTimeout, connectionTimeout);
        zkClient.setZkSerializer(new ZNRecordSerializer());
    }
View Full Code Here

        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);
        final CountDownLatch signalProcessesReady = new CountDownLatch(1);
View Full Code Here

        httpServer.start();

        assertDeployment("http://localhost:8080/s4/" + s4rToDeploy.getName());

        // check resource loading (we use a zkclient without custom serializer)
        ZkClient client2 = new ZkClient("localhost:" + CommTestUtils.ZK_PORT);
        Assert.assertEquals("Salut!", client2.readData("/resourceData"));

    }
View Full Code Here

        // 0. package s4 app
        // TODO this is currently done offline, and the app contains the TestApp class copied from the one in the
        // current package .

        // 1. start s4 nodes. Check that no app is deployed.
        zkClient = new ZkClient("localhost:" + CommTestUtils.ZK_PORT);
        zkClient.setZkSerializer(new ZNRecordSerializer());
        List<String> processes = zkClient.getChildren("/s4/clusters/cluster1/process");
        Assert.assertTrue(processes.size() == 0);
        final CountDownLatch signalProcessesReady = new CountDownLatch(1);
View Full Code Here

        DeployAppArgs deployArgs = new DeployAppArgs();

        Tools.parseArgs(deployArgs, args);

        try {
            ZkClient zkClient = new ZkClient(deployArgs.zkConnectionString, deployArgs.timeout);
            zkClient.setZkSerializer(new ZNRecordSerializer());

            tmpAppsDir = Files.createTempDir();

            if (!Strings.isNullOrEmpty(deployArgs.s4rPath) && !Strings.isNullOrEmpty(deployArgs.generatedS4R)) {
                logger.error("-s4r and -generatedS4R options are mutually exclusive");
                System.exit(1);
            }

            File s4rToDeploy;

            if (deployArgs.s4rPath != null) {
                s4rToDeploy = new File(deployArgs.s4rPath);
                if (!s4rToDeploy.exists()) {
                    logger.error("Specified S4R file does not exist in {}", s4rToDeploy.getAbsolutePath());
                    System.exit(1);
                } else {
                    logger.info(
                            "Using specified S4R [{}], the S4R archive will not be built from source (and corresponding parameters are ignored)",
                            s4rToDeploy.getAbsolutePath());
                }
            } else {
                List<String> params = new ArrayList<String>();
                // prepare gradle -P parameters, including passed gradle opts
                params.addAll(deployArgs.gradleOpts);
                params.add("appClass=" + deployArgs.appClass);
                params.add("appsDir=" + tmpAppsDir.getAbsolutePath());
                params.add("appName=" + deployArgs.appName);
                ExecGradle.exec(deployArgs.gradleBuildFile, "installS4R", params.toArray(new String[] {}));
                File tmpS4R = new File(tmpAppsDir.getAbsolutePath() + "/" + deployArgs.appName + ".s4r");
                if (!Strings.isNullOrEmpty(deployArgs.generatedS4R)) {
                    logger.info("Copying generated S4R to [{}]", deployArgs.generatedS4R);
                    s4rToDeploy = new File(deployArgs.generatedS4R);
                    if (!(ByteStreams.copy(Files.newInputStreamSupplier(tmpS4R),
                            Files.newOutputStreamSupplier(s4rToDeploy)) > 0)) {
                        logger.error("Cannot copy generated s4r from {} to {}", tmpS4R.getAbsolutePath(),
                                s4rToDeploy.getAbsolutePath());
                        System.exit(1);
                    }
                } else {
                    s4rToDeploy = tmpS4R;
                }
            }

            final String uri = s4rToDeploy.toURI().toString();
            ZNRecord record = new ZNRecord(String.valueOf(System.currentTimeMillis()));
            record.putSimpleField(DistributedDeploymentManager.S4R_URI, uri);
            record.putSimpleField("name", deployArgs.appName);
            String deployedAppPath = "/s4/clusters/" + deployArgs.clusterName + "/app/s4App";
            if (zkClient.exists(deployedAppPath)) {
                ZNRecord readData = zkClient.readData(deployedAppPath);
                logger.error("Cannot deploy app [{}], because app [{}] is already deployed", deployArgs.appName,
                        readData.getSimpleField("name"));
                System.exit(1);
            }

            zkClient.create("/s4/clusters/" + deployArgs.clusterName + "/app/s4App", record, CreateMode.PERSISTENT);
            logger.info(
                    "uploaded application [{}] to cluster [{}], using zookeeper znode [{}], and s4r file [{}]",
                    new String[] { deployArgs.appName, deployArgs.clusterName,
                            "/s4/clusters/" + deployArgs.clusterName + "/app/" + deployArgs.appName,
                            s4rToDeploy.getAbsolutePath() });
View Full Code Here

   * @see com.linkedin.incubator.mstuart.leaderelect.api.GroupLeadershipConnectionFactory#getConnection()
   */
  @Override
  public GroupLeadershipConnection getConnection()
  {
    ZkClient zkClient = new ZkClient(_zkServerList, _sessionTimeoutMillis, _connectTimeoutMillis);
    GroupLeadershipConnection groupLeadershipConnection = new GroupLeadershipConnectionZkClientImpl(zkClient);
    return groupLeadershipConnection;
  }
View Full Code Here

TOP

Related Classes of org.I0Itec.zkclient.ZkClient

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.