-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Usage parsers refactoring #11097
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
base: main
Are you sure you want to change the base?
Usage parsers refactoring #11097
Conversation
thanks for this initiative @erikbocks , I’ll look at this (including doing some testing) |
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.
Pull Request Overview
This PR refactors individual Usage parser classes to inherit from a new abstract UsageParser
, replaces static methods/fields with instance methods and injected DAOs, unifies logging behavior, and simplifies UsageManagerImpl.parseHelperTables()
by injecting and iterating a list of parser beans.
- All parser classes now extend
UsageParser
, remove static parsing logic, and use an injectedUsageDao
- Introduced common logging (
beforeParse
) and standardized debug messages - Updated
UsageManagerImpl
to injectList<UsageParser>
and loop through parsers instead of calling each statically
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
UsageParser.java |
New base class with doParsing() , beforeParse() and common usageDao |
UsageManagerImpl.java |
Injects List<UsageParser> and iterates in parseHelperTables() |
usage/src/main/java/com/cloud/usage/parser/*.java |
Each parser now extends UsageParser , removes static methods, replaces DAO calls, and switches to instance logger |
Comments suppressed due to low confidence (1)
usage/src/main/java/com/cloud/usage/parser/NetworksUsageParser.java:40
- [nitpick] The parser name is pluralized here, while most other parsers use a singular form. Consider using "Network" for consistency.
return "Networks";
usage/src/main/java/com/cloud/usage/parser/NetworksUsageParser.java
Outdated
Show resolved
Hide resolved
@blueorangutan package |
@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #11097 +/- ##
===========================================
Coverage 16.57% 16.58%
- Complexity 13868 13968 +100
===========================================
Files 5719 5743 +24
Lines 507178 510354 +3176
Branches 61571 62026 +455
===========================================
+ Hits 84085 84617 +532
- Misses 413674 416275 +2601
- Partials 9419 9462 +43
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 13935 |
@blueorangutan test |
@DaanHoogland a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
The code looks good. I think we can still do some more refactoring inside the I will do some testing too. |
Description
Currently, all Usage parsers implement a static method with an identical signature, which is invoked by the
UsageManagerImpl#parseHelperTables()
method. This PR refactors these parser classes by standardizing them to extend theUsageParser
class and requiring an override of theparse
method, improving code consistency, maintainability, and extensibility.Additionally, by leveraging Spring Dependency Injection, it was possible to provide a major cleanup in the
UsageManagerImpl#parseHelperTables()
method, by injecting allUsageParser
implementations into a list, then iterating over it and calling theparse
method. The parse log was also improved to provide better information about the parsing result, the object being parsed and the target account.Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Screenshots (if appropriate):
How Has This Been Tested?
Update log example 1:
Footnotes
During the tests, I validated that the
UUID
column ofcloud_usage.accounts
is set to NULL after the accounts import from thecloud
database. An issue was mapped to fix this behaviour (NULL value in uuid column of cloud_usage.account table #11077) ↩