Examples of PathChildrenCache


Examples of org.apache.curator.framework.recipes.cache.PathChildrenCache

    EmbeddedZooKeeper zkServer = new EmbeddedZooKeeper(5555);
    zkServer.start();
    ZooKeeperConnection zkConnection = new ZooKeeperConnection("localhost:5555");
    zkConnection.start();
    CuratorFramework client = zkConnection.getClient();
    PathChildrenCache cache = new PathChildrenCache(client, Paths.build(Paths.STREAMS), true);
    cache.getListenable().addListener(new ListenerOne());
    cache.getListenable().addListener(new ListenerTwo());
    cache.start();

    Paths.ensurePath(client, Paths.STREAMS);

    for (int i = 0; i < 100; i++) {
      client.create().creatingParentsIfNeeded().forPath(
          Paths.build(Paths.STREAM_DEPLOYMENTS, "foo" + i));
    }
    cache.close();
  }
View Full Code Here

Examples of org.apache.curator.framework.recipes.cache.PathChildrenCache

        for (int i = 0; i < 5; i++) {
            System.out.format("%nCreating consumer #%d%n", i + 1);
            ConsumerConnector connector = Consumer.createJavaConsumerConnector(config);
            connector.createMessageStreams(Collections.singletonMap("mytopic", 1));
            if (i == 0) {
                PathChildrenCache cache = new PathChildrenCache(curator, "/consumers/foo/owners/mytopic", true);
                listener = new RebalanceListener(5);
                cache.getListenable().addListener(listener);
                cache.start(PathChildrenCache.StartMode.POST_INITIALIZED_EVENT);
            }

            synchronized (listener) {
                System.out.println("******** Waiting for rebalance...");
                listener.wait();
View Full Code Here

Examples of org.apache.curator.framework.recipes.cache.PathChildrenCache

            } catch (Exception e) {
                LOG.warn("Tried to create path " + path + " but got: " + e, e);
            }
        }

        apiCache = new PathChildrenCache(curatorFramework, path, false);
        apiCache.getListenable().addListener(new PathChildrenCacheListener() {
            @Override
            public void childEvent(CuratorFramework curatorFramework, PathChildrenCacheEvent event) throws Exception {
                try {
                    LOG.debug("event: " + event);
View Full Code Here

Examples of org.apache.curator.framework.recipes.cache.PathChildrenCache

    @Override
    public synchronized void start() {
        try {
            ZooKeeperUtils.createDefault(curator, partitionsPath, null);
            if (partitionCache == null) {
                partitionCache = new PathChildrenCache(curator, partitionsPath, true, false, executorService);
                partitionCache.getListenable().addListener(this);
                partitionCache.start(PathChildrenCache.StartMode.POST_INITIALIZED_EVENT);
                partitionCache.rebuild();
            }
        } catch (Exception e) {
View Full Code Here

Examples of org.apache.curator.framework.recipes.cache.PathChildrenCache

  public ZooKeeperHealthChecker(final ZooKeeperClient zooKeeperClient, final String path,
                                final RiemannFacade facade, final TimeUnit timeUnit,
                                final long interval) {
    super();
    this.scheduler = Executors.newScheduledThreadPool(2);
    this.cache = new PathChildrenCache(zooKeeperClient.getCuratorFramework(), path, true, false,
        scheduler);
    this.facade = facade.stack("zookeeper-connection");
    this.timeUnit = timeUnit;
    this.interval = interval;
View Full Code Here

Examples of org.apache.curator.framework.recipes.cache.PathChildrenCache

        this.client = client;
        this.defaults = defaults;
        this.hostname = hostname;
        configPath = ZKPaths.makePath(baseZPath, CONFIG_PATH);
        lockPath = ZKPaths.makePath(baseZPath, LOCK_PATH);
        cache = new PathChildrenCache(client, configPath, true);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.