Examples of CuratorFramework


Examples of com.netflix.curator.framework.CuratorFramework

    builder.connectString(connectionString);
    TimeSpan retryInterval = TimeSpan.FIVE_SECONDS;
    RetryPolicy retryPolicy = new RetryOneTime((int) retryInterval.getTotalMilliseconds());
    builder.retryPolicy(retryPolicy);

    CuratorFramework curatorFramework;
    try {
      curatorFramework = builder.build();
    } catch (IOException e) {
      throw new OpsException("Error building zookeeper connection", e);
    }
View Full Code Here

Examples of com.netflix.curator.framework.CuratorFramework

   * @return
   */
  public CuratorFramework mkClient(Map conf, List<String> servers,
      Object port, String root, final WatcherCallBack watcher) {

    CuratorFramework fk = Utils.newCurator(conf, servers, port, root);

    fk.getCuratorListenable().addListener(new CuratorListener() {
      @Override
      public void eventReceived(CuratorFramework _fk, CuratorEvent e)
          throws Exception {

        if (e.getType().equals(CuratorEventType.WATCHED)) {
          WatchedEvent event = e.getWatchedEvent();

          watcher.execute(event.getState(), event.getType(),
              event.getPath());
        }

      }
    });

    fk.getUnhandledErrorListenable().addListener(
        new UnhandledErrorListener() {
          @Override
          public void unhandledError(String msg, Throwable error) {
            String errmsg = "Unrecoverable Zookeeper error, halting process: "
                + msg;
            LOG.error(errmsg, error);
            StormUtils.halt_process(1,
                "Unrecoverable Zookeeper error");

          }
        });

    fk.start();

    return fk;
  }
View Full Code Here

Examples of com.netflix.curator.framework.CuratorFramework

    for (String zkServer : (List<String>) servers) {
      serverPorts.add(zkServer + ":" + Utils.getInt(port));
    }
    String zkStr = StringUtils.join(serverPorts, ",") + root;
    try {
      CuratorFramework ret = CuratorFrameworkFactory
          .newClient(
              zkStr,
              Utils.getInt(conf
                  .get(Config.STORM_ZOOKEEPER_SESSION_TIMEOUT)),
              15000,
View Full Code Here

Examples of com.netflix.curator.framework.CuratorFramework

    return newCurator(conf, servers, port, "");
  }

  public static CuratorFramework newCuratorStarted(Map conf,
      List<String> servers, Object port, String root) {
    CuratorFramework ret = newCurator(conf, servers, port, root);
    ret.start();
    return ret;
  }
View Full Code Here

Examples of com.netflix.curator.framework.CuratorFramework

    return ret;
  }

  public static CuratorFramework newCuratorStarted(Map conf,
      List<String> servers, Object port) {
    CuratorFramework ret = newCurator(conf, servers, port);
    ret.start();
    return ret;
  }
View Full Code Here

Examples of com.netflix.curator.framework.CuratorFramework

  private WatcherCallBack watcher;

  public DistributedClusterState(Map _conf) throws Exception {
    conf = _conf;
    zkobj = new Zookeeper();
    CuratorFramework _zk = mkZk();
    String path = String.valueOf(conf.get(Config.STORM_ZOOKEEPER_ROOT));
    zkobj.mkdirs(_zk, path);
    _zk.close();

    active = new AtomicBoolean(true);

    watcher = new WatcherCallBack() {
      @SuppressWarnings("unchecked")
View Full Code Here

Examples of com.netflix.curator.framework.CuratorFramework

                              .get(Config.TOPOLOGY_KRYO_REGISTER));
            }
            String rootDir = conf.get(Config.TRANSACTIONAL_ZOOKEEPER_ROOT) + "/" + id + "/" + subroot;
            List<String> servers = (List<String>) getWithBackup(conf, Config.TRANSACTIONAL_ZOOKEEPER_SERVERS, Config.STORM_ZOOKEEPER_SERVERS);
            Object port = getWithBackup(conf, Config.TRANSACTIONAL_ZOOKEEPER_PORT, Config.STORM_ZOOKEEPER_PORT);
            CuratorFramework initter = Utils.newCuratorStarted(conf, servers, port);
            try {
                initter.create().creatingParentsIfNeeded().forPath(rootDir);
            } catch(KeeperException.NodeExistsException e)  {
               
            }
           
            initter.close();
                                   
            _curator = Utils.newCuratorStarted(conf, servers, port, rootDir);
            _ser = new KryoValuesSerializer(conf);
            _des = new KryoValuesDeserializer(conf);
        } catch (Exception e) {
View Full Code Here

Examples of org.apache.curator.framework.CuratorFramework

{
    @Test
    public void connectionLossWithBackgroundTest() throws Exception
    {
        Timing timing = new Timing();
        CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), 1, new RetryOneTime(1));
        try
        {
            final CountDownLatch latch = new CountDownLatch(1);
            client.start();
            client.getZookeeperClient().blockUntilConnectedOrTimedOut();
            server.close();
            client.getChildren().inBackground
            (
                new BackgroundCallback()
                {
                    public void processResult(CuratorFramework client, CuratorEvent event) throws Exception
                    {
                        latch.countDown();
                    }
                }
            ).forPath("/");
            Assert.assertTrue(timing.awaitLatch(latch));
        }
        finally
        {
            client.close();
        }
    }
View Full Code Here

Examples of org.apache.curator.framework.CuratorFramework

    @Test
    public void testReconnectAfterLoss() throws Exception
    {
        Timing timing = new Timing();
        CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1));
        try
        {
            client.start();

            final CountDownLatch lostLatch = new CountDownLatch(1);
            ConnectionStateListener listener = new ConnectionStateListener()
            {
                @Override
                public void stateChanged(CuratorFramework client, ConnectionState newState)
                {
                    if ( newState == ConnectionState.LOST )
                    {
                        lostLatch.countDown();
                    }
                }
            };
            client.getConnectionStateListenable().addListener(listener);

            client.checkExists().forPath("/");

            server.close();

            Assert.assertTrue(timing.awaitLatch(lostLatch));

            try
            {
                client.checkExists().forPath("/");
                Assert.fail();
            }
            catch ( KeeperException.ConnectionLossException e )
            {
                // correct
            }

            server = new TestingServer(server.getPort());
            client.checkExists().forPath("/");
        }
        finally
        {
            Closeables.closeQuietly(client);
        }
View Full Code Here

Examples of org.apache.curator.framework.CuratorFramework

    @Test
    public void testGetAclNoStat() throws Exception
    {

        CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), new RetryOneTime(1));
        client.start();
        try
        {
            try
            {
                client.getACL().forPath("/");
            }
            catch ( NullPointerException e )
            {
                Assert.fail();
            }
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.