rangareddy opened a new pull request, #19418:
URL: https://github.com/apache/hudi/pull/19418
### Describe the issue this Pull Request addresses
Closes #15293 (HUDI-4452).
The CloudWatch metrics reporter lives in the optional `hudi-aws` module and
is loaded reflectively by
`MetricsReporterFactory`. `packaging/hudi-spark-bundle/pom.xml` does not
shade `hudi-aws` (unlike
`hudi-flink-bundle` and `hudi-kafka-connect-bundle`, which do), so a Spark
user who sets
`hoodie.metrics.reporter.type=CLOUDWATCH` with only the Spark bundle on the
classpath gets:
```
org.apache.hudi.exception.HoodieException: Unable to load class
Caused by: java.lang.ClassNotFoundException:
org.apache.hudi.aws.metrics.cloudwatch.CloudWatchMetricsReporter
```
The message names neither the missing class nor anything the user can do
about it.
### Summary and Changelog
Turns that failure into an actionable one instead of changing the bundle's
dependencies.
- `MetricsReporterFactory`: extracted the reporter class name to a constant
and moved the reflective
load into a small private helper. When the load fails with a
`ClassNotFoundException` cause, rethrow a
`HoodieException` naming the missing class, the `hudi-aws` module, the
`hudi-aws-bundle` jar to add,
and `hoodie.metrics.reporter.type` as the alternative. Every other failure
is rethrown unchanged.
- `TestMetricsReporterFactory`: new test asserting the message names the
class, the bundle, and the
config key. It works because `hudi-aws` is not on `hudi-common`'s test
classpath, which is the same
condition the user hits (the pre-existing CloudWatch test has to
`mockStatic` `ReflectionUtils` for
exactly that reason).
**On the approach:** the issue title asks for `hudi-aws` to be added to
`hudi-spark-bundle`. #6183 did
that and was closed unmerged; the review there asked for the opposite
direction — "Ideally, we need a
way to completely decouple the two. Just because one class we need to pull
in this dependency" — and
conditioned merging on `hudi-aws` being in `provided` scope, which would not
put the class on a user's
classpath anyway. Shading an AWS SDK into the general-purpose Spark bundle
for one optional reporter
seemed like the wrong trade, so this PR fixes the user-visible defect (an
unactionable error) and leaves
the bundle contents alone. Happy to switch approaches if the preference is
otherwise.
`MetricsReporterFactory` is the only place the class is loaded, so there is
no second path to update.
### Impact
No API, config, or format change, and no change in which reporters work.
Only the failure message for
`CLOUDWATCH` when `hudi-aws` is missing; the exception type stays
`HoodieException`.
Known limitation, deliberately not addressed: if `hudi-aws` is present but
the AWS SDK is not, the JVM
raises `NoClassDefFoundError`, which this does not intercept — catching
`Error` in a metrics factory
would be worse than the message it would improve.
### Risk Level
none
### Documentation Update
none — no new config and no default value change.
### Contributor's checklist
- [x] Read through [contributor's
guide](https://hudi.apache.org/contribute/how-to-contribute)
- [x] Enough context is provided in the sections above
- [x] Adequate tests were added if applicable
- [x] CI passes on my PR
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]