HBASE-5809 Avoid move api to take the destination server same as the source server. (Rajesh)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1328458 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e05c21c0cb
commit
14f80913e5
|
@ -1174,6 +1174,11 @@ Server {
|
||||||
this.assignmentManager.unassign(hri);
|
this.assignmentManager.unassign(hri);
|
||||||
} else {
|
} else {
|
||||||
dest = new ServerName(Bytes.toString(destServerName));
|
dest = new ServerName(Bytes.toString(destServerName));
|
||||||
|
if (dest.equals(p.getSecond())) {
|
||||||
|
LOG.debug("Skipping move of region " + hri.getRegionNameAsString()
|
||||||
|
+ " because region already assigned to the same server " + dest +".");
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if (this.cpHost != null) {
|
if (this.cpHost != null) {
|
||||||
if (this.cpHost.preMove(p.getFirst(), p.getSecond(), dest)) {
|
if (this.cpHost.preMove(p.getFirst(), p.getSecond(), dest)) {
|
||||||
|
|
|
@ -43,6 +43,8 @@ import org.apache.hadoop.hbase.*;
|
||||||
import org.apache.hadoop.hbase.executor.EventHandler;
|
import org.apache.hadoop.hbase.executor.EventHandler;
|
||||||
import org.apache.hadoop.hbase.executor.EventHandler.EventType;
|
import org.apache.hadoop.hbase.executor.EventHandler.EventType;
|
||||||
import org.apache.hadoop.hbase.executor.ExecutorService;
|
import org.apache.hadoop.hbase.executor.ExecutorService;
|
||||||
|
import org.apache.hadoop.hbase.master.AssignmentManager;
|
||||||
|
import org.apache.hadoop.hbase.master.HMaster;
|
||||||
import org.apache.hadoop.hbase.master.MasterServices;
|
import org.apache.hadoop.hbase.master.MasterServices;
|
||||||
import org.apache.hadoop.hbase.regionserver.HRegion;
|
import org.apache.hadoop.hbase.regionserver.HRegion;
|
||||||
import org.apache.hadoop.hbase.regionserver.HRegionServer;
|
import org.apache.hadoop.hbase.regionserver.HRegionServer;
|
||||||
|
@ -1404,6 +1406,22 @@ public class TestAdmin {
|
||||||
assertTrue(("actual count: " + count), count <= 2);
|
assertTrue(("actual count: " + count), count <= 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMoveToPreviouslyAssignedRS() throws IOException {
|
||||||
|
byte[] tableName = Bytes.toBytes("testMoveToPreviouslyAssignedRS");
|
||||||
|
MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
|
||||||
|
HMaster master = cluster.getMaster();
|
||||||
|
HBaseAdmin localAdmin = createTable(tableName);
|
||||||
|
List<HRegionInfo> tableRegions = localAdmin.getTableRegions(tableName);
|
||||||
|
HRegionInfo hri = tableRegions.get(0);
|
||||||
|
AssignmentManager am = master.getAssignmentManager();
|
||||||
|
ServerName server = am.getRegionServerOfRegion(hri);
|
||||||
|
localAdmin.move(hri.getEncodedNameAsBytes(), Bytes.toBytes(server.getServerName()));
|
||||||
|
assertEquals("Current region server and region server before move should be same.", server,
|
||||||
|
am.getRegionServerOfRegion(hri));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setUpforLogRolling() {
|
private void setUpforLogRolling() {
|
||||||
// Force a region split after every 768KB
|
// Force a region split after every 768KB
|
||||||
TEST_UTIL.getConfiguration().setLong(HConstants.HREGION_MAX_FILESIZE,
|
TEST_UTIL.getConfiguration().setLong(HConstants.HREGION_MAX_FILESIZE,
|
||||||
|
|
Loading…
Reference in New Issue