Examples of ZooKeeperWrapper


Examples of org.apache.hadoop.hbase.zookeeper.ZooKeeperWrapper

   */
  public List<HServerAddress> getPeersAddresses(String peerClusterId) {
    if (this.peerClusters.size() == 0) {
      return new ArrayList<HServerAddress>(0);
    }
    ZooKeeperWrapper zkw = this.peerClusters.get(peerClusterId);
    return zkw == null?
        new ArrayList<HServerAddress>(0) : zkw.scanRSDirectory();
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.zookeeper.ZooKeeperWrapper

    }
    Configuration otherConf = new Configuration(this.conf);
    otherConf.set(HConstants.ZOOKEEPER_QUORUM, ensemble[0]);
    otherConf.set("hbase.zookeeper.property.clientPort", ensemble[1]);
    otherConf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, ensemble[2]);
    ZooKeeperWrapper zkw = ZooKeeperWrapper.createInstance(otherConf,
        "connection to cluster: " + peerId);
    zkw.registerListener(new ReplicationStatusWatcher());
    this.peerClusters.put(peerId, zkw);
    this.zookeeperWrapper.ensureExists(this.zookeeperWrapper.getZNode(
        this.rsServerNameZnode, peerId));
    LOG.info("Added new peer cluster " + StringUtils.arrayToString(ensemble));
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.zookeeper.ZooKeeperWrapper

    HRegionServer rs = hbaseCluster.getRegionServer(index);
    expireSession(rs.getZooKeeperWrapper());
  }

  public void expireSession(ZooKeeperWrapper nodeZK) throws Exception{
    ZooKeeperWrapper zkw =
        ZooKeeperWrapper.createInstance(conf,
            ZooKeeperWrapper.class.getName());
    zkw.registerListener(EmptyWatcher.instance);
    String quorumServers = zkw.getQuorumServers();
    int sessionTimeout = 5 * 1000; // 5 seconds

    byte[] password = nodeZK.getSessionPassword();
    long sessionID = nodeZK.getSessionID();

View Full Code Here

Examples of org.apache.hadoop.hbase.zookeeper.ZooKeeperWrapper

  @Test
  public void testClientSessionExpired()
      throws IOException, InterruptedException {
    new HTable(conf, HConstants.META_TABLE_NAME);

    ZooKeeperWrapper zkw =
        ZooKeeperWrapper.createInstance(conf, TestZooKeeper.class.getName());
    zkw.registerListener(EmptyWatcher.instance);
    String quorumServers = zkw.getQuorumServers();
    int sessionTimeout = 5 * 1000; // 5 seconds
    HConnection connection = HConnectionManager.getConnection(conf);
    ZooKeeperWrapper connectionZK = connection.getZooKeeperWrapper();
    long sessionID = connectionZK.getSessionID();
    byte[] password = connectionZK.getSessionPassword();

    ZooKeeper zk = new ZooKeeper(quorumServers, sessionTimeout,
        EmptyWatcher.instance, sessionID, password);
    zk.close();

View Full Code Here

Examples of org.apache.hadoop.hbase.zookeeper.ZooKeeperWrapper

   * (it will fail), then delete it recursively, then delete the last znode
   * @throws Exception
   */
  @Test
  public void testZNodeDeletes() throws Exception {
    ZooKeeperWrapper zkw =
        ZooKeeperWrapper.createInstance(conf, TestZooKeeper.class.getName());
    zkw.registerListener(EmptyWatcher.instance);
    zkw.ensureExists("/l1/l2/l3/l4");
    try {
      zkw.deleteZNode("/l1/l2");
      fail("We should not be able to delete if znode has childs");
    } catch (KeeperException ex) {
      assertNotNull(zkw.getData("/l1/l2/l3", "l4"));
    }
    zkw.deleteZNode("/l1/l2", true);
    assertNull(zkw.getData("/l1/l2/l3", "l4"));
    zkw.deleteZNode("/l1");
    assertNull(zkw.getData("/l1", "l2"));
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.zookeeper.ZooKeeperWrapper

    this.metaRescanInterval =
      conf.getInt("hbase.master.meta.thread.rescanfrequency", 60 * 1000);

    this.sleeper = new Sleeper(this.threadWakeFrequency, this.closed);
   
    zooKeeperWrapper = new ZooKeeperWrapper(conf, this);
    zkMasterAddressWatcher = new ZKMasterAddressWatcher(this);
    serverManager = new ServerManager(this);
    regionManager = new RegionManager(this);
   
    writeAddressToZooKeeper(true);
View Full Code Here

Examples of org.apache.hadoop.hbase.zookeeper.ZooKeeperWrapper

      // Can we still be the master? If not, goodbye

      zooKeeperWrapper.close();
      try {
        zooKeeperWrapper = new ZooKeeperWrapper(conf, this);

        if(!writeAddressToZooKeeper(false)) {
          throw new Exception("Another Master is currently active");
        }
View Full Code Here

Examples of org.apache.hadoop.hbase.zookeeper.ZooKeeperWrapper

  /**
   * @throws IOException
   */
  public void testWritesRootRegionLocation() throws IOException {
    ZooKeeperWrapper zooKeeper = new ZooKeeperWrapper(conf, EmptyWatcher.instance);

    boolean outOfSafeMode = zooKeeper.checkOutOfSafeMode();
    assertFalse(outOfSafeMode);

    HServerAddress zooKeeperRootAddress = zooKeeper.readRootRegionLocation();
    assertNull(zooKeeperRootAddress);

    HMaster master = cluster.getMaster();
    HServerAddress masterRootAddress = master.getRootRegionLocation();
    assertNull(masterRootAddress);

    new HTable(conf, HConstants.META_TABLE_NAME);

    outOfSafeMode = zooKeeper.checkOutOfSafeMode();
    assertTrue(outOfSafeMode);

    zooKeeperRootAddress = zooKeeper.readRootRegionLocation();
    assertNotNull(zooKeeperRootAddress);

    masterRootAddress = master.getRootRegionLocation();
    assertEquals(masterRootAddress, zooKeeperRootAddress);
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.zookeeper.ZooKeeperWrapper

   * @throws IOException
   */
  public void testParentExists() throws IOException {
    String oldValue = conf.get("zookeeper.znode.safemode");
    conf.set("zookeeper.znode.safemode", "/a/b/c/d/e");
    ZooKeeperWrapper zooKeeper = new ZooKeeperWrapper(conf, EmptyWatcher.instance);
    assertTrue(zooKeeper.writeOutOfSafeMode());
    conf.set("zookeeper.znode.safemode", oldValue);
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.zookeeper.ZooKeeperWrapper

   * @throws InterruptedException
   */
  public void testClientSessionExpired() throws IOException, InterruptedException {
    new HTable(conf, HConstants.META_TABLE_NAME);

    ZooKeeperWrapper zkw = new ZooKeeperWrapper(conf, EmptyWatcher.instance);
    String quorumServers = zkw.getQuorumServers();
    int sessionTimeout = conf.getInt("zookeeper.session.timeout", 2 * 1000);
    HConnection connection = HConnectionManager.getConnection(conf);
    ZooKeeperWrapper connectionZK = connection.getZooKeeperWrapper();
    long sessionID = connectionZK.getSessionID();
    byte[] password = connectionZK.getSessionPassword();

    ZooKeeper zk = new ZooKeeper(quorumServers, sessionTimeout, EmptyWatcher.instance, sessionID, password);
    zk.close();

    Thread.sleep(sessionTimeout * 2);
 
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.