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]: Implement a stateless overview manager. #3429

Merged
merged 14 commits into from
Feb 7, 2025

Conversation

baiyangtx
Copy link
Contributor

Why are the changes needed?

Make overview stateless to deploy it in multi-instance mode.

Brief change log

  • Caculate all overview data from database instead of metrics set.

How was this patch tested?

  • Add some test cases that check the changes thoroughly including negative and positive cases if possible

  • Add screenshots for manual tests if appropriate

  • Run test locally before making a pull request

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

# Conflicts:
#	dist/src/main/amoro-bin/conf/config.yaml
@codecov-commenter
Copy link

codecov-commenter commented Feb 5, 2025

Codecov Report

Attention: Patch coverage is 80.79470% with 29 lines in your changes missing coverage. Please review.

Project coverage is 27.72%. Comparing base (66a5254) to head (5ba9459).
Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
...apache/amoro/server/dashboard/OverviewManager.java 84.25% 12 Missing and 8 partials ⚠️
...erver/dashboard/controller/OverviewController.java 18.18% 9 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3429      +/-   ##
============================================
+ Coverage     21.80%   27.72%   +5.91%     
- Complexity     2353     3614    +1261     
============================================
  Files           431      602     +171     
  Lines         39948    49141    +9193     
  Branches       5655     6333     +678     
============================================
+ Hits           8712    13623    +4911     
- Misses        30504    34569    +4065     
- Partials        732      949     +217     
Flag Coverage Δ
core 27.72% <80.79%> (?)
trino ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@zhoujinsong zhoujinsong left a comment

Choose a reason for hiding this comment

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

@baiyangtx Thanks for the work.

I left some comments, PTAL.

@@ -38,25 +38,25 @@
/** The controller that handles overview page requests. */
public class OverviewController {

private OverviewCache overviewCache;
Copy link
Contributor

Choose a reason for hiding this comment

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

OverviewCache seems no longer needed, we may remove it.

@VisibleForTesting
public OverviewManager(int maxRecordCount, Duration refreshInterval) {
this.maxRecordCount = maxRecordCount;
ScheduledExecutorService overviewUpdaterScheduler =
Copy link
Contributor

Choose a reason for hiding this comment

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

overviewRefreshScheduler may be a proper name, and the thread name pattern can be overview-refresh-scheduler-%d.

@VisibleForTesting
public void refresh() {
long start = System.currentTimeMillis();
LOG.info("Updating overview cache");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
LOG.info("Updating overview cache");
LOG.info("Refreshing overview cache");

refreshResourceUsage(start);

} catch (Exception e) {
LOG.error("OverviewRefresher error", e);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
LOG.error("OverviewRefresher error", e);
LOG.error("Refreshed overview cache failed", e);

LOG.error("OverviewRefresher error", e);
} finally {
long end = System.currentTimeMillis();
LOG.info("Refresher overview cache took {} ms.", end - start);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
LOG.info("Refresher overview cache took {} ms.", end - start);
LOG.info("Refreshed overview cache in {} ms", end - start);

});
String status = statusToMetricString(meta.getTableStatus());
if (StringUtils.isNotEmpty(status)) {
optimizingStatusMap.computeIfAbsent(status, ignore -> 0L);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
optimizingStatusMap.computeIfAbsent(status, ignore -> 0L);
optimizingStatusMap.putIfAbsent(status, 0L);

Copy link
Contributor

@zhoujinsong zhoujinsong left a comment

Choose a reason for hiding this comment

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

LGTM.

@zhoujinsong zhoujinsong merged commit 57cc34c into apache:master Feb 7, 2025
4 checks passed
@baiyangtx baiyangtx deleted the stateless-overview branch February 7, 2025 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants