@Override public boolean visit(Result r) throws IOException { if (r == null || r.isEmpty()) return true; count.incrementAndGet(); RegionInfo info = MetaTableAccessor.getRegionInfo(r); if (info == null) return true; // Keep scanning if (isTableSpecified && info.getTable().compareTo(tableName) > 0) { // Another table, stop scanning return false; } if (LOG.isTraceEnabled()) LOG.trace("" + info + " IS-SPLIT_PARENT=" + info.isSplitParent()); if (info.isSplitParent()) splitParents.put(info, r); if (r.getValue(HConstants.CATALOG_FAMILY, HConstants.MERGEA_QUALIFIER) != null) { mergedRegions.put(info, r); } // Returning true means "keep scanning" return true; } };
@Override public boolean visit(Result r) throws IOException { current = getRegionLocations(r); if (!current.isPresent() || current.get().getRegionLocation().getRegion() == null) { LOG.warn("No serialized RegionInfo in " + r); return true; } RegionInfo hri = current.get().getRegionLocation().getRegion(); if (excludeOfflinedSplitParents && hri.isSplitParent()) return true; // Else call super and add this Result to the collection. return super.visit(r); }
/** * Create any replicas for the regions (the default replicas that was already created is passed to * the method) * @param tableDescriptor descriptor to use * @param regions existing regions * @param oldReplicaCount existing replica count * @param newReplicaCount updated replica count due to modify table * @return the combined list of default and non-default replicas */ public static List<RegionInfo> addReplicas(final TableDescriptor tableDescriptor, final List<RegionInfo> regions, int oldReplicaCount, int newReplicaCount) { if ((newReplicaCount - 1) <= 0) { return regions; } List<RegionInfo> hRegionInfos = new ArrayList<>((newReplicaCount) * regions.size()); for (RegionInfo ri : regions) { if (RegionReplicaUtil.isDefaultReplica(ri) && (!ri.isOffline() || (!ri.isSplit() && !ri.isSplitParent()))) { // region level replica index starts from 0. So if oldReplicaCount was 2 then the max replicaId for // the existing regions would be 1 for (int j = oldReplicaCount; j < newReplicaCount; j++) { hRegionInfos.add(RegionReplicaUtil.getRegionInfoForReplica(ri, j)); } } } hRegionInfos.addAll(regions); return hRegionInfos; } }
List<RegionInfo> parentRegions = new LinkedList<>(); for (RegionInfo regionInfo: regionInfos) { if (regionInfo.isSplitParent()) { parentRegions.add(regionInfo); } else {
/** * Creates a region which is the parent of a split. * * @param storeSizes A list of sizes for each Store. * @return A mocked Region. */ private Region mockSplitParentRegionWithSize(Collection<Long> storeSizes) { final Region r = mockRegionWithSize(storeSizes); final RegionInfo info = r.getRegionInfo(); when(info.isSplitParent()).thenReturn(true); return r; }
@Override public boolean visit(Result r) throws IOException { current = getRegionLocations(r); 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); }
if (region.getRegionInfo().isSplitParent()) { skippedSplitParents++; continue;
if (h != null && h.getServerName() != null) { RegionInfo hri = h.getRegion(); if (hri == null || hri.isSplitParent() || hri.getReplicaId() != RegionInfo.DEFAULT_REPLICA_ID) { continue;
private boolean isValidRegion(RegionInfo hri) { // An offline split parent region should be excluded. if (hri.isOffline() && (hri.isSplit() || hri.isSplitParent())) { return false; } return PrivateCellUtil.overlappingKeys(scan.getStartRow(), scan.getStopRow(), hri.getStartKey(), hri.getEndKey()); }
private boolean onScanNext(TableName tableName, LocateRequest req, Result result) { RegionLocations locs = MetaTableAccessor.getRegionLocations(result); if (LOG.isDebugEnabled()) { LOG.debug("The fetched location of '{}', row='{}', locateType={} is {}", tableName, Bytes.toStringBinary(req.row), req.locateType, locs); } // the default region location should always be presented when fetching from meta, otherwise // let's fail the request. if (locs == null || locs.getDefaultRegionLocation() == null) { complete(tableName, req, null, new HBaseIOException(String.format("No location found for '%s', row='%s', locateType=%s", tableName, Bytes.toStringBinary(req.row), req.locateType))); return true; } HRegionLocation loc = locs.getDefaultRegionLocation(); RegionInfo info = loc.getRegion(); if (info == null) { complete(tableName, req, null, new HBaseIOException(String.format("HRegionInfo is null for '%s', row='%s', locateType=%s", tableName, Bytes.toStringBinary(req.row), req.locateType))); return true; } if (info.isSplitParent()) { return false; } complete(tableName, req, locs, null); return true; }
if (info == null || info.isOffline() || info.isSplitParent()) { continue;
@Override public void split(final TableName tableName, final byte[] splitPoint) throws IOException { checkTableExists(tableName); for (HRegionLocation loc : connection.locateRegions(tableName, false, false)) { ServerName sn = loc.getServerName(); if (sn == null) { continue; } RegionInfo r = loc.getRegion(); // check for parents if (r.isSplitParent()) { continue; } // if a split point given, only split that particular region if (r.getReplicaId() != RegionInfo.DEFAULT_REPLICA_ID || (splitPoint != null && !r.containsRow(splitPoint))) { continue; } // call out to master to do split now splitRegionAsync(r, splitPoint); } }
if (region != null && region.getFirst() != null && region.getSecond() != null) { RegionInfo hri = region.getFirst(); if (hri.isOffline() && (hri.isSplit() || hri.isSplitParent())) continue; regionServers.add(region.getSecond().toString()); if (regionInfo.isOffline() && (regionInfo.isSplit() || regionInfo.isSplitParent()) && RegionReplicaUtil.isDefaultReplica(regionInfo)) { LOG.info("Take disabled snapshot of offline region=" + regionInfo);
if (region != null && region.getFirst() != null && region.getSecond() != null) { RegionInfo hri = region.getFirst(); if (hri.isOffline() && (hri.isSplit() || hri.isSplitParent())) continue; regionServers.add(region.getSecond().toString());
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 = MetaTableAccessor.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; } } }
if (p != null && p.getFirst() != null && p.getSecond() != null) { RegionInfo hri = p.getFirst(); if (hri.isOffline() && (hri.isSplit() || hri.isSplitParent())) continue; serverNames.add(p.getSecond().toString());
public void checkOnline() throws DoNotRetryRegionException { RegionInfo ri = getRegionInfo(); State s = state; if (s != State.OPEN) { throw new DoNotRetryRegionException(ri.getEncodedName() + " is no 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())); } }
List<RegionInfo> regionsToAssign = new ArrayList<>(); newRegions.forEach(ri -> { if (ri.isOffline() && (ri.isSplit() || ri.isSplitParent())) { splitRegions.add(ri); } else {
for (SnapshotRegionManifest snapshotRegionManifest : regionManifests.values()) { RegionInfo hri = ProtobufUtil.toRegionInfo(snapshotRegionManifest.getRegionInfo()); if (hri.isOffline() && (hri.isSplit() || hri.isSplitParent())) { continue;
if (region.isSplitParent()) { log("found parent region: " + region.toString()); PairOfSameType<RegionInfo> pair = MetaTableAccessor.getDaughterRegions(result);