-
Notifications
You must be signed in to change notification settings - Fork 134
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
[Improvement] Optimize the use of QuotaManager #359
Conversation
cc @xianjingfeng Could you help me review this patch? |
this.currentUserAndApp = quotaManager.getCurrentUserAndApp(); | ||
this.appIdToUser = quotaManager.getAppIdToUser(); | ||
this.defaultUserApps = quotaManager.getDefaultUserApps(); | ||
if (conf.get(CoordinatorConf.COORDINATOR_ACCESS_CHECKERS).stream().map(String::trim).collect(Collectors.toList()) |
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.
String quotaCheckerClass = AccessQuotaChecker.class.getCanonicalName();
for (String checker : conf.get(COORDINATOR_ACCESS_CHECKERS)) {
if (quotaCheckerClass.equals(checker.trim())) {
this.quotaManager = new QuotaManager(conf);
this.currentUserAndApp = quotaManager.getCurrentUserAndApp();
this.appIdToUser = quotaManager.getAppIdToUser();
this.defaultUserApps = quotaManager.getDefaultUserApps();
break;
}
}
Do you think it's good to write like this?
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.
It's ok for me.
this.quotaManager = new QuotaManager(conf); | ||
this.currentUserAndApp = quotaManager.getCurrentUserAndApp(); | ||
this.appIdToUser = quotaManager.getAppIdToUser(); | ||
this.defaultUserApps = quotaManager.getDefaultUserApps(); |
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.
Can we remove defaultUserApps
in this class?
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.
Yes, this's not used in this class.
@@ -53,13 +53,14 @@ public class QuotaManager { | |||
private final Map<String, Integer> defaultUserApps = Maps.newConcurrentMap(); | |||
|
|||
public QuotaManager(CoordinatorConf conf) { | |||
this.quotaFilePath = conf.get(CoordinatorConf.COORDINATOR_QUOTA_DEFAULT_PATH);; | |||
this.quotaFilePath = conf.get(CoordinatorConf.COORDINATOR_QUOTA_DEFAULT_PATH); |
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.
If quotaFilePath
is empty, should we throw an exception here right now?
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.
If the quotaFilePath is empty, the quota for each user is the default value of rss.coordinator.quota.default.app.num
. No exception is thrown, but logs can be added
final Long updateTime = conf.get(CoordinatorConf.COORDINATOR_QUOTA_UPDATE_INTERVAL); | ||
try { | ||
hadoopFileSystem = HadoopFilesystemProvider.getFilesystem(new Path(quotaFilePath), new Configuration()); | ||
} catch (Exception e) { | ||
LOG.error("Cannot init remoteFS on path : " + quotaFilePath, e); | ||
} | ||
LOG.warn("We will update the quota of users regularly."); |
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.
Why we need this?
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.
This is to prompt the user that QuotaManager starts normally.
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.
How about use LOG.info?
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.
Updated.
Codecov Report
@@ Coverage Diff @@
## master #359 +/- ##
============================================
+ Coverage 58.32% 61.62% +3.29%
- Complexity 1550 1572 +22
============================================
Files 193 187 -6
Lines 10754 9685 -1069
Branches 936 954 +18
============================================
- Hits 6272 5968 -304
+ Misses 4109 3403 -706
+ Partials 373 314 -59
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
LGTM
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.
LGTM, wait for CI. thanks @smallzhongfeng @xianjingfeng
Thanks all. @jerqi @xianjingfeng |
What changes were proposed in this pull request?
QuotaManager
, useQuotaManager
when checking the number of apps, and decouple withApplicationManager
.QuotaManager
is controlled by the configuration of the checker.Why are the changes needed?
More reasonable.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Added new ut.