Package org.apache.hadoop.hbase.master

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


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


  }

  @Test (timeout=180000)
  public void testMasterFailoverWhenDisablingTableRegionsInRITOnDeadRS() throws Exception {
    MiniHBaseCluster cluster = TESTUTIL.getHBaseCluster();
    HMaster master = cluster.getMaster();
    // disable load balancing on this master
    master.balanceSwitch(false);

    final String table = "testMasterFailoverWhenDisablingTableRegionsInRITOnDeadRS";
    byte [] FAMILY = Bytes.toBytes("family");
    byte[][] SPLIT_KEYS =
        new byte[][] {Bytes.toBytes("a"), Bytes.toBytes("b"), Bytes.toBytes("c"),
            Bytes.toBytes("d") };
    HTableDescriptor htd = new HTableDescriptor(table);
    HColumnDescriptor hcd = new HColumnDescriptor(FAMILY);
    htd.addFamily(hcd);
    TESTUTIL.getHBaseAdmin().createTable(htd, SPLIT_KEYS);
    AssignmentManager am = cluster.getMaster().getAssignmentManager();
    List<HRegionInfo> regionsOfTable = null;
    while ((regionsOfTable = am.getRegionsOfTable(table.getBytes())).size()
        != (SPLIT_KEYS.length + 1)) {
      Thread.sleep(10);
    }
    HRegionInfo closingRegion = regionsOfTable.get(0);
    ServerName serverName = am.getRegionServerOfRegion(closingRegion);
    HRegionServer deadRS = null;
    for (int i = 0; i < cluster.getRegionServerThreads().size(); i++) {
      deadRS = cluster.getRegionServer(i);
      if (deadRS.getServerName().equals(serverName)) {
        break;
      }
    }

    // Disable the table in ZK
    ZKTable zkTable = am.getZKTable();
    zkTable.setDisablingTable(table);
    ZKAssign.createNodeClosing(master.getZooKeeper(), closingRegion, serverName);

    // Stop the master
    abortMaster(cluster);
    master = startMasterAndWaitTillMetaRegionAssignment(cluster);
    deadRS.kill();
    deadRS.join();
    waitUntilMasterIsInitialized(master);
    am = cluster.getMaster().getAssignmentManager();
    zkTable = am.getZKTable();
    // wait for no more RIT
    ZKAssign.blockUntilNoRIT(master.getZooKeeper());
    while (!master.getAssignmentManager().getZKTable().isDisabledTable(table)) {
      Thread.sleep(10);
    }
    assertTrue("Table should be disabled state.", zkTable.isDisabledTable(table));
    HBaseAdmin admin = new HBaseAdmin(master.getConfiguration());
    admin.deleteTable(table);
  }
View Full Code Here

      setupTable(table);
      assertEquals(ROWKEYS.length, countRows());

      // Mess it up by creating an overlap
      MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
      HMaster master = cluster.getMaster();
      HRegionInfo hriOverlap1 = createRegion(conf, tbl.getTableDescriptor(),
        Bytes.toBytes("A"), Bytes.toBytes("AB"));
      master.assignRegion(hriOverlap1);
      master.getAssignmentManager().waitForAssignment(hriOverlap1);
      HRegionInfo hriOverlap2 = createRegion(conf, tbl.getTableDescriptor(),
        Bytes.toBytes("AB"), Bytes.toBytes("B"));
      master.assignRegion(hriOverlap2);
      master.getAssignmentManager().waitForAssignment(hriOverlap2);

      HBaseFsck hbck = doFsck(conf, false);
      assertErrors(hbck, new ERROR_CODE[] {ERROR_CODE.DUPE_STARTKEYS,
        ERROR_CODE.DUPE_STARTKEYS, ERROR_CODE.OVERLAP_IN_REGION_CHAIN});
      assertEquals(3, hbck.getOverlapGroups(table).size());
View Full Code Here

  @Test
  public void testStarted() throws Exception {
    MiniHBaseCluster cluster = UTIL.getHBaseCluster();

    HMaster master = cluster.getMaster();
    assertTrue("Master should be active", master.isActiveMaster());
    MasterCoprocessorHost host = master.getCoprocessorHost();
    assertNotNull("CoprocessorHost should not be null", host);
    CPMasterObserver cp = (CPMasterObserver)host.findCoprocessor(
        CPMasterObserver.class.getName());
    assertNotNull("CPMasterObserver coprocessor not found or not installed!", cp);
View Full Code Here

  @Test
  public void testTableOperations() throws Exception {
    MiniHBaseCluster cluster = UTIL.getHBaseCluster();

    HMaster master = cluster.getMaster();
    MasterCoprocessorHost host = master.getCoprocessorHost();
    CPMasterObserver cp = (CPMasterObserver)host.findCoprocessor(
        CPMasterObserver.class.getName());
    cp.enableBypass(true);
    cp.resetStates();
    assertFalse("No table created yet", cp.wasCreateTableCalled());
View Full Code Here

  @Test
  public void testRegionTransitionOperations() throws Exception {
    MiniHBaseCluster cluster = UTIL.getHBaseCluster();

    HMaster master = cluster.getMaster();
    MasterCoprocessorHost host = master.getCoprocessorHost();
    CPMasterObserver cp = (CPMasterObserver)host.findCoprocessor(
        CPMasterObserver.class.getName());
    cp.enableBypass(false);
    cp.resetStates();

    HTable table = UTIL.createTable(TEST_TABLE, TEST_FAMILY);
    UTIL.createMultiRegions(table, TEST_FAMILY);
    UTIL.waitUntilAllRegionsAssigned(TEST_TABLE);
   
    NavigableMap<HRegionInfo, ServerName> regions = table.getRegionLocations();
    Map.Entry<HRegionInfo, ServerName> firstGoodPair = null;
    for (Map.Entry<HRegionInfo, ServerName> e: regions.entrySet()) {
      if (e.getValue() != null) {
        firstGoodPair = e;
        break;
      }
    }
    assertNotNull("Found a non-null entry", firstGoodPair);
    LOG.info("Found " + firstGoodPair.toString());
    // Try to force a move
    Collection<ServerName> servers = master.getClusterStatus().getServers();
    String destName = null;
    String firstRegionHostnamePortStr = firstGoodPair.getValue().toString();
    LOG.info("firstRegionHostnamePortStr=" + firstRegionHostnamePortStr);
    boolean found = false;
    // Find server that is NOT carrying the first region
    for (ServerName info : servers) {
      LOG.info("ServerName=" + info);
      if (!firstRegionHostnamePortStr.equals(info.getHostAndPort())) {
        destName = info.toString();
        found = true;
        break;
      }
    }
    assertTrue("Found server", found);
    LOG.info("Found " + destName);
    master.move(firstGoodPair.getKey().getEncodedNameAsBytes(),
      Bytes.toBytes(destName));
    assertTrue("Coprocessor should have been called on region move",
      cp.wasMoveCalled());

    // make sure balancer is on
    master.balanceSwitch(true);
    assertTrue("Coprocessor should have been called on balance switch",
        cp.wasBalanceSwitchCalled());

    // force region rebalancing
    master.balanceSwitch(false);
    // move half the open regions from RS 0 to RS 1
    HRegionServer rs = cluster.getRegionServer(0);
    byte[] destRS = Bytes.toBytes(cluster.getRegionServer(1).getServerName().toString());
    //Make sure no regions are in transition now
    waitForRITtoBeZero(master);
    List<HRegionInfo> openRegions = rs.getOnlineRegions();
    int moveCnt = openRegions.size()/2;
    for (int i=0; i<moveCnt; i++) {
      HRegionInfo info = openRegions.get(i);
      if (!info.isMetaTable()) {
        master.move(openRegions.get(i).getEncodedNameAsBytes(), destRS);
      }
    }
    //Make sure no regions are in transition now
    waitForRITtoBeZero(master);
    // now trigger a balance
    master.balanceSwitch(true);
    boolean balanceRun = master.balance();
    assertTrue("Coprocessor should be called on region rebalancing",
        cp.wasBalanceCalled());
  }
View Full Code Here

  }

  @Test
  public void testSnapshotOperations() throws Exception {
    MiniHBaseCluster cluster = UTIL.getHBaseCluster();
    HMaster master = cluster.getMaster();
    MasterCoprocessorHost host = master.getCoprocessorHost();
    CPMasterObserver cp = (CPMasterObserver)host.findCoprocessor(
        CPMasterObserver.class.getName());
    cp.resetStates();

    // create a table
View Full Code Here

  @Test
  public void testTableDescriptorsEnumeration() throws Exception {
    MiniHBaseCluster cluster = UTIL.getHBaseCluster();

    HMaster master = cluster.getMaster();
    MasterCoprocessorHost host = master.getCoprocessorHost();
    CPMasterObserver cp = (CPMasterObserver)host.findCoprocessor(
        CPMasterObserver.class.getName());
    cp.resetStates();

    master.getHTableDescriptors();

    assertTrue("Coprocessor should be called on table descriptors request",
      cp.wasGetTableDescriptorsCalled());
  }
View Full Code Here

  /**
   * Expire the Master's session
   * @throws Exception
   */
  public void expireMasterSession() throws Exception {
    HMaster master = getMiniHBaseCluster().getMaster();
    expireSession(master.getZooKeeper(), false);
  }
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

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.