Package org.apache.hadoop.hbase.master

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


      meta.delete(new Delete(daughters.getFirst().getRegionName()));
      meta.delete(new Delete(daughters.getSecond().getRegionName()));
      meta.flushCommits();

      // Remove daughters from regionStates
      RegionStates regionStates = TEST_UTIL.getMiniHBaseCluster().getMaster().
        getAssignmentManager().getRegionStates();
      regionStates.deleteRegion(daughters.getFirst());
      regionStates.deleteRegion(daughters.getSecond());

      HBaseFsck hbck = doFsck(conf, false);
      assertErrors(hbck, new ERROR_CODE[] {ERROR_CODE.NOT_IN_META_OR_DEPLOYED,
          ERROR_CODE.NOT_IN_META_OR_DEPLOYED, ERROR_CODE.HOLE_IN_REGION_CHAIN}); //no LINGERING_SPLIT_PARENT
View Full Code Here


      Thread.sleep(500);
    }

    // Now open the region again.
    HMaster master = cluster.getMaster();
    RegionStates states = master.getAssignmentManager().getRegionStates();
    states.regionOffline(hri);
    states.updateRegionState(hri, State.OPENING);
    ProtobufUtil.openRegion(rs.getRSRpcServices(), rs.getServerName(), hri);
    startTime = EnvironmentEdgeManager.currentTime();
    while (true) {
      if (rs.getOnlineRegion(regionName) != null) {
        break;
View Full Code Here

    // Randomly choose one of the two merged regions
    HRegionInfo hri = RandomUtils.nextBoolean() ?
      mergedRegions.getFirst() : mergedRegions.getSecond();
    MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
    AssignmentManager am = cluster.getMaster().getAssignmentManager();
    RegionStates regionStates = am.getRegionStates();
    long start = EnvironmentEdgeManager.currentTime();
    while (!regionStates.isRegionInState(hri, State.MERGED)) {
      assertFalse("Timed out in waiting one merged region to be in state MERGED",
        EnvironmentEdgeManager.currentTime() - start > 60000);
      Thread.sleep(500);
    }

    // We should not be able to assign it again
    am.assign(hri, true);
    assertFalse("Merged region can't be assigned",
      regionStates.isRegionInTransition(hri));
    assertTrue(regionStates.isRegionInState(hri, State.MERGED));

    // We should not be able to unassign it either
    am.unassign(hri, null);
    assertFalse("Merged region can't be unassigned",
      regionStates.isRegionInTransition(hri));
    assertTrue(regionStates.isRegionInState(hri, State.MERGED));

    table.close();
  }
View Full Code Here

    final TableName tableName = TableName.valueOf("testMerge");

    try {
      // Create table and load data.
      Table table = createTableAndLoadData(master, tableName);
      RegionStates regionStates = master.getAssignmentManager().getRegionStates();
      List<HRegionInfo> regions = regionStates.getRegionsOfTable(tableName);
      // Fake offline one region
      HRegionInfo a = regions.get(0);
      HRegionInfo b = regions.get(1);
      regionStates.regionOffline(a);
      try {
        // Merge offline region. Region a is offline here
        admin.mergeRegions(a.getEncodedNameAsBytes(), b.getEncodedNameAsBytes(), false);
        fail("Offline regions should not be able to merge");
      } catch (IOException ie) {
View Full Code Here

    public ReportRegionStateTransitionResponse reportRegionStateTransition(RpcController c,
        ReportRegionStateTransitionRequest req) throws ServiceException {
      ReportRegionStateTransitionResponse resp = super.reportRegionStateTransition(c, req);
      if (enabled.get() && req.getTransition(0).getTransitionCode()
          == TransitionCode.READY_TO_MERGE && !resp.hasErrorMessage()) {
        RegionStates regionStates = myMaster.getAssignmentManager().getRegionStates();
        for (RegionState regionState: regionStates.getRegionsInTransition().values()) {
          // Find the merging_new region and remove it
          if (regionState.isMergingNew()) {
            regionStates.deleteRegion(regionState.getRegion());
          }
        }
      }
      return resp;
    }
View Full Code Here

    forceRegionsOffline(metaChanges.getRegionsToRemove());
  }

  private void forceRegionsOffline(final List<HRegionInfo> hris) {
    AssignmentManager am = this.masterServices.getAssignmentManager();
    RegionStates states = am.getRegionStates();
    if (hris != null) {
      for (HRegionInfo hri: hris) {
        states.regionOffline(hri);
      }
    }
  }
View Full Code Here

        synchronized (this.colocationInfo) {
            if (!isTableColocated(table)) {
                throw new IllegalArgumentException("Specified table " + table
                        + " should be in one of the tables to co-locate.");
            }
            RegionStates regionStates = this.master.getAssignmentManager().getRegionStates();
            List<HRegionInfo> onlineRegions = regionStates.getRegionsOfTable(table);
            for (HRegionInfo hri : onlineRegions) {
                regionOnline(hri, regionStates.getRegionServerOfRegion(hri));
            }
            Map<String, RegionState> regionsInTransition = regionStates.getRegionsInTransition();
            for (RegionState regionState : regionsInTransition.values()) {
                if (table.equals(regionState.getRegion().getTable())
                        && regionState.getServerName() != null) {
                    regionOnline(regionState.getRegion(), regionState.getServerName());
                }
View Full Code Here

    @Test(timeout = 180000)
    public void testColocationAfterRegionsMerge() throws Exception {
        MiniHBaseCluster cluster = UTIL.getHBaseCluster();
        HMaster master = cluster.getMaster();
        RegionStates regionStates = master.getAssignmentManager().getRegionStates();
        // Table names to make use of the
        TableName tableName = TableName.valueOf("testColocationAfterRegionsMerge");
        TableName indexTableName = TableName.valueOf("testColocationAfterRegionsMerge_index");
        createUserAndIndexTable(tableName, indexTableName);
        ServerName server = cluster.getRegionServer(0).getServerName();
        List<HRegionInfo> regionsOfUserTable = regionStates.getRegionsOfTable(tableName);
        Pair<HRegionInfo, HRegionInfo> regionsToMerge = new Pair<HRegionInfo, HRegionInfo>();
        byte[] startKey1 = { (byte) 'C' };
        byte[] startKey2 = { (byte) 'D' };
        for (HRegionInfo region : regionsOfUserTable) {
            if (Bytes.compareTo(startKey1, region.getStartKey()) == 0) {
                regionsToMerge.setFirst(region);
            } else if (Bytes.compareTo(startKey2, region.getStartKey()) == 0) {
                regionsToMerge.setSecond(region);
            }
        }
        admin.move(regionsToMerge.getFirst().getEncodedNameAsBytes(), Bytes.toBytes(server
                .toString()));
        admin.move(regionsToMerge.getSecond().getEncodedNameAsBytes(), Bytes.toBytes(server
                .toString()));

        List<HRegionInfo> regionsOfIndexTable = regionStates.getRegionsOfTable(indexTableName);
        Pair<HRegionInfo, HRegionInfo> indexRegionsToMerge = new Pair<HRegionInfo, HRegionInfo>();
        for (HRegionInfo region : regionsOfIndexTable) {
            if (Bytes.compareTo(startKey1, region.getStartKey()) == 0) {
                indexRegionsToMerge.setFirst(region);
            } else if (Bytes.compareTo(startKey2, region.getStartKey()) == 0) {
                indexRegionsToMerge.setSecond(region);
            }
        }
        admin.move(indexRegionsToMerge.getFirst().getEncodedNameAsBytes(), Bytes.toBytes(server
                .toString()));
        admin.move(indexRegionsToMerge.getSecond().getEncodedNameAsBytes(), Bytes.toBytes(server
                .toString()));
        while (!regionStates.getRegionServerOfRegion(regionsToMerge.getFirst()).equals(server)
                || !regionStates.getRegionServerOfRegion(regionsToMerge.getSecond()).equals(server)
                || !regionStates.getRegionServerOfRegion(indexRegionsToMerge.getFirst()).equals(
                    server)
                || !regionStates.getRegionServerOfRegion(indexRegionsToMerge.getSecond()).equals(
                    server)) {
            Threads.sleep(1000);
        }
        admin.mergeRegions(regionsToMerge.getFirst().getEncodedNameAsBytes(), regionsToMerge
                .getSecond().getEncodedNameAsBytes(), true);
        admin.mergeRegions(indexRegionsToMerge.getFirst().getEncodedNameAsBytes(),
            indexRegionsToMerge.getSecond().getEncodedNameAsBytes(), true);

        while (regionsOfUserTable.size() != 20 || regionsOfIndexTable.size() != 20) {
            Thread.sleep(100);
            regionsOfUserTable = regionStates.getRegionsOfTable(tableName);
            regionsOfIndexTable = regionStates.getRegionsOfTable(indexTableName);
        }
        boolean isRegionColocated =
                checkForColocation(master, tableName.getNameAsString(), indexTableName
                        .getNameAsString());
        assertTrue("User regions and index regions should colocate.", isRegionColocated);
View Full Code Here

      for (int i=0; !firstSplitCompleted && i<100; i++) {
        Thread.sleep(100);
      }
      assertTrue("fist split did not complete", firstSplitCompleted);

      RegionStates regionStates = cluster.getMaster().getAssignmentManager().getRegionStates();
      Map<String, RegionState> rit = regionStates.getRegionsInTransition();

      for (int i=0; rit.containsKey(hri.getTable()) && i<100; i++) {
        Thread.sleep(100);
      }
      assertFalse("region still in transition", rit.containsKey(
View Full Code Here

      LOG.info("Waiting for region to come out of RIT");
      TESTING_UTIL.waitFor(60000, 1000, new Waiter.Predicate<Exception>() {
        @Override
        public boolean evaluate() throws Exception {
          RegionStates regionStates = cluster.getMaster().getAssignmentManager().getRegionStates();
          Map<String, RegionState> rit = regionStates.getRegionsInTransition();
          return !rit.containsKey(hri.getEncodedName());
        }
      });
    } finally {
      admin.setBalancerRunning(true, false);
View Full Code Here

TOP

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

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.