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
015b66103a
commit
78ff501ad8
|
@ -127,7 +127,7 @@ public class RegionMover extends AbstractHBaseTool {
|
||||||
* or hostname:port.
|
* or hostname:port.
|
||||||
*/
|
*/
|
||||||
public RegionMoverBuilder(String hostname) {
|
public RegionMoverBuilder(String hostname) {
|
||||||
String[] splitHostname = hostname.split(":");
|
String[] splitHostname = hostname.toLowerCase().split(":");
|
||||||
this.hostname = splitHostname[0];
|
this.hostname = splitHostname[0];
|
||||||
if (splitHostname.length == 2) {
|
if (splitHostname.length == 2) {
|
||||||
this.port = Integer.parseInt(splitHostname[1]);
|
this.port = Integer.parseInt(splitHostname[1]);
|
||||||
|
@ -409,7 +409,8 @@ public class RegionMover extends AbstractHBaseTool {
|
||||||
counter++;
|
counter++;
|
||||||
continue;
|
continue;
|
||||||
} else if (server.equals(currentServer)) {
|
} 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++;
|
counter++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -805,7 +806,7 @@ public class RegionMover extends AbstractHBaseTool {
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
server = i.next();
|
server = i.next();
|
||||||
String[] splitServer = server.split(ServerName.SERVERNAME_SEPARATOR);
|
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();
|
i.remove();
|
||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
@ -828,7 +829,7 @@ public class RegionMover extends AbstractHBaseTool {
|
||||||
admin.getClusterStatus(EnumSet.of(Option.LIVE_SERVERS)).getServers());
|
admin.getClusterStatus(EnumSet.of(Option.LIVE_SERVERS)).getServers());
|
||||||
ArrayList<String> regionServers = new ArrayList<>(serverInfo.size());
|
ArrayList<String> regionServers = new ArrayList<>(serverInfo.size());
|
||||||
for (ServerName server : serverInfo) {
|
for (ServerName server : serverInfo) {
|
||||||
regionServers.add(server.getServerName());
|
regionServers.add(server.getServerName().toLowerCase());
|
||||||
}
|
}
|
||||||
return regionServers;
|
return regionServers;
|
||||||
}
|
}
|
||||||
|
@ -905,7 +906,7 @@ public class RegionMover extends AbstractHBaseTool {
|
||||||
int maxWaitInSeconds =
|
int maxWaitInSeconds =
|
||||||
admin.getConfiguration().getInt(MOVE_WAIT_MAX_KEY, DEFAULT_MOVE_WAIT_MAX);
|
admin.getConfiguration().getInt(MOVE_WAIT_MAX_KEY, DEFAULT_MOVE_WAIT_MAX);
|
||||||
try {
|
try {
|
||||||
server = locator.waitMetaRegionLocation(zkw, maxWaitInSeconds * 1000).toString() + ",";
|
server = locator.waitMetaRegionLocation(zkw, maxWaitInSeconds * 1000).toString();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
LOG.error("Interrupted while waiting for location of Meta", e);
|
LOG.error("Interrupted while waiting for location of Meta", e);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -926,8 +927,8 @@ public class RegionMover extends AbstractHBaseTool {
|
||||||
byte[] startcode =
|
byte[] startcode =
|
||||||
result.getValue(HConstants.CATALOG_FAMILY, HConstants.STARTCODE_QUALIFIER);
|
result.getValue(HConstants.CATALOG_FAMILY, HConstants.STARTCODE_QUALIFIER);
|
||||||
if (servername != null) {
|
if (servername != null) {
|
||||||
server =
|
server = Bytes.toString(servername).replaceFirst(":", ",").toLowerCase() + "," +
|
||||||
Bytes.toString(servername).replaceFirst(":", ",") + "," + Bytes.toLong(startcode);
|
Bytes.toLong(startcode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -107,7 +107,6 @@ public class TestRegionMover {
|
||||||
|
|
||||||
/** Test to unload a regionserver first and then load it using no Ack mode
|
/** 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)
|
* we check if some regions are loaded on the region server(since no ack is best effort)
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testLoadWithoutAck() throws Exception {
|
public void testLoadWithoutAck() throws Exception {
|
||||||
|
@ -171,10 +170,31 @@ public class TestRegionMover {
|
||||||
assertEquals(0, regionServer.getNumberOfOnlineRegions());
|
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
|
* 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
|
* of regions on Excluded server and also test that regions are unloaded successfully
|
||||||
* @throws Exception
|
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testExclude() throws Exception {
|
public void testExclude() throws Exception {
|
||||||
|
|
Loading…
Reference in New Issue