Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public class RegionMover extends AbstractHBaseTool implements Closeable {
private Connection conn;
private Admin admin;
private RackManager rackManager;
private int maxRetries;

private RegionMover(RegionMoverBuilder builder) throws IOException {
this.hostname = builder.hostname;
Expand Down Expand Up @@ -146,6 +147,8 @@ private RegionMover(RegionMoverBuilder builder) throws IOException {
// provided as @InterfaceAudience.Private and it is commented that this is just
// to be used by unit test.
rackManager = builder.rackManager == null ? new RackManager(conf) : builder.rackManager;
this.maxRetries = admin.getConfiguration().getInt(RegionMover.MOVE_RETRIES_MAX_KEY,
RegionMover.DEFAULT_MOVE_RETRIES_MAX);
}

private RegionMover() {
Expand Down Expand Up @@ -396,8 +399,13 @@ private void loadRegions(List<RegionInfo> regionsToMove) throws Exception {
}

moveRegionsPool.shutdown();
// Calculate timeout based on acknowledge mode. In ack mode, account for retry attempts since
// MoveWithAck retries failed moves up to MOVE_RETRIES_MAX_KEY times. In no-ack mode, each
// region move is attempted only once. Timeout = regions * wait_per_region * retries
int retries = (ack) ? maxRetries : 1;
long timeoutInSeconds = regionsToMove.size()
* admin.getConfiguration().getLong(MOVE_WAIT_MAX_KEY, DEFAULT_MOVE_WAIT_MAX);
* admin.getConfiguration().getLong(MOVE_WAIT_MAX_KEY, DEFAULT_MOVE_WAIT_MAX) * retries;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems better to use this.conf instead of admin.getConfiguration(), conf is an inherited field

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @guluo2016 for reviewing the PR.

While this.conf would also work, I chose to continue using admin.getConfiguration() for consistency and correctness:

The admin object is constructed from this.conf (see RegionMover lines 130–131), so admin.getConfiguration() should reflect the same configuration.

The original code already uses admin.getConfiguration() here, and several other places in this class also rely on the admin instance for configuration.

MoveWithAck follows the same pattern and uses admin to retrieve the configuration.

To keep the code consistent across the class and related logic, I think it’s cleaner to continue using admin.getConfiguration().

Please let me what you think. Thanks


waitMoveTasksToFinish(moveRegionsPool, taskList, timeoutInSeconds);
}

Expand Down Expand Up @@ -682,8 +690,13 @@ private void submitRegionMovesWhileUnloading(ServerName server, List<ServerName>
serverIndex = (serverIndex + 1) % regionServers.size();
}
moveRegionsPool.shutdown();
// Calculate timeout based on acknowledge mode. In ack mode, account for retry attempts since
// MoveWithAck retries failed moves up to MOVE_RETRIES_MAX_KEY times. In no-ack mode, each
// region move is attempted only once. Timeout = regions * wait_per_region * retries
int retries = (ack || forceMoveRegionByAck) ? maxRetries : 1;
long timeoutInSeconds = regionsToMove.size()
* admin.getConfiguration().getLong(MOVE_WAIT_MAX_KEY, DEFAULT_MOVE_WAIT_MAX);
* admin.getConfiguration().getLong(MOVE_WAIT_MAX_KEY, DEFAULT_MOVE_WAIT_MAX) * retries;

waitMoveTasksToFinish(moveRegionsPool, taskList, timeoutInSeconds);
}

Expand Down