Package org.I0Itec.zkclient

Examples of org.I0Itec.zkclient.ZkClient


    String[] pathsToDelete = pathsToDeleteStr.split(",");

    LOG.info("Deleting paths: " + Arrays.toString(pathsToDelete));

    ZkClient zkClient = new ZkClient(
      ExampleUtils.getRequiredStringProperty("zkServerList", LOG),
      ExampleUtils.getRequiredIntProperty("sessionTimeoutMillis", LOG),
      ExampleUtils.getRequiredIntProperty("connectTimeoutMillis", LOG));

    for (String pathToDelete : pathsToDelete)
    {
      zkClient.deleteRecursive(pathToDelete);
    }

    zkClient.close();
  }
View Full Code Here


     * @throws InterruptedException
     */
    private static void createTopics(List<String> topics, int partitions,
            String zkConfig) throws InterruptedException {

        ZkClient zkClient = createZkClient(zkConfig);

        try {
            Properties props = new Properties();
            int replicationFactor = 1;
            for (String topic : topics) {
                AdminUtils.createTopic(zkClient, topic, partitions,
                        replicationFactor, props);
            }
        } catch (TopicExistsException e) {
            System.out.println(e.getMessage());
        } finally {
            zkClient.close();
        }

    }
View Full Code Here

     */
    private static ZkClient createZkClient(String zkConfig) {
        // Create a ZooKeeper client
        int sessionTimeoutMs = 10000;
        int connectionTimeoutMs = 10000;
        ZkClient zkClient = new ZkClient(zkConfig, sessionTimeoutMs,
                connectionTimeoutMs, ZKStringSerializer$.MODULE$);
        return zkClient;
    }
View Full Code Here

public class ZkKattaUtil {

  public static final int DEFAULT_PORT = 2181;

  public static ZkClient startZkClient(ZkConfiguration conf, int connectionTimeout) {
    return new ZkClient(conf.getZKServers(), conf.getZKTimeOut(), connectionTimeout);
  }
View Full Code Here

      super(command, parameterString, description);
    }

    @Override
    public final void execute(ZkConfiguration zkConf) throws Exception {
      ZkClient zkClient = new ZkClient(zkConf.getZKServers());
      InteractionProtocol protocol = new InteractionProtocol(zkClient, zkConf);
      execute(zkConf, protocol);
      protocol.disconnect();
    }
View Full Code Here

    return nodeOperationIds;
  }

  @Override
  public void nodeOperationsComplete(MasterContext context, List<OperationResult> results) throws Exception {
    ZkClient zkClient = context.getProtocol().getZkClient();
    ZkConfiguration zkConf = context.getProtocol().getZkConfiguration();
    for (Shard shard : _indexMD.getShards()) {
      zkClient.deleteRecursive(zkConf.getZkPath(PathDef.SHARD_TO_NODES, shard.getName()));
    }
  }
View Full Code Here

  @Test(timeout = 100000)
  public void testZkMasterReconnectDuringDeployment() throws Exception {
    deployTestIndices(1, getNodeCount());
    _miniCluster.getMaster().shutdown();

    ZkClient zkClient = new ZkClient(_miniCluster.getZkConfiguration().getZKServers());
    InteractionProtocol protocol = new InteractionProtocol(zkClient, _miniCluster.getZkConfiguration());
    Master master = new Master(protocol, false);
    master.start();
    TestUtil.waitUntilBecomeMaster(master);

    final IDeployClient deployClient = new DeployClient(_protocol);
    WatchedEvent event = new WatchedEvent(new WatcherEvent(EventType.None.getIntValue(), KeeperState.Expired
            .getIntValue(), null));
    for (int i = 0; i < 25; i++) {
      final String indexName = "index" + i;
      IIndexDeployFuture deployFuture = deployClient.addIndex(indexName, INDEX_FILE.getAbsolutePath(), 1);
      zkClient.getEventLock().lock();
      zkClient.process(event);
      zkClient.getEventLock().unlock();
      IndexState indexState = deployFuture.joinDeployment();
      assertEquals("" + deployClient.getIndexMetaData(indexName).getDeployError(), IndexState.DEPLOYED, indexState);

      if (indexState == IndexState.ERROR) {
        IndexDeployError deployError = protocol.getIndexMD(indexName).getDeployError();
View Full Code Here

  private static final Logger LOG = Logger.getLogger(UpgradeAction05_06.class);

  @SuppressWarnings("deprecation")
  @Override
  public void upgrade(InteractionProtocol protocol) {
    ZkClient zkClient = protocol.getZkClient();
    ZkConfiguration zkConf = protocol.getZkConfiguration();
    ZkClient zkClientForWriables = new ZkClient(zkConf.getZKServers(), 5000, 5000, new WriteableZkSerializer(
            net.sf.katta.index.IndexMetaData.class));
    LOG.info("restoring indices meta data...");
    String oldIndicesPath = getOldIndicesPath(zkConf);
    List<String> indices = zkClient.getChildren(oldIndicesPath);
    LOG.info("found " + indices.size() + " old indices");
    for (String indexName : indices) {
      net.sf.katta.index.IndexMetaData oldIndexMD = zkClientForWriables.readData(oldIndicesPath + "/" + indexName);
      IndexMetaData newIndexMD = new IndexMetaData(indexName, oldIndexMD.getPath(), oldIndexMD.getReplicationLevel());
      IndexReinitializeOperation deployOperation = new IndexReinitializeOperation(newIndexMD);
      protocol.addMasterOperation(deployOperation);
      protocol.publishIndex(newIndexMD);
    }
    zkClientForWriables.close();

    LOG.info("deleting obsolete folders...");
    zkClient.deleteRecursive(zkConf.getZkRootPath() + "/" + "indexes");
    zkClient.deleteRecursive(zkConf.getZkRootPath() + "/" + "node-to-shard");
    zkClient.deleteRecursive(zkConf.getZkRootPath() + "/" + "shard-to-node");
View Full Code Here

    assertNull(queue.getResult(elementId, false));
  }

  @Test(timeout = 15000)
  public void testResultCleanup() throws Exception {
    ZkClient zkClientSpy = spy(_zk.getZkClient());
    NodeQueue queue = new NodeQueue(zkClientSpy, getRootPath());
    NodeOperation nodeOperation = mock(NodeOperation.class);
    String elementName = queue.add(nodeOperation);

    OperationResult result = new OperationResult("node1");
View Full Code Here

  private InteractionProtocol _protocol = mock(InteractionProtocol.class);

  @Before
  public void setUp() {
    when(_protocol.getZkConfiguration()).thenReturn(new ZkConfiguration());
    ZkClient mock = mock(ZkClient.class);
    when(_protocol.getZkClient()).thenReturn(mock);
  }
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.