Java Code Examples for org.apache.hadoop.hbase.client.RegionInfo#isSplitParent()

The following examples show how to use org.apache.hadoop.hbase.client.RegionInfo#isSplitParent() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CatalogJanitor.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Override
public boolean visit(Result r) {
  if (r == null || r.isEmpty()) {
    return true;
  }
  this.report.count++;
  RegionInfo regionInfo = null;
  try {
    regionInfo = metaTableConsistencyCheck(r);
  } catch(Throwable t) {
    LOG.warn("Failed consistency check on {}", Bytes.toStringBinary(r.getRow()), t);
  }
  if (regionInfo != null) {
    LOG.trace(regionInfo.toString());
    if (regionInfo.isSplitParent()) { // splitParent means split and offline.
      this.report.splitParents.put(regionInfo, r);
    }
    if (MetaTableAccessor.hasMergeRegions(r.rawCells())) {
      this.report.mergedRegions.put(regionInfo, r);
    }
  }
  // Returning true means "keep scanning"
  return true;
}
 
Example 2
Source File: RegionStateNode.java    From hbase with Apache License 2.0 6 votes vote down vote up
public void checkOnline() throws DoNotRetryRegionException {
  RegionInfo ri = getRegionInfo();
  State s = state;
  if (s != State.OPEN) {
    throw new DoNotRetryRegionException(ri.getEncodedName() + " is not OPEN; state=" + s);
  }
  if (ri.isSplitParent()) {
    throw new DoNotRetryRegionException(
      ri.getEncodedName() + " is not online (splitParent=true)");
  }
  if (ri.isSplit()) {
    throw new DoNotRetryRegionException(ri.getEncodedName() + " has split=true");
  }
  if (ri.isOffline()) {
    // RegionOfflineException is not instance of DNRIOE so wrap it.
    throw new DoNotRetryRegionException(new RegionOfflineException(ri.getEncodedName()));
  }
}
 
Example 3
Source File: HbckChore.java    From hbase with Apache License 2.0 6 votes vote down vote up
private void loadRegionsFromInMemoryState() {
  List<RegionState> regionStates =
      master.getAssignmentManager().getRegionStates().getRegionStates();
  for (RegionState regionState : regionStates) {
    RegionInfo regionInfo = regionState.getRegion();
    if (master.getTableStateManager()
        .isTableState(regionInfo.getTable(), TableState.State.DISABLED)) {
      disabledTableRegions.add(regionInfo.getRegionNameAsString());
    }
    if (regionInfo.isSplitParent()) {
      splitParentRegions.add(regionInfo.getRegionNameAsString());
    }
    HbckRegionInfo.MetaEntry metaEntry =
        new HbckRegionInfo.MetaEntry(regionInfo, regionState.getServerName(),
            regionState.getStamp());
    regionInfoMap.put(regionInfo.getEncodedName(), new HbckRegionInfo(metaEntry));
  }
  LOG.info("Loaded {} regions from in-memory state of AssignmentManager", regionStates.size());
}
 
Example 4
Source File: TableSnapshotInputFormatImpl.java    From hbase with Apache License 2.0 6 votes vote down vote up
public static List<RegionInfo> getRegionInfosFromManifest(SnapshotManifest manifest) {
  List<SnapshotRegionManifest> regionManifests = manifest.getRegionManifests();
  if (regionManifests == null) {
    throw new IllegalArgumentException("Snapshot seems empty");
  }

  List<RegionInfo> regionInfos = Lists.newArrayListWithCapacity(regionManifests.size());

  for (SnapshotRegionManifest regionManifest : regionManifests) {
    RegionInfo hri = ProtobufUtil.toRegionInfo(regionManifest.getRegionInfo());
    if (hri.isOffline() && (hri.isSplit() || hri.isSplitParent())) {
      continue;
    }
    regionInfos.add(hri);
  }
  return regionInfos;
}
 
Example 5
Source File: TestCatalogJanitorInMemoryStates.java    From hbase with Apache License 2.0 5 votes vote down vote up
private PairOfSameType<RegionInfo> waitOnDaughters(final RegionInfo r)
    throws IOException {
  long start = System.currentTimeMillis();
  PairOfSameType<RegionInfo> pair = null;
  try (Connection conn = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration());
       Table metaTable = conn.getTable(TableName.META_TABLE_NAME)) {
    Result result = null;
    RegionInfo region = null;
    while ((System.currentTimeMillis() - start) < 60000) {
      result = metaTable.get(new Get(r.getRegionName()));
      if (result == null) {
        break;
      }
      region = CatalogFamilyFormat.getRegionInfo(result);
      if (region.isSplitParent()) {
        LOG.debug(region.toString() + " IS a parent!");
        pair = MetaTableAccessor.getDaughterRegions(result);
        break;
      }
      Threads.sleep(100);
    }

    if (pair.getFirst() == null || pair.getSecond() == null) {
      throw new IOException("Failed to get daughters, for parent region: " + r);
    }
    return pair;
  }
}
 
Example 6
Source File: ClientMetaTableAccessor.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public boolean visit(Result r) throws IOException {
  Optional<RegionLocations> currentRegionLocations = getRegionLocations(r);
  current = currentRegionLocations.orElse(null);
  if (current == null || current.getRegionLocation().getRegion() == null) {
    LOG.warn("No serialized RegionInfo in " + r);
    return true;
  }
  RegionInfo hri = current.getRegionLocation().getRegion();
  if (excludeOfflinedSplitParents && hri.isSplitParent()) {
    return true;
  }
  // Else call super and add this Result to the collection.
  return super.visit(r);
}
 
Example 7
Source File: TableSnapshotResultIterator.java    From phoenix with Apache License 2.0 5 votes vote down vote up
/**
 * Exclude offline split parent regions and
 * regions that don't intersect with provided scan
 */
private boolean isValidRegion(RegionInfo hri) {
  if (hri.isOffline() && (hri.isSplit() || hri.isSplitParent())) {
    return false;
  }
  return PrivateCellUtil.overlappingKeys(scan.getStartRow(), scan.getStopRow(),
          hri.getStartKey(), hri.getEndKey());
}
 
Example 8
Source File: CatalogJanitor.java    From hbase with Apache License 2.0 4 votes vote down vote up
/**
 * Check row.
 * @param metaTableRow Row from hbase:meta table.
 * @return Returns default regioninfo found in row parse as a convenience to save
 *   on having to do a double-parse of Result.
 */
private RegionInfo metaTableConsistencyCheck(Result metaTableRow) {
  RegionInfo ri;
  // Locations comes back null if the RegionInfo field is empty.
  // If locations is null, ensure the regioninfo is for sure empty before progressing.
  // If really empty, report as missing regioninfo!  Otherwise, can run server check
  // and get RegionInfo from locations.
  RegionLocations locations = CatalogFamilyFormat.getRegionLocations(metaTableRow);
  if (locations == null) {
    ri = CatalogFamilyFormat.getRegionInfo(metaTableRow,
        HConstants.REGIONINFO_QUALIFIER);
  } else {
    ri = locations.getDefaultRegionLocation().getRegion();
    checkServer(locations);
  }

  if (ri == null) {
    this.report.emptyRegionInfo.add(metaTableRow.getRow());
    return ri;
  }

  if (!Bytes.equals(metaTableRow.getRow(), ri.getRegionName())) {
    LOG.warn("INCONSISTENCY: Row name is not equal to serialized info:regioninfo content; " +
            "row={} {}; See if RegionInfo is referenced in another hbase:meta row? Delete?",
        Bytes.toStringBinary(metaTableRow.getRow()), ri.getRegionNameAsString());
    return null;
  }
  // Skip split parent region
  if (ri.isSplitParent()) {
    return ri;
  }
  // If table is disabled, skip integrity check.
  if (!isTableDisabled(ri)) {
    if (isTableTransition(ri)) {
      // On table transition, look to see if last region was last in table
      // and if this is the first. Report 'hole' if neither is true.
      // HBCK1 used to have a special category for missing start or end keys.
      // We'll just lump them in as 'holes'.
      if ((this.previous != null && !this.previous.isLast()) || !ri.isFirst()) {
        addHole(this.previous == null? RegionInfo.UNDEFINED: this.previous, ri);
      }
    } else {
      if (!this.previous.isNext(ri)) {
        if (this.previous.isOverlap(ri)) {
          addOverlap(this.previous, ri);
        } else if (ri.isOverlap(this.highestEndKeyRegionInfo)) {
          // We may have seen a region a few rows back that overlaps this one.
          addOverlap(this.highestEndKeyRegionInfo, ri);
        } else if (!this.highestEndKeyRegionInfo.isNext(ri)) {
          // Need to check the case if this.highestEndKeyRegionInfo.isNext(ri). If no,
          // report a hole, otherwise, it is ok. For an example,
          // previous: [aa, bb), ri: [cc, dd), highestEndKeyRegionInfo: [a, cc)
          // In this case, it should not report a hole, as highestEndKeyRegionInfo covers
          // the hole between previous and ri.
          addHole(this.previous, ri);
        }
      } else if (ri.isOverlap(this.highestEndKeyRegionInfo)) {
        // We may have seen a region a few rows back that overlaps this one
        // even though it properly 'follows' the region just before.
        addOverlap(this.highestEndKeyRegionInfo, ri);
      }
    }
  }
  this.previous = ri;
  this.highestEndKeyRegionInfo =
      MetaFixer.getRegionInfoWithLargestEndKey(this.highestEndKeyRegionInfo, ri);
  return ri;
}
 
Example 9
Source File: CatalogJanitor.java    From hbase with Apache License 2.0 4 votes vote down vote up
/**
 * Run through referenced servers and save off unknown and the dead.
 */
private void checkServer(RegionLocations locations) {
  if (this.services == null) {
    // Can't do this test if no services.
    return;
  }
  if (locations == null) {
    return;
  }
  if (locations.getRegionLocations() == null) {
    return;
  }
  // Check referenced servers are known/online. Here we are looking
  // at both the default replica -- the main replica -- and then replica
  // locations too.
  for (HRegionLocation location: locations.getRegionLocations()) {
    if (location == null) {
      continue;
    }
    ServerName sn = location.getServerName();
    if (sn == null) {
      continue;
    }
    if (location.getRegion() == null) {
      LOG.warn("Empty RegionInfo in {}", location);
      // This should never happen but if it does, will mess up below.
      continue;
    }
    RegionInfo ri = location.getRegion();
    // Skip split parent region
    if (ri.isSplitParent()) {
      continue;
    }
    // skip the offline regions which belong to disabled table.
    if (isTableDisabled(ri)) {
      continue;
    }
    RegionState rs = this.services.getAssignmentManager().getRegionStates().getRegionState(ri);
    if (rs == null || rs.isClosedOrAbnormallyClosed()) {
      // If closed against an 'Unknown Server', that is should be fine.
      continue;
    }
    ServerManager.ServerLiveState state = this.services.getServerManager().
        isServerKnownAndOnline(sn);
    switch (state) {
      case UNKNOWN:
        this.report.unknownServers.add(new Pair<>(ri, sn));
        break;

      default:
        break;
    }
  }
}
 
Example 10
Source File: TestEndToEndSplitTransaction.java    From hbase with Apache License 2.0 4 votes vote down vote up
/**
 * Blocks until the region split is complete in hbase:meta and region server opens the daughters
 */
public static void blockUntilRegionSplit(Configuration conf, long timeout,
    final byte[] regionName, boolean waitForDaughters) throws IOException, InterruptedException {
  long start = System.currentTimeMillis();
  log("blocking until region is split:" + Bytes.toStringBinary(regionName));
  RegionInfo daughterA = null, daughterB = null;
  try (Connection conn = ConnectionFactory.createConnection(conf);
      Table metaTable = conn.getTable(TableName.META_TABLE_NAME)) {
    Result result = null;
    RegionInfo region = null;
    while ((System.currentTimeMillis() - start) < timeout) {
      result = metaTable.get(new Get(regionName));
      if (result == null) {
        break;
      }

      region = CatalogFamilyFormat.getRegionInfo(result);
      if (region.isSplitParent()) {
        log("found parent region: " + region.toString());
        PairOfSameType<RegionInfo> pair = MetaTableAccessor.getDaughterRegions(result);
        daughterA = pair.getFirst();
        daughterB = pair.getSecond();
        break;
      }
      Threads.sleep(100);
    }
    if (daughterA == null || daughterB == null) {
      throw new IOException("Failed to get daughters, daughterA=" + daughterA + ", daughterB=" +
        daughterB + ", timeout=" + timeout + ", result=" + result + ", regionName=" +
        Bytes.toString(regionName) + ", region=" + region);
    }

    // if we are here, this means the region split is complete or timed out
    if (waitForDaughters) {
      long rem = timeout - (System.currentTimeMillis() - start);
      blockUntilRegionIsInMeta(conn, rem, daughterA);

      rem = timeout - (System.currentTimeMillis() - start);
      blockUntilRegionIsInMeta(conn, rem, daughterB);

      rem = timeout - (System.currentTimeMillis() - start);
      blockUntilRegionIsOpened(conf, rem, daughterA);

      rem = timeout - (System.currentTimeMillis() - start);
      blockUntilRegionIsOpened(conf, rem, daughterB);

      // Compacting the new region to make sure references can be cleaned up
      compactAndBlockUntilDone(TEST_UTIL.getAdmin(),
        TEST_UTIL.getMiniHBaseCluster().getRegionServer(0), daughterA.getRegionName());
      compactAndBlockUntilDone(TEST_UTIL.getAdmin(),
        TEST_UTIL.getMiniHBaseCluster().getRegionServer(0), daughterB.getRegionName());

      removeCompactedFiles(conn, timeout, daughterA);
      removeCompactedFiles(conn, timeout, daughterB);
    }
  }
}
 
Example 11
Source File: MapReduceParallelScanGrouper.java    From phoenix with Apache License 2.0 4 votes vote down vote up
private boolean isValidRegion(RegionInfo hri) {
	if (hri.isOffline() && (hri.isSplit() || hri.isSplitParent())) {
		return false;
	}
	return true;
}