-
Notifications
You must be signed in to change notification settings - Fork 3.3k
HBASE-29279 Allow throttling alter operation via table configuration #6951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
junegunn
wants to merge
2
commits into
apache:master
Choose a base branch
from
junegunn:HBASE-29279
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+69
−18
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,9 +22,13 @@ | |
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.stream.Collectors; | ||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.hbase.HRegionLocation; | ||
import org.apache.hadoop.hbase.TableName; | ||
import org.apache.hadoop.hbase.client.TableDescriptor; | ||
import org.apache.hadoop.hbase.conf.ConfigKey; | ||
import org.apache.hadoop.hbase.master.assignment.RegionStateNode; | ||
import org.apache.hadoop.hbase.master.assignment.TransitRegionStateProcedure; | ||
import org.apache.hadoop.hbase.procedure2.ProcedureStateSerializer; | ||
|
@@ -55,12 +59,11 @@ public class ReopenTableRegionsProcedure | |
private static final Logger LOG = LoggerFactory.getLogger(ReopenTableRegionsProcedure.class); | ||
|
||
public static final String PROGRESSIVE_BATCH_BACKOFF_MILLIS_KEY = | ||
"hbase.reopen.table.regions.progressive.batch.backoff.ms"; | ||
ConfigKey.LONG("hbase.reopen.table.regions.progressive.batch.backoff.ms"); | ||
public static final long PROGRESSIVE_BATCH_BACKOFF_MILLIS_DEFAULT = 0L; | ||
public static final String PROGRESSIVE_BATCH_SIZE_MAX_KEY = | ||
"hbase.reopen.table.regions.progressive.batch.size.max"; | ||
ConfigKey.INT("hbase.reopen.table.regions.progressive.batch.size.max"); | ||
public static final int PROGRESSIVE_BATCH_SIZE_MAX_DISABLED = -1; | ||
private static final int PROGRESSIVE_BATCH_SIZE_MAX_DEFAULT_VALUE = Integer.MAX_VALUE; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one was unused. |
||
|
||
// this minimum prevents a max which would break this procedure | ||
private static final int MINIMUM_BATCH_SIZE_MAX = 1; | ||
|
@@ -83,6 +86,23 @@ public class ReopenTableRegionsProcedure | |
private long regionsReopened = 0; | ||
private long batchesProcessed = 0; | ||
|
||
/** | ||
* Create a new ReopenTableRegionsProcedure respecting the throttling configuration for the table. | ||
* First check the table descriptor, then fall back to the global configuration. Only used in | ||
* ModifyTableProcedure. | ||
*/ | ||
public static ReopenTableRegionsProcedure throttled(final Configuration conf, | ||
final TableDescriptor desc) { | ||
long backoffMillis = Optional.ofNullable(desc.getValue(PROGRESSIVE_BATCH_BACKOFF_MILLIS_KEY)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pity we do not return Optional for desc.getValue... |
||
.map(Long::parseLong).orElseGet(() -> conf.getLong(PROGRESSIVE_BATCH_BACKOFF_MILLIS_KEY, | ||
PROGRESSIVE_BATCH_BACKOFF_MILLIS_DEFAULT)); | ||
int batchSizeMax = Optional.ofNullable(desc.getValue(PROGRESSIVE_BATCH_SIZE_MAX_KEY)) | ||
.map(Integer::parseInt).orElseGet( | ||
() -> conf.getInt(PROGRESSIVE_BATCH_SIZE_MAX_KEY, PROGRESSIVE_BATCH_SIZE_MAX_DISABLED)); | ||
|
||
return new ReopenTableRegionsProcedure(desc.getTableName(), backoffMillis, batchSizeMax); | ||
} | ||
|
||
public ReopenTableRegionsProcedure() { | ||
this(null); | ||
} | ||
|
@@ -96,12 +116,12 @@ public ReopenTableRegionsProcedure(final TableName tableName, final List<byte[]> | |
PROGRESSIVE_BATCH_SIZE_MAX_DISABLED); | ||
} | ||
|
||
public ReopenTableRegionsProcedure(final TableName tableName, long reopenBatchBackoffMillis, | ||
ReopenTableRegionsProcedure(final TableName tableName, long reopenBatchBackoffMillis, | ||
int reopenBatchSizeMax) { | ||
this(tableName, Collections.emptyList(), reopenBatchBackoffMillis, reopenBatchSizeMax); | ||
} | ||
|
||
public ReopenTableRegionsProcedure(final TableName tableName, final List<byte[]> regionNames, | ||
private ReopenTableRegionsProcedure(final TableName tableName, final List<byte[]> regionNames, | ||
long reopenBatchBackoffMillis, int reopenBatchSizeMax) { | ||
this.tableName = tableName; | ||
this.regionNames = regionNames; | ||
|
@@ -137,6 +157,12 @@ public long getBatchesProcessed() { | |
return batchesProcessed; | ||
} | ||
|
||
@RestrictedApi(explanation = "Should only be called in tests", link = "", | ||
allowedOnPath = ".*/src/test/.*") | ||
long getReopenBatchBackoffMillis() { | ||
return reopenBatchBackoffMillis; | ||
} | ||
|
||
@RestrictedApi(explanation = "Should only be called internally or in tests", link = "", | ||
allowedOnPath = ".*(/src/test/.*|ReopenTableRegionsProcedure).java") | ||
protected int progressBatchSize() { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type checks are now necessary.