RegionPlan plan = new RegionPlan(region, masterServerName, dest); if (plans == null) { plans = new ArrayList<>(); RegionPlan plan = new RegionPlan(region, server.getKey(), masterServerName); if (plans == null) { plans = new ArrayList<>();
/** * Create all of the RegionPlan's needed to move from the initial cluster state to the desired * state. * * @param cluster The state of the cluster * @return List of RegionPlan's that represent the moves needed to get to desired final state. */ private List<RegionPlan> createRegionPlans(Cluster cluster) { List<RegionPlan> plans = new LinkedList<>(); for (int regionIndex = 0; regionIndex < cluster.regionIndexToServerIndex.length; regionIndex++) { int initialServerIndex = cluster.initialRegionIndexToServerIndex[regionIndex]; int newServerIndex = cluster.regionIndexToServerIndex[regionIndex]; if (initialServerIndex != newServerIndex) { RegionInfo region = cluster.regions[regionIndex]; ServerName initialServer = cluster.servers[initialServerIndex]; ServerName newServer = cluster.servers[newServerIndex]; if (LOG.isTraceEnabled()) { LOG.trace("Moving Region " + region.getEncodedName() + " from server " + initialServer.getHostname() + " to " + newServer.getHostname()); } RegionPlan rp = new RegionPlan(region, initialServer, newServer); plans.add(rp); } } return plans; }
regionPlansForMisplacedRegions.add(new RegionPlan(region, currentHostServer, null)); } else { // region is placed as expected correctAssignments.get(currentHostServer).add(region);
continue; RegionPlan rp = new RegionPlan(hri, null, null); regionPlans.add(rp); misplacedRegions++;
@Test public void testEqualsWithNulls() { RegionInfo hri = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName())).build(); RegionPlan a = new RegionPlan(hri, null, null); RegionPlan b = new RegionPlan(hri, null, null); assertTrue(a.equals(b)); a = new RegionPlan(hri, SRC, null); b = new RegionPlan(hri, null, null); assertFalse(a.equals(b)); a = new RegionPlan(hri, SRC, null); b = new RegionPlan(hri, SRC, null); assertTrue(a.equals(b)); a = new RegionPlan(hri, SRC, null); b = new RegionPlan(hri, SRC, DEST); assertFalse(a.equals(b)); }
for (RegionInfo regionInfo : regionsShouldMove) { RegionPlan plan = new RegionPlan(regionInfo, server, null); if (regionInfo.isMetaRegion()) {
@Test public void testCompareTo() { RegionInfo hri = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName())).build(); RegionPlan a = new RegionPlan(hri, null, null); RegionPlan b = new RegionPlan(hri, null, null); assertEquals(0, a.compareTo(b)); a = new RegionPlan(hri, SRC, null); b = new RegionPlan(hri, null, null); assertEquals(1, a.compareTo(b)); a = new RegionPlan(hri, null, null); b = new RegionPlan(hri, SRC, null); assertEquals(-1, a.compareTo(b)); a = new RegionPlan(hri, SRC, null); b = new RegionPlan(hri, SRC, null); assertEquals(0, a.compareTo(b)); a = new RegionPlan(hri, SRC, null); b = new RegionPlan(hri, SRC, DEST); assertEquals(-1, a.compareTo(b)); a = new RegionPlan(hri, SRC, DEST); b = new RegionPlan(hri, SRC, DEST); assertEquals(0, a.compareTo(b)); }
RegionPlan plan = new RegionPlan(region, currentServer, destination); plans.add(plan);
regionsToMove.add(new RegionPlan(hri, sal.getServerName(), null)); numTaken++; if (numTaken >= numToOffload) break; RegionInfo region = server.getValue().get(idx); if (region.isMetaRegion()) continue; // Don't move meta regions. regionsToMove.add(new RegionPlan(region, server.getKey().getServerName(), null)); balanceInfo.setNumRegionsAdded(balanceInfo.getNumRegionsAdded() - 1); balanceInfo.setNextRegionForUnload(balanceInfo.getNextRegionForUnload() + 1);
hriToPlan = balanceInfo.getHriList().get(balanceInfo.getNextRegionForUnload()); RegionPlan maxPlan = new RegionPlan(hriToPlan, serverload.getServerName(), null); regionsToMove.add(maxPlan); setLoad(serverLoadList, i, -1);
@Test public void testEquals() { RegionInfo hri = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName())).build(); // Identity equality RegionPlan plan = new RegionPlan(hri, SRC, DEST); assertEquals(plan.hashCode(), new RegionPlan(hri, SRC, DEST).hashCode()); assertEquals(plan, new RegionPlan(hri, SRC, DEST)); // HRI is used for equality RegionInfo other = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName() + "other")).build(); assertNotEquals(plan.hashCode(), new RegionPlan(other, SRC, DEST).hashCode()); assertNotEquals(plan, new RegionPlan(other, SRC, DEST)); } }
@Override protected void deserializeStateData(ProcedureStateSerializer serializer) throws IOException { super.deserializeStateData(serializer); final MoveRegionStateData state = serializer.deserialize(MoveRegionStateData.class); final RegionInfo regionInfo = getRegion(); // Get it from super class deserialization. final ServerName sourceServer = ProtobufUtil.toServerName(state.getSourceServer()); final ServerName destinationServer = state.hasDestinationServer() ? ProtobufUtil.toServerName(state.getDestinationServer()) : null; this.plan = new RegionPlan(regionInfo, sourceServer, destinationServer); } }
RegionPlan rp = new RegionPlan(hri, regionState.getServerName(), dest); assert rp.getDestination() != null: rp.toString() + " " + dest;
throw new HBaseIOException("Unable to determine a plan to move " + hri); RegionPlan rp = new RegionPlan(hri, server, dest); this.assignmentManager.moveAsync(rp);
continue; RegionPlan rp = new RegionPlan(hri, regionState.getServerName(), server); this.assignmentManager.moveAsync(rp);
RESUME_AND_FAIL.set(latch); Future<byte[]> future = am.moveAsync(new RegionPlan(region, rsn.getRegionLocation(), rsn.getRegionLocation())); TransitRegionStateProcedure proc = procExec.getProcedures().stream().filter(p -> p instanceof TransitRegionStateProcedure)
ARRIVE_REPORT = new CountDownLatch(1); Future<?> future = am.moveAsync(new RegionPlan(region, rs0.getServerName(), rs1.getServerName())); ARRIVE_REPORT.await();
am.moveAsync(new RegionPlan(region, rsn.getRegionLocation(), rsn.getRegionLocation())); TransitRegionStateProcedure proc = procExec.getProcedures().stream().filter(p -> p instanceof TransitRegionStateProcedure)
ARRIVE = new CountDownLatch(1); HALT = true; am.moveAsync(new RegionPlan(region, sn, sn)); ARRIVE.await();
@Override public void process() throws IOException { ReentrantLock lock = locker.acquireLock(regionInfo.getEncodedName()); try { RegionPlan plan = new RegionPlan(regionInfo, null, sn); addPlan(encodedName, plan); assign(rsOffline, false, false); } finally { lock.unlock(); } } });