-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-29281 Atomic request throttles are missing QuotaSettingsFactory support #6953
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
Merged
Merged
Changes from all commits
Commits
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 |
|---|---|---|
|
|
@@ -26,7 +26,10 @@ | |
| import static org.apache.hadoop.hbase.quotas.ThrottleQuotaTestUtil.triggerUserCacheRefresh; | ||
| import static org.apache.hadoop.hbase.quotas.ThrottleQuotaTestUtil.waitMinuteQuota; | ||
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.assertTrue; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.List; | ||
| import java.util.concurrent.TimeUnit; | ||
| import org.apache.hadoop.hbase.HBaseClassTestRule; | ||
| import org.apache.hadoop.hbase.HBaseTestingUtil; | ||
|
|
@@ -652,4 +655,39 @@ public void testExceedThrottleQuota() throws Exception { | |
| admin.setQuota(QuotaSettingsFactory.unthrottleTable(TABLE_NAMES[0])); | ||
| triggerTableCacheRefresh(TEST_UTIL, true, TABLE_NAMES[0]); | ||
| } | ||
|
|
||
| @Test | ||
| public void testSetAndGetAllThrottleTypes() throws Exception { | ||
| for (ThrottleType throttleType : ThrottleType.values()) { | ||
| canSetAndGetUserThrottle(throttleType); | ||
| } | ||
|
Comment on lines
+661
to
+663
Contributor
Author
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. By validating this for every throttle type, we'll prevent new throttle types from missing this key usability piece down the road |
||
| } | ||
|
|
||
| private void canSetAndGetUserThrottle(ThrottleType throttleType) throws IOException { | ||
| final Admin admin = TEST_UTIL.getAdmin(); | ||
| final String userName = User.getCurrent().getShortName(); | ||
|
|
||
| QuotaSettings setQuota = | ||
| QuotaSettingsFactory.throttleUser(userName, throttleType, 123, TimeUnit.SECONDS); | ||
| admin.setQuota(setQuota); | ||
|
|
||
| boolean found = false; | ||
| List<QuotaSettings> quotaSettings = admin.getQuota(new QuotaFilter().setUserFilter(userName)); | ||
| for (QuotaSettings settings : quotaSettings) { | ||
| if (settings instanceof ThrottleSettings) { | ||
| ThrottleSettings throttle = (ThrottleSettings) settings; | ||
| if ( | ||
| userName.equals(throttle.getUserName()) && throttle.getThrottleType() == throttleType | ||
| && throttle.getSoftLimit() == 123 && throttle.getTimeUnit() == TimeUnit.SECONDS | ||
| ) { | ||
| found = true; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| assertTrue("Expected to find " + throttleType.name() + " quota for user " + userName, found); | ||
| admin.setQuota(QuotaSettingsFactory.unthrottleUserByThrottleType(userName, throttleType)); | ||
| } | ||
|
|
||
| } | ||
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.
[nitpick] Consider adding an inline comment here (and similarly for atomic write and request numbers) to explain the purpose of handling these atomic throttle settings for improved maintainability.
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.
I'm against superfluous comments that just reiterate straightforward code. This is already too verbose