Examples of Watcher


Examples of org.apache.zookeeper.Watcher

    HServerLoad load = useInfoLoad ? info.getLoad() : new HServerLoad();
    String serverName = HServerInfo.getServerName(info);
    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(serverName, info.getServerAddress());
    master.getZooKeeperWrapper().updateRSLocationGetWatch(info, watcher);
    serversToServerInfo.put(serverName, info);
    serverAddressToServerInfo.put(info.getServerAddress(), info);
    serversToLoad.put(serverName, load);
    synchronized (loadToServers) {
View Full Code Here

Examples of org.apache.zookeeper.Watcher

      throws IOException, KeeperException, InterruptedException, ServiceException {
    final RecoverableZooKeeper recoverableZk = Mockito
        .mock(RecoverableZooKeeper.class);
    AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(
      this.server, this.serverManager);
    Watcher zkw = new ZooKeeperWatcher(HBaseConfiguration.create(), "unittest",
        null) {
      public RecoverableZooKeeper getRecoverableZooKeeper() {
        return recoverableZk;
      }
    };
View Full Code Here

Examples of org.apache.zookeeper.Watcher

        }
    }

    // 创建一个与服务器的连接
    public static ZooKeeper connection(String host) throws IOException {
        ZooKeeper zk = new ZooKeeper(host, 60000, new Watcher() {
            // 监控所有被触发的事件
            public void process(WatchedEvent event) {
                if (event.getType() == Event.EventType.NodeCreated && event.getPath().equals(PROFIT)) {
                    System.out.println("Queue has Completed!!!");
                }
View Full Code Here

Examples of org.apache.zookeeper.Watcher

        }
    }

    // 创建一个与服务器的连接
    public static ZooKeeper connection(String host) throws IOException {
        ZooKeeper zk = new ZooKeeper(host, 60000, new Watcher() {
            // 监控所有被触发的事件
            public void process(WatchedEvent event) {
                if (event.getType() == Event.EventType.NodeCreated && event.getPath().equals("/queue/start")) {
                    System.out.println("Queue has Completed.Finish testing!!!");
                }
View Full Code Here

Examples of org.apache.zookeeper.Watcher

public class BasicDemo1 {

    public static void main(String[] args) throws IOException, KeeperException, InterruptedException {
        // 创建一个与服务器的连接
        ZooKeeper zk = new ZooKeeper("192.168.1.201:2181", 60000, new Watcher() {
            // 监控所有被触发的事件
            public void process(WatchedEvent event) {
                System.out.println("EVENT:" + event.getType());
            }
        });
View Full Code Here

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

Examples of org.apache.zookeeper.Watcher

    "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

Examples of org.apache.zookeeper.Watcher

         // 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

Examples of org.apache.zookeeper.Watcher

         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

Examples of org.apache.zookeeper.Watcher

        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
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.