Package org.apache.hadoop.hbase

Examples of org.apache.hadoop.hbase.MiniZooKeeperCluster


  private static void startZooKeeper() throws Exception {
    if (zooKeeperCluster != null) {
      LOG.error("ZooKeeper already running");
      return;
    }
    zooKeeperCluster = new MiniZooKeeperCluster();
    zooKeeperCluster.startup(testDir);
    LOG.info("started " + zooKeeperCluster.getClass().getName());
  }
View Full Code Here


    // above.
    final int retries = 5;
    this.conf.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER_KEY, retries);
    // Note that this is done before we create the MiniHBaseCluster because we
    // need to edit the config to add the ZooKeeper servers.
    MiniZooKeeperCluster zooKeeperCluster = new MiniZooKeeperCluster();
    int clientPort =
      zooKeeperCluster.startup(new java.io.File(this.testDir.toString()));
    conf.set("hbase.zookeeper.property.clientPort",
      Integer.toString(clientPort));
    MiniHBaseCluster cluster = new MiniHBaseCluster(this.conf, 1);
    try {
      HBaseAdmin hb = new HBaseAdmin(this.conf);
      assertTrue(hb.isMasterRunning());
      HTableDescriptor [] tables = hb.listTables();
      assertEquals(2, tables.length);
      boolean foundTable = false;
      // Just look at table 'a'.
      final String tablenameStr = "a";
      final byte [] tablename = Bytes.toBytes(tablenameStr);
      for (int i = 0; i < tables.length; i++) {
        byte [] tableName = tables[i].getName();
        if (Bytes.equals(tablename, tables[i].getName())) {
          foundTable = true;
          break;
        }
      }
      assertTrue(foundTable);
      LOG.info(tablenameStr + " exists.  Now waiting till startcode " +
        "changes before opening a scanner");
      waitOnStartCodeChange(retries);
      // Delete again so we go get it all fresh.
      HConnectionManager.deleteConnectionInfo(conf, false);
      HTable t = new HTable(this.conf, tablename);
      int count = 0;
      LOG.info("OPENING SCANNER");
      Scan scan = new Scan();
      ResultScanner s = t.getScanner(scan);
      try {
        for (Result r: s) {
          if (r == null || r.size() == 0) {
            break;
          }
          count++;
        }
        assertEquals(EXPECTED_COUNT, count);
      } finally {
        s.close();
      }
    } finally {
      HConnectionManager.deleteConnectionInfo(conf, false);
      cluster.shutdown();
      try {
        zooKeeperCluster.shutdown();
      } catch (IOException e) {
        LOG.warn("Shutting down ZooKeeper cluster", e);
      }
    }
  }
View Full Code Here

            LOG.info("vmInputArguments=" + runtime.getInputArguments());
          }
          // If 'local', defer to LocalHBaseCluster instance.  Starts master
          // and regionserver both in the one JVM.
          if (LocalHBaseCluster.isLocal(conf)) {
            final MiniZooKeeperCluster zooKeeperCluster =
              new MiniZooKeeperCluster();
            File zkDataPath = new File(conf.get("hbase.zookeeper.property.dataDir"));
            int zkClientPort = conf.getInt("hbase.zookeeper.property.clientPort", 0);
            if (zkClientPort == 0) {
              throw new IOException("No config value for hbase.zookeeper.property.clientPort");
            }
            zooKeeperCluster.setTickTime(conf.getInt("hbase.zookeeper.property.tickTime", 3000));
            zooKeeperCluster.setClientPort(zkClientPort);
            int clientPort = zooKeeperCluster.startup(zkDataPath);
            if (clientPort != zkClientPort) {
              String errorMsg = "Couldnt start ZK at requested address of " +
                  zkClientPort + ", instead got: " + clientPort + ". Aborting. Why? " +
                  "Because clients (eg shell) wont be able to find this ZK quorum";
              System.err.println(errorMsg);
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.MiniZooKeeperCluster

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.