HBASE-19456 RegionMover's region server hostname option is no longer case insensitive
Signed-off-by: Josh Elser <elserj@apache.org>
This commit is contained in:
parent
86043ef629
commit
d0c2329aa8
|
@ -127,7 +127,7 @@ public class RegionMover extends AbstractHBaseTool {
|
|||
* or hostname:port.
|
||||
*/
|
||||
public RegionMoverBuilder(String hostname) {
|
||||
String[] splitHostname = hostname.split(":");
|
||||
String[] splitHostname = hostname.toLowerCase().split(":");
|
||||
this.hostname = splitHostname[0];
|
||||
if (splitHostname.length == 2) {
|
||||
this.port = Integer.parseInt(splitHostname[1]);
|
||||
|
@ -409,7 +409,8 @@ public class RegionMover extends AbstractHBaseTool {
|
|||
counter++;
|
||||
continue;
|
||||
} else if (server.equals(currentServer)) {
|
||||
LOG.info("Region " + region.getRegionNameAsString() + "already on target server=" + server);
|
||||
LOG.info("Region " + region.getRegionNameAsString() +
|
||||
" is already on target server=" + server);
|
||||
counter++;
|
||||
continue;
|
||||
}
|
||||
|
@ -805,7 +806,7 @@ public class RegionMover extends AbstractHBaseTool {
|
|||
while (i.hasNext()) {
|
||||
server = i.next();
|
||||
String[] splitServer = server.split(ServerName.SERVERNAME_SEPARATOR);
|
||||
if (splitServer[0].equals(hostname) && splitServer[1].equals(portString)) {
|
||||
if (splitServer[0].equalsIgnoreCase(hostname) && splitServer[1].equals(portString)) {
|
||||
i.remove();
|
||||
return server;
|
||||
}
|
||||
|
@ -828,7 +829,7 @@ public class RegionMover extends AbstractHBaseTool {
|
|||
admin.getClusterStatus(EnumSet.of(Option.LIVE_SERVERS)).getServers());
|
||||
ArrayList<String> regionServers = new ArrayList<>(serverInfo.size());
|
||||
for (ServerName server : serverInfo) {
|
||||
regionServers.add(server.getServerName());
|
||||
regionServers.add(server.getServerName().toLowerCase());
|
||||
}
|
||||
return regionServers;
|
||||
}
|
||||
|
@ -905,7 +906,7 @@ public class RegionMover extends AbstractHBaseTool {
|
|||
int maxWaitInSeconds =
|
||||
admin.getConfiguration().getInt(MOVE_WAIT_MAX_KEY, DEFAULT_MOVE_WAIT_MAX);
|
||||
try {
|
||||
server = locator.waitMetaRegionLocation(zkw, maxWaitInSeconds * 1000).toString() + ",";
|
||||
server = locator.waitMetaRegionLocation(zkw, maxWaitInSeconds * 1000).toString();
|
||||
} catch (InterruptedException e) {
|
||||
LOG.error("Interrupted while waiting for location of Meta", e);
|
||||
} finally {
|
||||
|
@ -926,8 +927,8 @@ public class RegionMover extends AbstractHBaseTool {
|
|||
byte[] startcode =
|
||||
result.getValue(HConstants.CATALOG_FAMILY, HConstants.STARTCODE_QUALIFIER);
|
||||
if (servername != null) {
|
||||
server =
|
||||
Bytes.toString(servername).replaceFirst(":", ",") + "," + Bytes.toLong(startcode);
|
||||
server = Bytes.toString(servername).replaceFirst(":", ",").toLowerCase() + "," +
|
||||
Bytes.toLong(startcode);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -107,7 +107,6 @@ public class TestRegionMover {
|
|||
|
||||
/** Test to unload a regionserver first and then load it using no Ack mode
|
||||
* we check if some regions are loaded on the region server(since no ack is best effort)
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testLoadWithoutAck() throws Exception {
|
||||
|
@ -171,10 +170,31 @@ public class TestRegionMover {
|
|||
assertEquals(0, regionServer.getNumberOfOnlineRegions());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that loading the same region set doesn't cause timeout loop during meta load.
|
||||
*/
|
||||
@Test(timeout = 30000)
|
||||
public void testRepeatedLoad() throws Exception {
|
||||
MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
|
||||
HRegionServer regionServer = cluster.getRegionServer(0);
|
||||
String rsName = regionServer.getServerName().getHostname();
|
||||
int port = regionServer.getServerName().getPort();
|
||||
String rs = rsName + ":" + Integer.toString(port);
|
||||
RegionMoverBuilder rmBuilder = new RegionMoverBuilder(rs).ack(true);
|
||||
RegionMover rm = rmBuilder.build();
|
||||
rm.setConf(TEST_UTIL.getConfiguration());
|
||||
rm.unload();
|
||||
assertEquals(0, regionServer.getNumberOfOnlineRegions());
|
||||
rmBuilder = new RegionMoverBuilder(rs).ack(true);
|
||||
rm = rmBuilder.build();
|
||||
rm.setConf(TEST_UTIL.getConfiguration());
|
||||
rm.load();
|
||||
rm.load(); //Repeat the same load. It should be very fast because all regions are already moved.
|
||||
}
|
||||
|
||||
/**
|
||||
* To test that we successfully exclude a server from the unloading process We test for the number
|
||||
* of regions on Excluded server and also test that regions are unloaded successfully
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testExclude() throws Exception {
|
||||
|
|
Loading…
Reference in New Issue