-
Notifications
You must be signed in to change notification settings - Fork 3.3k
HBASE-29365 Improve option parser of PerformanceEvaluation #7052
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
Conversation
.load(PerformanceEvaluation.class.getClassLoader().getResourceAsStream(fileName)); | ||
opts.commandProperties = properties; | ||
} catch (IOException e) { | ||
LOG.error("Failed to load metricIds from properties file", e); |
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 changed two things here.
- The original error message was a bit strange. Where did
metricIds
come from? I changed it toFailed to load command properties from file
- It used to print the error message and proceed. I decided to throw the exception instead.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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 option parsing in PerformanceEvaluation to use dynamic mappings and implements stricter boolean parsing. Key changes include replacing the long if‐chain for options, adding new test cases for the parser, and introducing a custom parseBoolean method for robust flag handling.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
hbase-diagnostics/src/test/java/org/apache/hadoop/hbase/TestPerformanceEvaluation.java | Added tests to verify parsing behavior, including missing values and boolean flag handling. |
hbase-diagnostics/src/main/java/org/apache/hadoop/hbase/PerformanceEvaluation.java | Refactored option parsing with maps for flag and value handling and improved error reporting. |
hbase-diagnostics/src/test/java/org/apache/hadoop/hbase/TestPerformanceEvaluation.java
Outdated
Show resolved
Hide resolved
continue; | ||
} | ||
if (cmd.startsWith("--")) { | ||
final String[] parts = cmd.substring(2).split("=", 2); |
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.
Better use Splitter from our shaded guava?
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.
Thanks for the suggestion. I like that we can use trimResults
with Splitter
.
Addressed in 28b2769.
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 the option parser in PerformanceEvaluation to reduce duplicated code and improve boolean parsing strictness while adding tests for the new behavior.
- Refactor of option parsing to use maps for both boolean flags and value-based options
- Addition of a custom parseBoolean method for stricter boolean handling
- New tests in TestPerformanceEvaluation to validate parsing scenarios
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
hbase-diagnostics/src/test/java/org/apache/hadoop/hbase/TestPerformanceEvaluation.java | Added tests to validate boolean flags and missing option values |
hbase-diagnostics/src/main/java/org/apache/hadoop/hbase/PerformanceEvaluation.java | Refactored option parsing via maps and introduced strict boolean parsing with parseBoolean |
Comments suppressed due to low confidence (1)
hbase-diagnostics/src/main/java/org/apache/hadoop/hbase/PerformanceEvaluation.java:2967
- [nitpick] Clarify the error message in parseBoolean to specify that only 'true' or 'false' values are accepted.
private static boolean parseBoolean(String value) {
hbase-diagnostics/src/main/java/org/apache/hadoop/hbase/PerformanceEvaluation.java
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
🎊 +1 overall
This message was automatically generated. |
🎊 +1 overall
This message was automatically generated. |
Please raise PR for branch-2.x? Thanks. |
Thanks for the review! Just opened a pull request to branch-2: #7056 |
Also to branch-2.6: #7057 |
Signed-off-by: Duo Zhang <[email protected]> (cherry picked from commit 97cf65d)
https://issues.apache.org/jira/browse/HBASE-29365