@InterfaceAudience.Public public class RegionMover extends AbstractHBaseTool implements Closeable
load()
or unload()
methods for the desired operations.Modifier and Type | Class and Description |
---|---|
static class |
RegionMover.RegionMoverBuilder
Builder for Region mover.
|
AbstractHBaseTool.OptionsOrderComparator
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 |
designatedFile |
private String |
excludeFile |
private String |
filename |
private String |
hostname |
private String |
loadUnload |
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 RackManager |
rackManager |
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 Optional<RegionInfo> |
getMetaRegionInfoIfToBeMoved(List<RegionInfo> regionsToMove) |
private Callable<Boolean> |
getMetaRegionMovePlan() |
private Callable<Boolean> |
getNonMetaRegionsMovePlan() |
private Callable<Boolean> |
getRegionsMovePlan(boolean moveMetaRegion) |
private ServerName |
getTargetServer() |
private boolean |
ignoreRegionMoveFailure(ExecutionException e) |
private void |
includeExcludeRegionServers(String fileName,
List<ServerName> regionServers,
boolean isInclude)
Designates or excludes the servername whose hostname and port portion matches the list given in
the file.
|
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<RegionInfo> |
readRegionsFromFile(String filename) |
private List<String> |
readServersFromFile(String filename) |
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.
|
private void |
submitRegionMovesWhileUnloading(ServerName server,
List<ServerName> regionServers,
List<RegionInfo> movedRegions,
List<RegionInfo> regionsToMove) |
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 . |
boolean |
unloadFromRack()
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 boolean |
unloadRegions(boolean unloadFromRack) |
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, getOptionAsInt, getOptionAsLong, 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
private 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 String designatedFile
private int port
private Connection conn
private RackManager rackManager
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 Callable<Boolean> getMetaRegionMovePlan()
private Callable<Boolean> getNonMetaRegionsMovePlan()
private Callable<Boolean> getRegionsMovePlan(boolean moveMetaRegion)
private Optional<RegionInfo> getMetaRegionInfoIfToBeMoved(List<RegionInfo> regionsToMove)
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
. If designatedFile is present with some contents, we will unload regions
to hostnames provided in designatedFile
InterruptedException
ExecutionException
TimeoutException
public boolean unloadFromRack() 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
. If designatedFile is present with some contents, we will unload regions
to hostnames provided in designatedFile
. 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.InterruptedException
ExecutionException
TimeoutException
private boolean unloadRegions(boolean unloadFromRack) throws InterruptedException, ExecutionException, TimeoutException
private void unloadRegions(ServerName server, List<ServerName> regionServers, List<RegionInfo> movedRegions) throws Exception
Exception
private void submitRegionMovesWhileUnloading(ServerName server, List<ServerName> regionServers, List<RegionInfo> movedRegions, List<RegionInfo> regionsToMove) 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 boolean ignoreRegionMoveFailure(ExecutionException e)
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> readServersFromFile(String filename) throws IOException
filename
- The file should have 'host:port' per lineIOException
private void includeExcludeRegionServers(String fileName, List<ServerName> regionServers, boolean isInclude) throws IOException
IOException
private void stripMaster(List<ServerName> regionServers) throws IOException
IOException
private ServerName stripServer(List<ServerName> regionServers, String hostname, int port)
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–2020 The Apache Software Foundation. All rights reserved.