Package org.apache.hadoop.hbase.master

Examples of org.apache.hadoop.hbase.master.HMaster


   */
  @Test(timeout = 60000)
  public void testMasterZKSessionRecoveryFailure() throws Exception {
    LOG.info("Starting testMasterZKSessionRecoveryFailure");
    MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
    HMaster m = cluster.getMaster();
    m.abort("Test recovery from zk session expired",
      new KeeperException.SessionExpiredException());
    assertFalse(m.isStopped());
    testSanity("testMasterZKSessionRecoveryFailure");
  }
View Full Code Here


   */
  @Test
  public void testRegionAssignmentAfterMasterRecoveryDueToZKExpiry() throws Exception {
    MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
    cluster.startRegionServer();
    HMaster m = cluster.getMaster();
    ZooKeeperWatcher zkw = m.getZooKeeperWatcher();
    int expectedNumOfListeners = zkw.getNumberOfListeners();
    // now the cluster is up. So assign some regions.
    HBaseAdmin admin = new HBaseAdmin(TEST_UTIL.getConfiguration());
    try {
      byte[][] SPLIT_KEYS = new byte[][] { Bytes.toBytes("a"), Bytes.toBytes("b"),
        Bytes.toBytes("c"), Bytes.toBytes("d"), Bytes.toBytes("e"), Bytes.toBytes("f"),
        Bytes.toBytes("g"), Bytes.toBytes("h"), Bytes.toBytes("i"), Bytes.toBytes("j") };
      String tableName = "testRegionAssignmentAfterMasterRecoveryDueToZKExpiry";
      admin.createTable(new HTableDescriptor(TableName.valueOf(tableName)), SPLIT_KEYS);
      ZooKeeperWatcher zooKeeperWatcher = HBaseTestingUtility.getZooKeeperWatcher(TEST_UTIL);
      ZKAssign.blockUntilNoRIT(zooKeeperWatcher);
      m.getZooKeeperWatcher().close();
      MockLoadBalancer.retainAssignCalled = false;
      m.abort("Test recovery from zk session expired",
        new KeeperException.SessionExpiredException());
      assertFalse(m.isStopped());
      // The recovered master should not call retainAssignment, as it is not a
      // clean startup.
      assertFalse("Retain assignment should not be called", MockLoadBalancer.retainAssignCalled);
      // number of listeners should be same as the value before master aborted
      assertEquals(expectedNumOfListeners, zkw.getNumberOfListeners());
View Full Code Here

  @Test(timeout = 240000)
  public void testLogSplittingAfterMasterRecoveryDueToZKExpiry() throws IOException,
      KeeperException, InterruptedException {
    MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
    cluster.startRegionServer();
    HMaster m = cluster.getMaster();
    // now the cluster is up. So assign some regions.
    HBaseAdmin admin = new HBaseAdmin(TEST_UTIL.getConfiguration());
    HTable table = null;
    try {
      byte[][] SPLIT_KEYS = new byte[][] { Bytes.toBytes("1"), Bytes.toBytes("2"),
        Bytes.toBytes("3"), Bytes.toBytes("4"), Bytes.toBytes("5") };

      String tableName = "testLogSplittingAfterMasterRecoveryDueToZKExpiry";
      HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(tableName));
      HColumnDescriptor hcd = new HColumnDescriptor("col");
      htd.addFamily(hcd);
      admin.createTable(htd, SPLIT_KEYS);
      ZooKeeperWatcher zooKeeperWatcher = HBaseTestingUtility.getZooKeeperWatcher(TEST_UTIL);
      ZKAssign.blockUntilNoRIT(zooKeeperWatcher);
      table = new HTable(TEST_UTIL.getConfiguration(), tableName);
      Put p;
      int numberOfPuts;
      for (numberOfPuts = 0; numberOfPuts < 6; numberOfPuts++) {
        p = new Put(Bytes.toBytes(numberOfPuts));
        p.add(Bytes.toBytes("col"), Bytes.toBytes("ql"), Bytes.toBytes("value" + numberOfPuts));
        table.put(p);
      }
      m.getZooKeeperWatcher().close();
      m.abort("Test recovery from zk session expired",
        new KeeperException.SessionExpiredException());
      assertFalse(m.isStopped());
      cluster.getRegionServer(0).abort("Aborting");
      // Without patch for HBASE-6046 this test case will always timeout
      // with patch the test case should pass.
      Scan scan = new Scan();
      int numberOfRows = 0;
View Full Code Here

  /**
   * Cause a master to exit without shutting down entire cluster.
   * @param serverNumber  Used as index into a list.
   */
  public String abortMaster(int serverNumber) {
    HMaster server = getMaster(serverNumber);
    LOG.info("Aborting " + server.toString());
    server.abort("Aborting for tests", new Exception("Trace info"));
    return server.toString();
  }
View Full Code Here

  public void close() throws IOException {
  }

  @Override
  public ClusterStatus getClusterStatus() throws IOException {
    HMaster master = getMaster();
    return master == null ? null : master.getClusterStatus();
  }
View Full Code Here

    // take the snapshot async
    admin.takeSnapshotAsync(snapshot);

    // constantly loop, looking for the snapshot to complete
    HMaster master = UTIL.getMiniHBaseCluster().getMaster();
    SnapshotTestingUtils.waitForSnapshotToComplete(master, new HSnapshotDescription(snapshot), 200);
    LOG.info(" === Async Snapshot Completed ===");
    FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
      FSUtils.getRootDir(UTIL.getConfiguration()), LOG);
    // make sure we get the snapshot
View Full Code Here

  @Test
  public void testCreateTableCalledTwiceAndFirstOneInProgress() throws Exception {
    final byte[] tableName = Bytes.toBytes("testCreateTableCalledTwiceAndFirstOneInProgress");
    final MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
    final HMaster m = cluster.getMaster();
    final HTableDescriptor desc = new HTableDescriptor(tableName);
    desc.addFamily(new HColumnDescriptor(FAMILYNAME));
    final HRegionInfo[] hRegionInfos = new HRegionInfo[] { new HRegionInfo(desc.getName(), null,
        null) };
    CustomCreateTableHandler handler = new CustomCreateTableHandler(m, m.getMasterFileSystem(),
        m.getServerManager(), desc, cluster.getConfiguration(), hRegionInfos,
        m.getCatalogTracker(), m.getAssignmentManager());
    throwException = true;
    handler.process();
    throwException = false;
    CustomCreateTableHandler handler1 = new CustomCreateTableHandler(m, m.getMasterFileSystem(),
        m.getServerManager(), desc, cluster.getConfiguration(), hRegionInfos,
        m.getCatalogTracker(), m.getAssignmentManager());
    handler1.process();
    for (int i = 0; i < 100; i++) {
      if (!TEST_UTIL.getHBaseAdmin().isTableAvailable(tableName)) {
        Thread.sleep(200);
      }
View Full Code Here

  @Test (timeout=300000)
  public void testCreateTableWithSplitRegion() throws Exception {
    final byte[] tableName = Bytes.toBytes("testCreateTableWithSplitRegion");
    final MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
    final HMaster m = cluster.getMaster();
    final HTableDescriptor desc = new HTableDescriptor(tableName);
    desc.addFamily(new HColumnDescriptor(FAMILYNAME));
    byte[] splitPoint = Bytes.toBytes("split-point");
    long ts = System.currentTimeMillis();
    HRegionInfo d1 = new HRegionInfo(tableName, null, splitPoint, false, ts);
    HRegionInfo d2 = new HRegionInfo(tableName, splitPoint, null, false, ts + 1);
    HRegionInfo parent = new HRegionInfo(tableName, null, null, true, ts + 2);
    parent.setOffline(true);

    Path tempdir = m.getMasterFileSystem().getTempDir();
    FileSystem fs = m.getMasterFileSystem().getFileSystem();
    Path tempTableDir = FSUtils.getTablePath(tempdir, tableName);
    fs.delete(tempTableDir, true); // Clean up temp table dir if exists

    final HRegionInfo[] hRegionInfos = new HRegionInfo[] {d1, d2, parent};
    CreateTableHandler handler = new CreateTableHandler(m, m.getMasterFileSystem(),
      m.getServerManager(), desc, cluster.getConfiguration(), hRegionInfos,
      m.getCatalogTracker(), m.getAssignmentManager());
    handler.process();
    for (int i = 0; i < 200; i++) {
      if (!TEST_UTIL.getHBaseAdmin().isTableAvailable(tableName)) {
        Thread.sleep(300);
      }
    }
    assertTrue(TEST_UTIL.getHBaseAdmin().isTableEnabled(tableName));
    assertTrue(TEST_UTIL.getHBaseAdmin().isTableAvailable(tableName));
    List<HRegionInfo> regions = m.getAssignmentManager().getRegionsOfTable(tableName);
    assertFalse("Split parent should not be assigned", regions.contains(parent));
  }
View Full Code Here

  @Test (timeout=60000)
  public void testMasterRestartAfterEnablingNodeIsCreated() throws Exception {
    byte[] tableName = Bytes.toBytes("testMasterRestartAfterEnablingNodeIsCreated");
    final MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
    final HMaster m = cluster.getMaster();
    final HTableDescriptor desc = new HTableDescriptor(tableName);
    desc.addFamily(new HColumnDescriptor(FAMILYNAME));
    final HRegionInfo[] hRegionInfos = new HRegionInfo[] { new HRegionInfo(desc.getName(), null,
        null) };
    CustomCreateTableHandler handler = new CustomCreateTableHandler(m, m.getMasterFileSystem(),
        m.getServerManager(), desc, cluster.getConfiguration(), hRegionInfos,
        m.getCatalogTracker(), m.getAssignmentManager());
    throwException = true;
    handler.process();
    abortAndStartNewMaster(cluster);
    assertTrue(cluster.getLiveMasterThreads().size() == 1);
  }
View Full Code Here

  }

  private void moveRegionAndWait(HRegion destRegion, HRegionServer destServer)
      throws InterruptedException, MasterNotRunningException,
      ZooKeeperConnectionException, IOException {
    HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster();
    TEST_UTIL.getHBaseAdmin().move(
        destRegion.getRegionInfo().getEncodedNameAsBytes(),
        Bytes.toBytes(destServer.getServerName().getServerName()));
    while (true) {
      ServerName serverName = master.getAssignmentManager()
          .getRegionServerOfRegion(destRegion.getRegionInfo());
      if (serverName != null && serverName.equals(destServer.getServerName())) break;
      Thread.sleep(10);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.master.HMaster

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.