Skip to content

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

Merged
merged 4 commits into from
Jun 3, 2025

Conversation

junegunn
Copy link
Contributor

@junegunn junegunn commented May 31, 2025

.load(PerformanceEvaluation.class.getClassLoader().getResourceAsStream(fileName));
opts.commandProperties = properties;
} catch (IOException e) {
LOG.error("Failed to load metricIds from properties file", e);
Copy link
Contributor Author

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 to Failed to load command properties from file
  • It used to print the error message and proceed. I decided to throw the exception instead.

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache9 Apache9 requested a review from Copilot June 1, 2025 14:24
Copy link

@Copilot Copilot AI left a 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.

continue;
}
if (cmd.startsWith("--")) {
final String[] parts = cmd.substring(2).split("=", 2);
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@junegunn junegunn requested a review from Copilot June 2, 2025 00:08
Copy link

@Copilot Copilot AI left a 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) {

@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@junegunn junegunn requested a review from Apache9 June 2, 2025 00:50
@Apache-HBase

This comment has been minimized.

@Apache-HBase

This comment has been minimized.

@Apache-HBase
Copy link

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 30s Docker mode activated.
-0 ⚠️ yetus 0m 2s Unprocessed flag(s): --brief-report-file --spotbugs-strict-precheck --author-ignore-list --blanks-eol-ignore-file --blanks-tabs-ignore-file --quick-hadoopcheck
_ Prechecks _
_ master Compile Tests _
+1 💚 mvninstall 3m 13s master passed
+1 💚 compile 0m 18s master passed
+1 💚 javadoc 0m 13s master passed
+1 💚 shadedjars 6m 4s branch has no errors when building our shaded downstream artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 3m 10s the patch passed
+1 💚 compile 0m 18s the patch passed
+1 💚 javac 0m 18s the patch passed
+1 💚 javadoc 0m 12s the patch passed
+1 💚 shadedjars 6m 2s patch has no errors when building our shaded downstream artifacts.
_ Other Tests _
+1 💚 unit 4m 6s hbase-diagnostics in the patch passed.
25m 10s
Subsystem Report/Notes
Docker ClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7052/4/artifact/yetus-jdk17-hadoop3-check/output/Dockerfile
GITHUB PR #7052
Optional Tests javac javadoc unit compile shadedjars
uname Linux cf3bf0d6f8a9 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/hbase-personality.sh
git revision master / 858e01e
Default Java Eclipse Adoptium-17.0.11+9
Test Results https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7052/4/testReport/
Max. process+thread count 2181 (vs. ulimit of 30000)
modules C: hbase-diagnostics U: hbase-diagnostics
Console output https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7052/4/console
versions git=2.34.1 maven=3.9.8
Powered by Apache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

@Apache-HBase
Copy link

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 26s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 hbaseanti 0m 0s Patch does not have any anti-patterns.
_ master Compile Tests _
+1 💚 mvninstall 3m 8s master passed
+1 💚 compile 0m 25s master passed
+1 💚 checkstyle 0m 8s master passed
+1 💚 spotbugs 0m 26s master passed
+1 💚 spotless 0m 45s branch has no errors when running spotless:check.
_ Patch Compile Tests _
+1 💚 mvninstall 3m 6s the patch passed
+1 💚 compile 0m 26s the patch passed
-0 ⚠️ javac 0m 26s /results-compile-javac-hbase-diagnostics.txt hbase-diagnostics generated 2 new + 56 unchanged - 0 fixed = 58 total (was 56)
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 0m 9s hbase-diagnostics: The patch generated 0 new + 29 unchanged - 2 fixed = 29 total (was 31)
+1 💚 spotbugs 0m 33s the patch passed
+1 💚 hadoopcheck 12m 3s Patch does not cause any errors with Hadoop 3.3.6 3.4.0.
+1 💚 spotless 0m 47s patch has no errors when running spotless:check.
_ Other Tests _
+1 💚 asflicense 0m 8s The patch does not generate ASF License warnings.
30m 21s
Subsystem Report/Notes
Docker ClientAPI=1.43 ServerAPI=1.43 base: https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7052/4/artifact/yetus-general-check/output/Dockerfile
GITHUB PR #7052
Optional Tests dupname asflicense javac spotbugs checkstyle codespell detsecrets compile hadoopcheck hbaseanti spotless
uname Linux 8b6ecdd6894e 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/hbase-personality.sh
git revision master / 858e01e
Default Java Eclipse Adoptium-17.0.11+9
Max. process+thread count 83 (vs. ulimit of 30000)
modules C: hbase-diagnostics U: hbase-diagnostics
Console output https://ci-hbase.apache.org/job/HBase-PreCommit-GitHub-PR/job/PR-7052/4/console
versions git=2.34.1 maven=3.9.8 spotbugs=4.7.3
Powered by Apache Yetus 0.15.0 https://yetus.apache.org

This message was automatically generated.

@Apache9
Copy link
Contributor

Apache9 commented Jun 2, 2025

Please raise PR for branch-2.x?

Thanks.

@junegunn
Copy link
Contributor Author

junegunn commented Jun 2, 2025

Thanks for the review! Just opened a pull request to branch-2: #7056

@junegunn
Copy link
Contributor Author

junegunn commented Jun 2, 2025

Also to branch-2.6: #7057

@Apache9 Apache9 merged commit 97cf65d into apache:master Jun 3, 2025
1 check passed
Apache9 pushed a commit that referenced this pull request Jun 3, 2025
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.

3 participants