/** * Returns the merge regions by reading the corresponding columns of the catalog table * Result. * @param data a Result object from the catalog table scan * @return a pair of RegionInfo or PairOfSameType(null, null) if the region is not a split * parent */ public static PairOfSameType<RegionInfo> getMergeRegions(Result data) { RegionInfo mergeA = getRegionInfo(data, HConstants.MERGEA_QUALIFIER); RegionInfo mergeB = getRegionInfo(data, HConstants.MERGEB_QUALIFIER); return new PairOfSameType<>(mergeA, mergeB); }
/** * Returns the daughter regions by reading the corresponding columns of the catalog table * Result. * @param data a Result object from the catalog table scan * @return a pair of RegionInfo or PairOfSameType(null, null) if the region is not a split * parent */ public static PairOfSameType<RegionInfo> getDaughterRegions(Result data) { RegionInfo splitA = getRegionInfo(data, HConstants.SPLITA_QUALIFIER); RegionInfo splitB = getRegionInfo(data, HConstants.SPLITB_QUALIFIER); return new PairOfSameType<>(splitA, splitB); }
@Override public PairOfSameType<Integer> getRegionCounts() { try { if (!master.isInitialized()) { return new PairOfSameType<>(0, 0); } Integer onlineRegionCount = 0; Integer offlineRegionCount = 0; List<TableDescriptor> descriptors = master.listTableDescriptors(null, null, null, false); for (TableDescriptor htDesc : descriptors) { TableName tableName = htDesc.getTableName(); Map<RegionState.State, List<RegionInfo>> tableRegions = master.getAssignmentManager().getRegionStates() .getRegionByStateOfTable(tableName); onlineRegionCount += tableRegions.get(RegionState.State.OPEN).size(); offlineRegionCount += tableRegions.get(RegionState.State.OFFLINE).size(); } return new PairOfSameType<>(onlineRegionCount, offlineRegionCount); } catch (IOException e) { return new PairOfSameType<>(0, 0); } } }
Pair<Boolean, Boolean> a = checkDaughterInFs(parent, daughters.getFirst()); Pair<Boolean, Boolean> b = checkDaughterInFs(parent, daughters.getSecond()); if (hasNoReferences(a) && hasNoReferences(b)) { String daughterA = daughters.getFirst() != null? daughters.getFirst().getShortNameToLog(): "null"; String daughterB = daughters.getSecond() != null? daughters.getSecond().getShortNameToLog(): "null"; LOG.debug("Deleting region " + parent.getShortNameToLog() + " because daughters -- " + daughterA + ", " + daughterB +
private PairOfSameType<RegionInfo> requestMergeRegion( HMaster master, TableName tablename, int regionAnum, int regionBnum) throws Exception { List<Pair<RegionInfo, ServerName>> tableRegions = MetaTableAccessor .getTableRegionsAndLocations( TEST_UTIL.getConnection(), tablename); RegionInfo regionA = tableRegions.get(regionAnum).getFirst(); RegionInfo regionB = tableRegions.get(regionBnum).getFirst(); ADMIN.mergeRegionsAsync( regionA.getEncodedNameAsBytes(), regionB.getEncodedNameAsBytes(), false); return new PairOfSameType<>(regionA, regionB); }
/** * Returns the daughter regions by reading the corresponding columns of the catalog table * Result. * @param data a Result object from the catalog table scan * @return a pair of RegionInfo or PairOfSameType(null, null) if the region is not a split * parent */ public static PairOfSameType<RegionInfo> getDaughterRegions(Result data) { RegionInfo splitA = getRegionInfo(data, HConstants.SPLITA_QUALIFIER); RegionInfo splitB = getRegionInfo(data, HConstants.SPLITB_QUALIFIER); return new PairOfSameType<>(splitA, splitB); }
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; } } }
/** * Returns the merge regions by reading the corresponding columns of the catalog table * Result. * @param data a Result object from the catalog table scan * @return a pair of RegionInfo or PairOfSameType(null, null) if the region is not a split * parent */ public static PairOfSameType<RegionInfo> getMergeRegions(Result data) { RegionInfo mergeA = getRegionInfo(data, HConstants.MERGEA_QUALIFIER); RegionInfo mergeB = getRegionInfo(data, HConstants.MERGEB_QUALIFIER); return new PairOfSameType<>(mergeA, mergeB); }
currentRegions.add(p.getFirst()); assertTrue(initialRegions.contains(mergedRegions.getFirst())); //this is the first region assertTrue(initialRegions.contains(RegionReplicaUtil.getRegionInfoForReplica( mergedRegions.getFirst(), 1))); //this is the replica of the first region assertTrue(initialRegions.contains(mergedRegions.getSecond())); //this is the second region assertTrue(initialRegions.contains(RegionReplicaUtil.getRegionInfoForReplica( mergedRegions.getSecond(), 1))); //this is the replica of the second region assertTrue(!initialRegions.contains(currentRegions.get(0))); //this is the new region assertTrue(!initialRegions.contains(RegionReplicaUtil.getRegionInfoForReplica( currentRegions.get(0), 1))); //replica of the new region assertTrue(!currentRegions.contains(RegionReplicaUtil.getRegionInfoForReplica( mergedRegions.getFirst(), 1))); //replica of the merged region assertTrue(!currentRegions.contains(RegionReplicaUtil.getRegionInfoForReplica( mergedRegions.getSecond(), 1))); //replica of the merged region
/** * Returns the daughter regions by reading from the corresponding columns of the .META. table * Result. If the region is not a split parent region, it returns PairOfSameType(null, null). */ public static PairOfSameType<HRegionInfo> getDaughterRegions(Result data) throws IOException { HRegionInfo splitA = Writables.getHRegionInfoOrNull( data.getValue(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER)); HRegionInfo splitB = Writables.getHRegionInfoOrNull( data.getValue(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER)); return new PairOfSameType<HRegionInfo>(splitA, splitB); }