Skip to content
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

Merged
merged 3 commits into from
Nov 26, 2022

Conversation

smallzhongfeng
Copy link
Contributor

What changes were proposed in this pull request?

  1. Optimize the use of QuotaManager, use QuotaManager when checking the number of apps, and decouple with ApplicationManager.
  2. For [Improvement] Make the startup of QuotaManager a configuration item #356 The start of 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.

@jerqi jerqi linked an issue Nov 25, 2022 that may be closed by this pull request
3 tasks
@jerqi
Copy link
Contributor

jerqi commented Nov 25, 2022

cc @xianjingfeng Could you help me review this patch?
If you feel that this patch is ok, you approve this pr and say LGTM. (LGTM means that look good to me)
企业微信截图_86ea0a12-15ab-45a3-b42b-6a9264dbada6

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())
Copy link
Member

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?

Copy link
Contributor Author

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();
Copy link
Member

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?

Copy link
Contributor Author

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);
Copy link
Member

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?

Copy link
Contributor Author

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.");
Copy link
Member

Choose a reason for hiding this comment

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

Why we need this?

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@codecov-commenter
Copy link

codecov-commenter commented Nov 26, 2022

Codecov Report

Merging #359 (85c409c) into master (91eef08) will increase coverage by 3.29%.
The diff coverage is 91.66%.

@@             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     
Impacted Files Coverage Δ
...a/org/apache/uniffle/coordinator/QuotaManager.java 82.00% <82.35%> (-6.64%) ⬇️
.../org/apache/uniffle/coordinator/AccessManager.java 94.28% <100.00%> (ø)
...apache/uniffle/coordinator/AccessQuotaChecker.java 95.83% <100.00%> (ø)
...apache/uniffle/coordinator/ApplicationManager.java 85.46% <100.00%> (+0.52%) ⬆️
.../apache/uniffle/coordinator/CoordinatorServer.java 65.26% <100.00%> (+0.36%) ⬆️
...rg/apache/uniffle/storage/common/LocalStorage.java 43.79% <0.00%> (-2.42%) ⬇️
...che/uniffle/server/storage/HdfsStorageManager.java 95.08% <0.00%> (-1.59%) ⬇️
...he/uniffle/server/storage/MultiStorageManager.java 47.76% <0.00%> (-1.47%) ⬇️
...he/uniffle/server/storage/LocalStorageManager.java 91.17% <0.00%> (-0.43%) ⬇️
... and 11 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@xianjingfeng xianjingfeng left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@jerqi jerqi left a 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

@jerqi jerqi merged commit 57a834b into apache:master Nov 26, 2022
@smallzhongfeng
Copy link
Contributor Author

Thanks all. @jerqi @xianjingfeng

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improvement] Make the startup of QuotaManager a configuration item
4 participants