Examples of PathChildrenCache


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

     * @param path to ZK root parent node for the rest of the configuration properties (ie. /<my-app>/config)
     */
    public ZooKeeperConfigurationSource(CuratorFramework client, String configRootPath) {
        this.client = client;
        this.configRootPath = configRootPath;       
        this.pathChildrenCache = new PathChildrenCache(client, configRootPath, true);
    }   
View Full Code Here

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

            // and come back, we expect a removed event in between.
            if (containers.containsKey(containerKey)) {
              log.error("New node[%s] but there was already one.  That's not good, ignoring new one.", child.getPath());
            } else {
              final String inventoryPath = String.format("%s/%s", config.getInventoryPath(), containerKey);
              PathChildrenCache inventoryCache = cacheFactory.make(curatorFramework, inventoryPath);
              inventoryCache.getListenable().addListener(new InventoryCacheListener(containerKey, inventoryPath));

              containers.put(containerKey, new ContainerHolder(container, inventoryCache));

              log.info("Starting inventory cache for %s, inventoryPath %s", containerKey, inventoryPath);
              inventoryCache.start(PathChildrenCache.StartMode.POST_INITIALIZED_EVENT);
              strategy.newContainer(container);
            }

            break;
          }
View Full Code Here

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

  }

  @Override
  public PathChildrenCache make(CuratorFramework curator, String path)
  {
    return new PathChildrenCache(curator, path, cacheData, compressed, exec);
  }
View Full Code Here

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

      final ConcurrentMap<String, byte[]> finalSubPaths = announcements.get(parentPath);

      // Synchronize to make sure that I only create a listener once.
      synchronized (finalSubPaths) {
        if (!listeners.containsKey(parentPath)) {
          final PathChildrenCache cache = factory.make(curator, parentPath);
          cache.getListenable().addListener(
              new PathChildrenCacheListener()
              {
                private final AtomicReference<Set<String>> pathsLost = new AtomicReference<Set<String>>(null);

                @Override
View Full Code Here

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

      TaskRunner taskRunner,
      WorkerConfig workerConfig
  )
  {
    this.jsonMapper = jsonMapper;
    this.pathChildrenCache = new PathChildrenCache(
        cf, workerCuratorCoordinator.getTaskPathForWorker(), false, true, Execs.makeThreadFactory("TaskMonitorCache-%s")
    );
    this.cf = cf;
    this.workerCuratorCoordinator = workerCuratorCoordinator;
    this.taskRunner = taskRunner;
View Full Code Here

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

  UsersTracker(
      CuratorFramework zkClient,
      File usersDir
  ) {
    mUsersDir = usersDir;
    mCache = new PathChildrenCache(zkClient, usersDir.getPath(), false);
  }
View Full Code Here

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

        Preconditions.checkNotNull(name, "name cannot be null");
        Preconditions.checkNotNull(threadFactory, "threadFactory cannot be null");

        this.discovery = discovery;

        cache = new PathChildrenCache(discovery.getClient(), discovery.pathForName(name), true, threadFactory);
        cache.getListenable().addListener(this);
    }
View Full Code Here

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

    public static void main(String[] args) throws Exception
    {
        TestingServer       server = new TestingServer();
        CuratorFramework    client = null;
        PathChildrenCache   cache = null;
        try
        {
            client = CuratorFrameworkFactory.newClient(server.getConnectString(), new ExponentialBackoffRetry(1000, 3));
            client.start();

            // in this example we will cache data. Notice that this is optional.
            cache = new PathChildrenCache(client, PATH, true);
            cache.start();

            processCommands(client, cache);
        }
        finally
        {
View Full Code Here

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

    {
        try
        {
            final CuratorEntry entry = CuratorEntry.mustGetEntry(connectionManager, projection);

            final PathChildrenCache cache = new PathChildrenCache(entry.getClient(), path, cacheData, dataIsCompressed, ThreadUtils.newThreadFactory("PathChildrenCacheResource"));
            cache.start(PathChildrenCache.StartMode.valueOf(startMode.name()));

            Closer closer = new Closer()
            {
                @Override
                public void close()
                {
                    try
                    {
                        cache.close();
                    }
                    catch ( IOException e )
                    {
                        log.error("Could not close left-over PathChildrenCache for path: " + path, e);
                    }
                }
            };
            String id = entry.addThing(cache, closer);

            PathChildrenCacheListener listener = new PathChildrenCacheListener()
            {
                @Override
                public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws RpcException
                {
                    entry.addEvent(new RpcCuratorEvent(new RpcPathChildrenCacheEvent(path, event)));
                }
            };
            cache.getListenable().addListener(listener);

            return new PathChildrenCacheProjection(id);
        }
        catch ( Exception e )
        {
View Full Code Here

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

    {
        try
        {
            CuratorEntry entry = CuratorEntry.mustGetEntry(connectionManager, projection);

            PathChildrenCache pathChildrenCache = CuratorEntry.mustGetThing(entry, cacheProjection.id, PathChildrenCache.class);
            return Lists.transform
            (
                pathChildrenCache.getCurrentData(),
                new Function<ChildData, RpcChildData>()
                {
                    @Override
                    public RpcChildData apply(ChildData childData)
                    {
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.