Package org.apache.zookeeper

Examples of org.apache.zookeeper.Watcher


   */
  private Watcher wrapWatcher(final Watcher watcher) {
    if (watcher == null) {
      return null;
    }
    return new Watcher() {
      @Override
      public void process(final WatchedEvent event) {
        eventExecutor.execute(new Runnable() {
          @Override
          public void run() {
View Full Code Here


        CreateLMThread(String root, String type, CyclicBarrier barrier) throws Exception {
            this.type = type;
            this.barrier = barrier;
            this.root = root;
            final CountDownLatch latch = new CountDownLatch(1);
            zkc = new ZooKeeper("127.0.0.1", 10000, new Watcher() {
                    public void process(WatchedEvent event) {
                        latch.countDown();
                    }
                });
            latch.await();
View Full Code Here

     * @return zk client instance
     */
    private ZooKeeper newZookeeper(final String zkServers,
                                   final int sessionTimeout) throws IOException {
        ZooKeeper newZk = new ZooKeeper(zkServers, sessionTimeout,
        new Watcher() {
            @Override
            public void process(WatchedEvent event) {
                // handle session disconnects and expires
                if (event.getType()
                .equals(Watcher.Event.EventType.None)) {
View Full Code Here

     *             Throws this exception if there is an error instantiating the
     *             BookKeeper client.
     */
    public BookKeeperAdmin(ClientConfiguration conf) throws IOException, InterruptedException, KeeperException {
        // Create the ZooKeeper client instance
        zk = new ZooKeeper(conf.getZkServers(), conf.getZkTimeout(), new Watcher() {
            @Override
            public void process(WatchedEvent event) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Process: " + event.getType() + " " + event.getPath());
                }
View Full Code Here

     * @throws InterruptedException
     * @throws KeeperException
     */
    public BookKeeper(ClientConfiguration conf) throws IOException, InterruptedException,
        KeeperException {
        this(conf, new ZooKeeper(conf.getZkServers(), conf.getZkTimeout(), new Watcher() {
            @Override
            public void process(WatchedEvent event) {
                // TODO: handle session disconnects and expires
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Process: " + event.getType() + " " + event.getPath());
View Full Code Here

  public static void releaseAllLocks(HiveConf conf) throws Exception {
    ZooKeeper zkpClient = null;
    try {
      int sessionTimeout = conf.getIntVar(HiveConf.ConfVars.HIVE_ZOOKEEPER_SESSION_TIMEOUT);
      String quorumServers = getQuorumServers(conf);
      Watcher dummWatcher = new DummyWatcher();
      zkpClient = new ZooKeeper(quorumServers, sessionTimeout, dummWatcher);
      String parent = conf.getVar(HiveConf.ConfVars.HIVE_ZOOKEEPER_NAMESPACE);
      List<HiveLock> locks = getLocks(conf, zkpClient, null, parent, false, false);
      Exception lastExceptionGot = null;
      if (locks != null) {
View Full Code Here

    protected void instantiateZookeeperClient() throws Exception {
        if (!conf.isStandalone()) {
            final CountDownLatch signalZkReady = new CountDownLatch(1);

            zk = new ZooKeeper(conf.getZkHost(), conf.getZkTimeout(), new Watcher() {
                @Override
                public void process(WatchedEvent event) {
                    if(Event.KeeperState.SyncConnected.equals(event.getState())) {
                        signalZkReady.countDown();
                    }
View Full Code Here

        super(cfg, scheduler);
        this.zk = zk;
        this.ephemeralNodePath = cfg.getZkHostsPrefix(new StringBuilder()).append("/").append(addr).toString();

        zk.register(new Watcher() {
            @Override
            public void process(WatchedEvent event) {
                if (event.getType().equals(Watcher.Event.EventType.None)) {
                    if (event.getState().equals(Watcher.Event.KeeperState.Disconnected)) {
                        logger.warn("ZK client has been disconnected to the ZK server!");
View Full Code Here

                    @Override
                    protected void realGetOwner(ByteString topic, boolean shouldClaim,
                    Callback<HedwigSocketAddress> cb, Object ctx) {
                        ZooKeeper zookeeper;
                        try {
                            zookeeper = new ZooKeeper(hostPort, 60000, new Watcher() {
                                @Override
                                public void process(WatchedEvent event) {
                                    // TODO Auto-generated method stub

                                }
View Full Code Here

            Assert.assertEquals(node.getActualPath(), PATH);
            Assert.assertEquals(client.getData().forPath(PATH), "a".getBytes());

            final Semaphore semaphore = new Semaphore(0);
            Watcher watcher = new Watcher()
            {
                @Override
                public void process(WatchedEvent arg0)
                {
                    semaphore.release();
View Full Code Here

TOP

Related Classes of org.apache.zookeeper.Watcher

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.