nastra commented on code in PR #7014:
URL: https://github.com/apache/iceberg/pull/7014#discussion_r1126017965
##########
core/src/test/java/org/apache/iceberg/TestCatalogUtil.java:
##########
@@ -193,26 +194,28 @@ public void buildCustomCatalog_withTypeSet() {
public void loadCustomMetricsReporter_noArg() {
Map<String, String> properties = Maps.newHashMap();
properties.put("key", "val");
+ properties.put(
+ CatalogProperties.METRICS_REPORTER_IMPL,
TestMetricsReporterDefault.class.getName());
- MetricsReporter metricsReporter =
-
CatalogUtil.loadMetricsReporter(TestMetricsReporterDefault.class.getName());
+ MetricsReporter metricsReporter =
CatalogUtil.loadMetricsReporter(properties);
Assertions.assertThat(metricsReporter).isInstanceOf(TestMetricsReporterDefault.class);
}
@Test
public void loadCustomMetricsReporter_badArg() {
- Assertions.assertThatThrownBy(
- () ->
CatalogUtil.loadMetricsReporter(TestMetricsReporterBadArg.class.getName()))
- .isInstanceOf(IllegalArgumentException.class)
- .hasMessageContaining("missing no-arg constructor");
+ Map<String, String> properties = Maps.newHashMap();
+ properties.put(
+ CatalogProperties.METRICS_REPORTER_IMPL,
TestMetricsReporterBadArg.class.getName());
+ Assertions.assertThat(CatalogUtil.loadMetricsReporter(properties))
+ .isInstanceOf(LoggingMetricsReporter.class);
}
@Test
public void loadCustomMetricsReporter_badClass() {
- Assertions.assertThatThrownBy(
- () ->
CatalogUtil.loadMetricsReporter(TestFileIONotImpl.class.getName()))
- .isInstanceOf(IllegalArgumentException.class)
- .hasMessageContaining("does not implement MetricsReporter");
+ Map<String, String> properties = Maps.newHashMap();
+ properties.put(CatalogProperties.METRICS_REPORTER_IMPL,
TestFileIONotImpl.class.getName());
+ Assertions.assertThat(CatalogUtil.loadMetricsReporter(properties))
Review Comment:
nit: the properties could be inlined:
`Assertions.assertThat(CatalogUtil.loadMetricsReporter(ImmutableMap.of(CatalogProperties.METRICS_REPORTER_IMPL,
TestFileIONotImpl.class.getName())))`
##########
core/src/main/java/org/apache/iceberg/CatalogUtil.java:
##########
@@ -407,36 +408,38 @@ public static void configureHadoopConf(Object
maybeConfigurable, Object conf) {
*
* <p>The implementation must have a no-arg constructor.
*
- * @param impl full class name of a custom {@link MetricsReporter}
implementation
+ * @param properties catalog properties which contains class name of a
custom {@link
+ * MetricsReporter} implementation
* @return An initialized {@link MetricsReporter}.
- * @throws IllegalArgumentException if class path not found or right
constructor not found or the
- * loaded class cannot be cast to the given interface type
*/
- public static MetricsReporter loadMetricsReporter(String impl) {
+ public static MetricsReporter loadMetricsReporter(Map<String, String>
properties) {
Review Comment:
I agree with everything what @rdblue mentioned here.
* it should fallback to the `LoggingMetricsReporter` if there's no reporter
available (so that me don't change behavior)
* failures should still happen (as before) if something is misconfigured
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]