@InterfaceAudience.Public public class RegionMover extends AbstractHBaseTool implements Closeable
load()
or unload()
methods for the desired operations.Modifier and Type | Class and Description |
---|---|
private class |
RegionMover.MoveWithAck
Move Regions and make sure that they are up on the target server.If a region movement fails we
exit as failure
|
private class |
RegionMover.MoveWithoutAck
Move Regions without Acknowledging.Usefule in case of RS shutdown as we might want to shut the
RS down anyways and not abort on a stuck region.
|
static class |
RegionMover.RegionMoverBuilder
Builder for Region mover.
|
Modifier and Type | Field and Description |
---|---|
private boolean |
ack |
private Admin |
admin |
private Connection |
conn |
static int |
DEFAULT_MOVE_RETRIES_MAX |
static int |
DEFAULT_MOVE_WAIT_MAX |
static int |
DEFAULT_SERVERSTART_WAIT_MAX |
private String |
excludeFile |
private String |
filename |
private String |
hostname |
private String |
loadUnload |
(package private) static org.slf4j.Logger |
LOG |
private int |
maxthreads |
static String |
MOVE_RETRIES_MAX_KEY |
static String |
MOVE_WAIT_MAX_KEY |
private int |
port |
private RegionMover.RegionMoverBuilder |
rmbuilder |
static String |
SERVERSTART_WAIT_MAX_KEY |
private int |
timeout |
cmdLineArgs, conf, EXIT_FAILURE, EXIT_SUCCESS, LONG_HELP_OPTION, options, SHORT_HELP_OPTION
Modifier | Constructor and Description |
---|---|
private |
RegionMover() |
private |
RegionMover(RegionMover.RegionMoverBuilder builder) |
Modifier and Type | Method and Description |
---|---|
protected void |
addOptions()
Override this to add command-line options using
AbstractHBaseTool.addOptWithArg(java.lang.String, java.lang.String)
and similar methods. |
void |
close() |
private void |
deleteFile(String filename) |
protected int |
doWork()
The "main function" of the tool
|
private ServerName |
getServerNameForRegion(RegionInfo region)
Get servername that is up in hbase:meta hosting the given region.
|
private ServerName |
getTargetServer() |
private boolean |
isSameServer(RegionInfo region,
ServerName serverName)
Returns true if passed region is still on serverName when we look at hbase:meta.
|
private void |
isSuccessfulScan(RegionInfo region)
Tries to scan a row from passed region
|
boolean |
load()
Loads the specified
hostname with regions listed in the filename RegionMover
Object has to be created using RegionMover(RegionMoverBuilder) |
private void |
loadRegions(List<RegionInfo> regionsToMove) |
static void |
main(String[] args) |
protected void |
processOptions(org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine cmd)
This method is called to process the options after they have been parsed.
|
private List<String> |
readExcludes(String excludeFile) |
private List<RegionInfo> |
readRegionsFromFile(String filename) |
private void |
stripExcludes(List<ServerName> regionServers)
Excludes the servername whose hostname and port portion matches the list given in exclude file
|
private void |
stripMaster(List<ServerName> regionServers)
Exclude master from list of RSs to move regions to
|
private ServerName |
stripServer(List<ServerName> regionServers,
String hostname,
int port)
Remove the servername whose hostname and port portion matches from the passed array of servers.
|
boolean |
unload()
Unload regions from given
hostname using ack/noAck mode and maxthreads .In
noAck mode we do not make sure that region is successfully online on the target region
server,hence it is best effort.We do not unload regions to hostnames given in
excludeFile . |
private void |
unloadRegions(ServerName server,
List<ServerName> regionServers,
List<RegionInfo> movedRegions) |
private void |
waitMoveTasksToFinish(ExecutorService moveRegionsPool,
List<Future<Boolean>> taskList,
long timeoutInSeconds) |
private boolean |
waitTaskToFinish(ExecutorService pool,
Future<Boolean> task,
String operation) |
private void |
writeFile(String filename,
List<RegionInfo> movedRegions)
Write the number of regions moved in the first line followed by regions moved in subsequent
lines
|
addOption, addOptNoArg, addOptNoArg, addOptWithArg, addOptWithArg, addRequiredOption, addRequiredOptWithArg, addRequiredOptWithArg, doStaticMain, getConf, getOptionAsDouble, getOptionAsInt, getOptionAsLong, newParser, parseArgs, parseInt, parseLong, printUsage, printUsage, processOldArgs, run, setConf
public static final String MOVE_RETRIES_MAX_KEY
public static final String MOVE_WAIT_MAX_KEY
public static final String SERVERSTART_WAIT_MAX_KEY
public static final int DEFAULT_MOVE_RETRIES_MAX
public static final int DEFAULT_MOVE_WAIT_MAX
public static final int DEFAULT_SERVERSTART_WAIT_MAX
static final org.slf4j.Logger LOG
private RegionMover.RegionMoverBuilder rmbuilder
private boolean ack
private int maxthreads
private int timeout
private String loadUnload
private String excludeFile
private int port
private Connection conn
private RegionMover(RegionMover.RegionMoverBuilder builder) throws IOException
IOException
private RegionMover()
public void close()
close
in interface Closeable
close
in interface AutoCloseable
public boolean load() throws ExecutionException, InterruptedException, TimeoutException
hostname
with regions listed in the filename
RegionMover
Object has to be created using RegionMover(RegionMoverBuilder)
ExecutionException
InterruptedException
TimeoutException
private void loadRegions(List<RegionInfo> regionsToMove) throws Exception
Exception
public boolean unload() throws InterruptedException, ExecutionException, TimeoutException
hostname
using ack/noAck mode and maxthreads
.In
noAck mode we do not make sure that region is successfully online on the target region
server,hence it is best effort.We do not unload regions to hostnames given in
excludeFile
.InterruptedException
ExecutionException
TimeoutException
private void unloadRegions(ServerName server, List<ServerName> regionServers, List<RegionInfo> movedRegions) throws Exception
Exception
private boolean waitTaskToFinish(ExecutorService pool, Future<Boolean> task, String operation) throws TimeoutException, InterruptedException, ExecutionException
private void waitMoveTasksToFinish(ExecutorService moveRegionsPool, List<Future<Boolean>> taskList, long timeoutInSeconds) throws Exception
Exception
private ServerName getTargetServer() throws Exception
Exception
private List<RegionInfo> readRegionsFromFile(String filename) throws IOException
IOException
private void writeFile(String filename, List<RegionInfo> movedRegions) throws IOException
IOException
private void deleteFile(String filename)
private List<String> readExcludes(String excludeFile) throws IOException
IOException
private void stripExcludes(List<ServerName> regionServers) throws IOException
IOException
private void stripMaster(List<ServerName> regionServers) throws IOException
IOException
private ServerName stripServer(List<ServerName> regionServers, String hostname, int port)
private void isSuccessfulScan(RegionInfo region) throws IOException
IOException
private boolean isSameServer(RegionInfo region, ServerName serverName) throws IOException
IOException
private ServerName getServerNameForRegion(RegionInfo region) throws IOException
IOException
protected void addOptions()
AbstractHBaseTool
AbstractHBaseTool.addOptWithArg(java.lang.String, java.lang.String)
and similar methods.addOptions
in class AbstractHBaseTool
protected void processOptions(org.apache.hbase.thirdparty.org.apache.commons.cli.CommandLine cmd)
AbstractHBaseTool
processOptions
in class AbstractHBaseTool
protected int doWork() throws Exception
AbstractHBaseTool
doWork
in class AbstractHBaseTool
Exception
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.