Package org.apache.zookeeper

Examples of org.apache.zookeeper.Watcher


        (
            localZookeeperFactory,
            builder.getEnsembleProvider(),
            builder.getSessionTimeoutMs(),
            builder.getConnectionTimeoutMs(),
            new Watcher()
            {
                @Override
                public void process(WatchedEvent watchedEvent)
                {
                    CuratorEvent event = new CuratorEventImpl
View Full Code Here


            setLeadership(true);
        }
        else
        {
            String watchPath = sortedChildren.get(ourIndex - 1);
            Watcher watcher = new Watcher()
            {
                @Override
                public void process(WatchedEvent event)
                {
                    if ( (state.get() == State.STARTED) && (event.getType() == Event.EventType.NodeDeleted) && (localOurPath != null) )
View Full Code Here

    LOG.info("Getting safe mode lock.");
    final Object lock = new Object();
    String blurSafemodePath = ZookeeperPathConstants.getSafemodePath(cluster);
    String newPath = zookeeper.create(blurSafemodePath + "/safemode-", nodeName.getBytes(), Ids.OPEN_ACL_UNSAFE,
        CreateMode.EPHEMERAL_SEQUENTIAL);
    Watcher watcher = new Watcher() {
      @Override
      public void process(WatchedEvent event) {
        synchronized (lock) {
          lock.notifyAll();
        }
View Full Code Here

      _debugStackTrace = writer.toString();
    }
    _watchThread = new Thread(new Runnable() {
      @Override
      public void run() {
        Watcher watcher = new Watcher() {
          @Override
          public void process(WatchedEvent event) {
            synchronized (_lock) {
              _lock.notify();
            }
View Full Code Here

    HServerLoad load = useInfoLoad ? info.getLoad() : new HServerLoad();
    String serverName = info.getServerName();
    info.setLoad(load);
    // We must set this watcher here because it can be set on a fresh start
    // or on a failover
    Watcher watcher = new ServerExpirer(new HServerInfo(info));
    this.master.getZooKeeperWrapper().updateRSLocationGetWatch(info, watcher);
    this.serversToServerInfo.put(serverName, info);
    this.serversToLoad.put(serverName, load);
    synchronized (this.loadToServers) {
      Set<String> servers = this.loadToServers.get(load);
View Full Code Here

  @BeforeClass
  public static void startZooKeeper() throws IOException {
    new File(path).mkdirs();
    MiniCluster.startZooKeeper(path);
    zk = new ZooKeeper(MiniCluster.getZkConnectionString(), 20000, new Watcher() {
      @Override
      public void process(WatchedEvent event) {

      }
    });
View Full Code Here

    assertEquals(0, zooKeeperLockManager.getNumberOfLockNodesPresent(SafeMode.STARTUP));
  }

  @Test
  public void testExtraNodeStartup() throws IOException, InterruptedException, KeeperException {
    ZooKeeper zk = new ZooKeeper(MiniCluster.getZkConnectionString(), 20000, new Watcher() {
      @Override
      public void process(WatchedEvent event) {

      }
    });
View Full Code Here

    zk.close();
  }

  @Test
  public void testSecondNodeStartup() throws IOException, InterruptedException, KeeperException {
    ZooKeeper zk = new ZooKeeper(MiniCluster.getZkConnectionString(), 20000, new Watcher() {
      @Override
      public void process(WatchedEvent event) {

      }
    });
View Full Code Here

        // see http://wiki.apache.org/hadoop/ZooKeeper/FAQ#A4

        final Timing                  timing = new Timing();

        final CountDownLatch    latch = new CountDownLatch(1);
        Watcher                 watcher = new Watcher()
        {
            @Override
            public void process(WatchedEvent event)
            {
                if ( event.getState() == Event.KeeperState.Expired )
View Full Code Here

        synchronized (mutex) {

          if (getNodeName(taskId, superstep).equals(
              pathToSuperstepZnode + "/" + lowest)) {
            Stat s = zk.exists(pathToSuperstepZnode + "/" + highest,
                new Watcher() {
                  @Override
                  public void process(WatchedEvent event) {
                    synchronized (mutex) {
                      LOG.debug("leaveBarrier() at superstep: " + superstep
                          + " taskid:" + taskId.toString()
                          + " highest notify lowest.");
                      mutex.notifyAll();
                    }
                  }
                });

            if (null != s) {
              LOG.debug("leaveBarrier(): superstep:" + superstep + " taskid:"
                  + taskId.toString() + " wait for higest notify.");
              mutex.wait();
            }
          } else {
            Stat s1 = zk.exists(getNodeName(taskId, superstep), false);

            if (null != s1) {
              try {
                zk.delete(getNodeName(taskId, superstep), 0);
              } catch (KeeperException.NoNodeException nne) {
                LOG.warn("++++ Ignore because node may be dleted.", nne);
              }
            }

            Stat s2 = zk.exists(pathToSuperstepZnode + "/" + lowest,
                new Watcher() {
                  @Override
                  public void process(WatchedEvent event) {
                    synchronized (mutex) {
                      LOG.debug("leaveBarrier() at superstep: " + superstep
                          + " taskid:" + taskId.toString()
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.