Package org.apache.zookeeper

Examples of org.apache.zookeeper.Watcher


  private ServerWatcher modelWatcher = new ServerWatcher();

  public Server(int port) throws TTransportException, IOException,
      InterruptedException, KeeperException {
    zk = new ZooKeeper("localhost", 2181, new Watcher() {
      @Override
      public void process(WatchedEvent watchedEvent) {
        // ignore
      }
    });
View Full Code Here


    "talk.politics.mideast",
    "talk.politics.misc",
    "talk.religion.misc");

  public static void main(String[] args) throws TException, IOException, InterruptedException, KeeperException {
    ZooKeeper zk = new ZooKeeper("localhost", 2181, new Watcher() {
      @Override
      public void process(WatchedEvent watchedEvent) {
        // ignore
      }
    });
View Full Code Here

         // ok ... so now we have stuff going all the way through. let's kick
         // the middle Mp's zookeeper cluster and see what happens.
         ZooKeeper origZk = zookeeperCluster.zkref.get();
         long sessionid = origZk.getSessionId();
         ZooKeeper killer = new ZooKeeper(System.getProperty("zk_connect"),5000, new Watcher() { @Override public void process(WatchedEvent arg0) { } }, sessionid, null);
         killer.close(); // tricks the server into expiring the other session

//         // we should be getting failures now ...
//         // but it's possible that it can reconnect prior to actually seeing an error so if this
//         //   fails frequently we need to remove this test.
View Full Code Here

         if (!calledBack)
            killer.close();

         final AtomicBoolean isExpired = new AtomicBoolean(false);
         ZooKeeper check = new ZooKeeper("127.0.0.1:" + port,5000, new Watcher()
         {
            @Override
            public void process(WatchedEvent event)
            {
               if (event.getState() == Watcher.Event.KeeperState.Expired)
View Full Code Here

        public Watcher expirePart1(int which) {
            String path = serverIds.get(which);
            System.out.printf("before %s[%s] = %s\n", Thread.currentThread().getId(), System.identityHashCode(data), data);
            data.remove(path);
            System.out.printf("after %s[%s] = %s\n", Thread.currentThread().getId(), System.identityHashCode(data), data);
            Watcher oldWatch = watchers.remove(which);

            // notify all other nodes that node "which" has disappeared
            String dir = path.replaceAll("^(.*?)(/[^/]*)?$", "$1");
            if (watched.contains(dir)) {
                for (Watcher watcher : Lists.newArrayList(watchers)) {
View Full Code Here

        fake.disconnect(0);
        // TODO this breaks because the mocking causes the update not to propagate from one thread to another
        // very mysterious, but essentially undebuggable without some help from the author of jmockit.

        Watcher w = fake.expirePart1(0);

        // the other (unexpired) server should now know it is the only one
        assertEquals(1, Iterables.size(cs2.getCluster()));

        fake.expirePart2(w);
View Full Code Here

      throw new RuntimeException(e);
    }
  }

  public ZookeeperClusterStatus(String connectionStr, BlurConfiguration configuration) throws IOException {
    this(new ZooKeeper(connectionStr, 30000, new Watcher() {
      @Override
      public void process(WatchedEvent event) {

      }
    }), configuration);
View Full Code Here

  }

  public void register(final BlurShutdown shutdown, ZooKeeper zooKeeper) {
    this.shutdown = shutdown;
    this.zooKeeper = zooKeeper;
    zooKeeper.register(new Watcher() {
      @Override
      public void process(WatchedEvent event) {
        KeeperState state = event.getState();
        if (state == KeeperState.Expired) {
          LOG.fatal("Zookeeper session has [" + state + "] server process shutting down.");
View Full Code Here

   * Constructor
   * @param conf
   * @throws IOException
   */
  public ZooKeeperAuthenticator(HBaseConfiguration conf) throws IOException {
    this(conf, new ZooKeeperWrapper(conf, new Watcher() {
      public void process(WatchedEvent event) { }
    }));
    ensureExists(USERS_ZNODE_ROOT);
  }
View Full Code Here

    ZkConnection connection = ((ZkConnection) _zkClient.getConnection());
    ZooKeeper zookeeper = connection.getZookeeper();
    System.out.println("old sessionId= " + zookeeper.getSessionId());
    try
    {
      Watcher watcher = new Watcher(){
        @Override
        public void process(WatchedEvent event)
        {
          System.out.println("In New connection In process event:"+ event);
        }
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.