Package org.apache.hadoop.hbase.util
Class RegionMover
java.lang.Object
org.apache.hadoop.hbase.util.AbstractHBaseTool
org.apache.hadoop.hbase.util.RegionMover
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.hadoop.conf.Configurable,org.apache.hadoop.util.Tool
Tool for loading/unloading regions to/from given regionserver This tool can be run from Command
line directly as a utility. Supports Ack/No Ack mode for loading/unloading operations.Ack mode
acknowledges if regions are online after movement while noAck mode is best effort mode that
improves performance but will still move on if region is stuck/not moved. Motivation behind noAck
mode being RS shutdown where even if a Region is stuck, upon shutdown master will move it
anyways. This can also be used by constructiong an Object using the builder and then calling
load() or unload() methods for the desired operations.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for Region mover.Nested classes/interfaces inherited from class org.apache.hadoop.hbase.util.AbstractHBaseTool
AbstractHBaseTool.OptionsOrderComparator -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate Adminprivate Connectionstatic final intstatic final intstatic final intprivate Stringprivate Stringprivate Stringprivate Stringprivate Stringprivate static final org.slf4j.Loggerprivate intstatic final Stringstatic final Stringprivate intprivate RackManagerprivate RegionMover.RegionMoverBuilderstatic final Stringprivate intFields inherited from class org.apache.hadoop.hbase.util.AbstractHBaseTool
cmdLineArgs, conf, EXIT_FAILURE, EXIT_SUCCESS, LONG_HELP_OPTION, options, SHORT_HELP_OPTION -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateprivate -
Method Summary
Modifier and TypeMethodDescriptionprotected voidOverride this to add command-line options usingAbstractHBaseTool.addOptWithArg(java.lang.String, java.lang.String)and similar methods.voidclose()private voiddeleteFile(String filename) protected intdoWork()The "main function" of the tool(package private) Collection<ServerName>filterRSGroupServers(RSGroupInfo rsgroup, Collection<ServerName> onlineServers) private Optional<RegionInfo>getMetaRegionInfoIfToBeMoved(List<RegionInfo> regionsToMove) getRegionsMovePlan(boolean moveMetaRegion) private ServerNameprivate booleanprivate voidincludeExcludeRegionServers(String fileName, List<ServerName> regionServers, boolean isInclude) Designates or excludes the servername whose hostname and port portion matches the list given in the file.booleanIsolated regions specified inisolateRegionIdArrayonhostnamein ack Mode and Unload regions from givenhostnameusing ack/noAck mode andmaxthreads.booleanload()Loads the specifiedhostnamewith regions listed in thefilenameRegionMover Object has to be created usingRegionMover(RegionMoverBuilder)private voidloadRegions(List<RegionInfo> regionsToMove) static voidprotected voidprocessOptions(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<RegionInfo>readRegionsFromFile(String filename) readServersFromFile(String filename) private voidstripMaster(List<ServerName> regionServers) Exclude master from list of RSs to move regions toprivate ServerNamestripServer(List<ServerName> regionServers, String hostname, int port) Remove the servername whose hostname and port portion matches from the passed array of servers.private voidsubmitRegionMovesWhileUnloading(ServerName server, List<ServerName> regionServers, List<RegionInfo> movedRegions, List<RegionInfo> regionsToMove, boolean forceMoveRegionByAck) booleanunload()Unload regions from givenhostnameusing ack/noAck mode andmaxthreads.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 inexcludeFile.booleanUnload regions from givenhostnameusing ack/noAck mode andmaxthreads.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 inexcludeFile.private booleanunloadRegions(boolean unloadFromRack) private booleanunloadRegions(boolean unloadFromRack, List<String> isolateRegionIdArray) private voidunloadRegions(ServerName server, List<ServerName> regionServers, List<RegionInfo> movedRegions, List<String> isolateRegionIdArray) private voidwaitMoveTasksToFinish(ExecutorService moveRegionsPool, List<Future<Boolean>> taskList, long timeoutInSeconds) private booleanwaitTaskToFinish(ExecutorService pool, Future<Boolean> task, String operation) private voidwriteFile(String filename, List<RegionInfo> movedRegions) Write the number of regions moved in the first line followed by regions moved in subsequent linesMethods inherited from class org.apache.hadoop.hbase.util.AbstractHBaseTool
addOption, addOptNoArg, addOptNoArg, addOptWithArg, addOptWithArg, addRequiredOption, addRequiredOptWithArg, addRequiredOptWithArg, doStaticMain, getConf, getOptionAsDouble, getOptionAsInt, getOptionAsInt, getOptionAsLong, getOptionAsLong, newParser, parseArgs, parseInt, parseLong, printUsage, printUsage, processOldArgs, run, setConf
-
Field Details
-
MOVE_RETRIES_MAX_KEY
- See Also:
-
MOVE_WAIT_MAX_KEY
- See Also:
-
SERVERSTART_WAIT_MAX_KEY
- See Also:
-
DEFAULT_MOVE_RETRIES_MAX
- See Also:
-
DEFAULT_MOVE_WAIT_MAX
- See Also:
-
DEFAULT_SERVERSTART_WAIT_MAX
- See Also:
-
LOG
-
rmbuilder
-
ack
-
maxthreads
-
timeout
-
isolateRegionIdArray
-
loadUnload
-
hostname
-
filename
-
excludeFile
-
designatedFile
-
port
-
conn
-
admin
-
rackManager
-
-
Constructor Details
-
RegionMover
- Throws:
IOException
-
RegionMover
private RegionMover()
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
load
Loads the specifiedhostnamewith regions listed in thefilenameRegionMover Object has to be created usingRegionMover(RegionMoverBuilder)- Returns:
- true if loading succeeded, false otherwise
- Throws:
ExecutionExceptionInterruptedExceptionTimeoutException
-
getMetaRegionMovePlan
-
getNonMetaRegionsMovePlan
-
getRegionsMovePlan
-
getMetaRegionInfoIfToBeMoved
-
loadRegions
- Throws:
Exception
-
unload
Unload regions from givenhostnameusing ack/noAck mode andmaxthreads.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 inexcludeFile. If designatedFile is present with some contents, we will unload regions to hostnames provided indesignatedFile- Returns:
- true if unloading succeeded, false otherwise
- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
unloadFromRack
Unload regions from givenhostnameusing ack/noAck mode andmaxthreads.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 inexcludeFile. If designatedFile is present with some contents, we will unload regions to hostnames provided indesignatedFile. While unloading regions, destination RegionServers are selected from different rack i.e regions should not move to any RegionServers that belong to same rack as source RegionServer.- Returns:
- true if unloading succeeded, false otherwise
- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-
unloadRegions
private boolean unloadRegions(boolean unloadFromRack) throws ExecutionException, InterruptedException, TimeoutException -
isolateRegions
Isolated regions specified inisolateRegionIdArrayonhostnamein ack Mode and Unload regions from givenhostnameusing ack/noAck mode andmaxthreads. In noAck mode we do not make sure that region is successfully online on the target region server,hence it is the best effort. We do not unload regions to hostnames given inexcludeFile. If designatedFile is present with some contents, we will unload regions to hostnames provided indesignatedFile- Returns:
- true if region isolation succeeded, false otherwise
- Throws:
ExecutionExceptionInterruptedExceptionTimeoutException
-
unloadRegions
private boolean unloadRegions(boolean unloadFromRack, List<String> isolateRegionIdArray) throws InterruptedException, ExecutionException, TimeoutException -
filterRSGroupServers
@Private Collection<ServerName> filterRSGroupServers(RSGroupInfo rsgroup, Collection<ServerName> onlineServers) -
unloadRegions
private void unloadRegions(ServerName server, List<ServerName> regionServers, List<RegionInfo> movedRegions, List<String> isolateRegionIdArray) throws Exception - Throws:
Exception
-
submitRegionMovesWhileUnloading
private void submitRegionMovesWhileUnloading(ServerName server, List<ServerName> regionServers, List<RegionInfo> movedRegions, List<RegionInfo> regionsToMove, boolean forceMoveRegionByAck) throws Exception - Throws:
Exception
-
waitTaskToFinish
private boolean waitTaskToFinish(ExecutorService pool, Future<Boolean> task, String operation) throws TimeoutException, InterruptedException, ExecutionException -
waitMoveTasksToFinish
private void waitMoveTasksToFinish(ExecutorService moveRegionsPool, List<Future<Boolean>> taskList, long timeoutInSeconds) throws Exception - Throws:
Exception
-
ignoreRegionMoveFailure
-
getTargetServer
- Throws:
Exception
-
readRegionsFromFile
- Throws:
IOException
-
writeFile
Write the number of regions moved in the first line followed by regions moved in subsequent lines- Throws:
IOException
-
deleteFile
-
readServersFromFile
- Parameters:
filename- The file should have 'host:port' per line- Returns:
- List of servers from the file in format 'hostname:port'.
- Throws:
IOException
-
includeExcludeRegionServers
private void includeExcludeRegionServers(String fileName, List<ServerName> regionServers, boolean isInclude) throws IOException Designates or excludes the servername whose hostname and port portion matches the list given in the file. Example:
If you want to designated RSs, suppose designatedFile has RS1, regionServers has RS1, RS2 and RS3. When we call includeExcludeRegionServers(designatedFile, regionServers, true), RS2 and RS3 are removed from regionServers list so that regions can move to only RS1. If you want to exclude RSs, suppose excludeFile has RS1, regionServers has RS1, RS2 and RS3. When we call includeExcludeRegionServers(excludeFile, servers, false), RS1 is removed from regionServers list so that regions can move to only RS2 and RS3.- Throws:
IOException
-
stripMaster
Exclude master from list of RSs to move regions to- Throws:
IOException
-
stripServer
Remove the servername whose hostname and port portion matches from the passed array of servers. Returns as side-effect the servername removed.- Returns:
- server removed from list of Region Servers
-
addOptions
Description copied from class:AbstractHBaseToolOverride this to add command-line options usingAbstractHBaseTool.addOptWithArg(java.lang.String, java.lang.String)and similar methods.- Specified by:
addOptionsin classAbstractHBaseTool
-
processOptions
Description copied from class:AbstractHBaseToolThis method is called to process the options after they have been parsed.- Specified by:
processOptionsin classAbstractHBaseTool
-
doWork
Description copied from class:AbstractHBaseToolThe "main function" of the tool- Specified by:
doWorkin classAbstractHBaseTool- Throws:
Exception
-
main
-