@Override public T next() { if (++this.returned == 1) return getFirst(); else if (this.returned == 2) return getSecond(); else throw new IllegalAccessError("this.returned=" + this.returned); }
@Override public String toString() { return "{" + getFirst() + "," + getSecond() + "}"; }
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> 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; } } }
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( mergedRegions.getFirst(), 1))); //replica of the merged region assertTrue(!currentRegions.contains(RegionReplicaUtil.getRegionInfoForReplica( mergedRegions.getSecond(), 1))); //replica of the merged region
private List<HRegionLocation> splitRegion(final RegionInfo r) throws IOException, InterruptedException { List<HRegionLocation> locations = new ArrayList<>(); // Split this table in two. Admin admin = TEST_UTIL.getAdmin(); Connection connection = TEST_UTIL.getConnection(); admin.splitRegion(r.getEncodedNameAsBytes()); admin.close(); PairOfSameType<RegionInfo> regions = waitOnDaughters(r); if (regions != null) { try (RegionLocator rl = connection.getRegionLocator(r.getTable())) { locations.add(rl.getRegionLocation(regions.getFirst().getEncodedNameAsBytes())); locations.add(rl.getRegionLocation(regions.getSecond().getEncodedNameAsBytes())); } return locations; } return locations; }
PairOfSameType<RegionInfo> pair = MetaTableAccessor.getDaughterRegions(result); daughterA = pair.getFirst(); daughterB = pair.getSecond(); break;
RegionInfo regionB = p.getSecond(); FileSystem fs = MASTER.getMasterFileSystem().getFileSystem(); Path rootDir = MASTER.getMasterFileSystem().getRootDir();
@Test public void testWholesomeMerge() throws Exception { LOG.info("Starting " + name.getMethodName()); final TableName tableName = TableName.valueOf(name.getMethodName()); // Create table and load data. Table table = createTableAndLoadData(MASTER, tableName); // Merge 1st and 2nd region mergeRegionsAndVerifyRegionNum(MASTER, tableName, 0, 1, INITIAL_REGION_NUM - 1); // Merge 2nd and 3th region PairOfSameType<RegionInfo> mergedRegions = mergeRegionsAndVerifyRegionNum(MASTER, tableName, 1, 2, INITIAL_REGION_NUM - 2); verifyRowCount(table, ROWSIZE); // Randomly choose one of the two merged regions RegionInfo hri = RandomUtils.nextBoolean() ? mergedRegions.getFirst() : mergedRegions.getSecond(); MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster(); AssignmentManager am = cluster.getMaster().getAssignmentManager(); RegionStates regionStates = am.getRegionStates(); // We should not be able to assign it again am.assign(hri); assertFalse("Merged region can't be assigned", regionStates.isRegionInTransition(hri)); // We should not be able to unassign it either am.unassign(hri); assertFalse("Merged region can't be unassigned", regionStates.isRegionInTransition(hri)); table.close(); }
regionNumberPair.getFirst()) .addGauge(Interns.info(OFFLINE_REGION_COUNT_NAME, OFFLINE_REGION_COUNT_DESC), regionNumberPair.getSecond()) .tag(Interns.info(LIVE_REGION_SERVERS_NAME, LIVE_REGION_SERVERS_DESC), masterWrapper.getRegionServers())
@Override public T next() { if (++this.returned == 1) return getFirst(); else if (this.returned == 2) return getSecond(); else throw new IllegalAccessError("this.returned=" + this.returned); }
@Override public T next() { if (++this.returned == 1) return getFirst(); else if (this.returned == 2) return getSecond(); else throw new IllegalAccessError("this.returned=" + this.returned); }
@Override public String toString() { return "{" + getFirst() + "," + getSecond() + "}"; }
@Override public T next() { if (++this.returned == 1) return getFirst(); else if (this.returned == 2) return getSecond(); else throw new IllegalAccessError("this.returned=" + this.returned); }
@Override public T next() { if (++this.returned == 1) return getFirst(); else if (this.returned == 2) return getSecond(); else throw new IllegalAccessError("this.returned=" + this.returned); }
@Override public String toString() { return "{" + getFirst() + "," + getSecond() + "}"; }
@Override public Void run() throws Exception { parent.getCoprocessorHost().postSplit(regions.getFirst(), regions.getSecond()); return null; } });