[HUDI-2840] Fixed DeltaStreaemer to properly respect configuration passed t/h properties file (#4090)
* Rebased `DFSPropertiesConfiguration` to access Hadoop config in liue of FS to avoid confusion * Fixed `readConfig` to take Hadoop's `Configuration` instead of FS; Fixing usages * Added test for local FS access * Rebase to use `FSUtils.getFs` * Combine properties provided as a file along w/ overrides provided from the CLI * Added helper utilities to `HoodieClusteringConfig`; Make sure corresponding config methods fallback to defaults; * Fixed DeltaStreamer usage to respect properly combined configuration; Abstracted `HoodieClusteringConfig.from` convenience utility to init Clustering config from `Properties` * Tidying up * `lint` * Reverting changes to `HoodieWriteConfig` * Tdiying up * Fixed incorrect merge of the props * Converted `HoodieConfig` to wrap around `Properties` into `TypedProperties` * Fixed compilation * Fixed compilation
This commit is contained in:
@@ -22,6 +22,7 @@ import org.apache.hudi.common.config.ConfigClassProperty;
|
||||
import org.apache.hudi.common.config.ConfigGroups;
|
||||
import org.apache.hudi.common.config.ConfigProperty;
|
||||
import org.apache.hudi.common.config.HoodieConfig;
|
||||
import org.apache.hudi.common.config.TypedProperties;
|
||||
import org.apache.hudi.common.engine.EngineType;
|
||||
import org.apache.hudi.exception.HoodieException;
|
||||
import org.apache.hudi.exception.HoodieNotSupportedException;
|
||||
@@ -334,11 +335,24 @@ public class HoodieClusteringConfig extends HoodieConfig {
|
||||
/** @deprecated Use {@link #ASYNC_CLUSTERING_ENABLE} and its methods instead */
|
||||
@Deprecated
|
||||
public static final String DEFAULT_ASYNC_CLUSTERING_ENABLE_OPT_VAL = ASYNC_CLUSTERING_ENABLE.defaultValue();
|
||||
|
||||
|
||||
// NOTE: This ctor is required for appropriate deserialization
|
||||
public HoodieClusteringConfig() {
|
||||
super();
|
||||
}
|
||||
|
||||
public boolean isAsyncClusteringEnabled() {
|
||||
return getBooleanOrDefault(HoodieClusteringConfig.ASYNC_CLUSTERING_ENABLE);
|
||||
}
|
||||
|
||||
public boolean isInlineClusteringEnabled() {
|
||||
return getBooleanOrDefault(HoodieClusteringConfig.INLINE_CLUSTERING);
|
||||
}
|
||||
|
||||
public static HoodieClusteringConfig from(TypedProperties props) {
|
||||
return HoodieClusteringConfig.newBuilder().fromProperties(props).build();
|
||||
}
|
||||
|
||||
public static Builder newBuilder() {
|
||||
return new Builder();
|
||||
}
|
||||
@@ -421,6 +435,7 @@ public class HoodieClusteringConfig extends HoodieConfig {
|
||||
}
|
||||
|
||||
public Builder fromProperties(Properties props) {
|
||||
// TODO this should cherry-pick only clustering properties
|
||||
this.clusteringConfig.getProps().putAll(props);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -166,11 +166,6 @@ public class HoodieMetricsPrometheusConfig extends HoodieConfig {
|
||||
return new HoodieMetricsPrometheusConfig.Builder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Properties getProps() {
|
||||
return super.getProps();
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private HoodieMetricsPrometheusConfig hoodieMetricsPrometheusConfig = new HoodieMetricsPrometheusConfig();
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
package org.apache.hudi.metrics;
|
||||
|
||||
import org.apache.hudi.common.config.TypedProperties;
|
||||
import org.apache.hudi.config.HoodieWriteConfig;
|
||||
|
||||
import com.codahale.metrics.MetricRegistry;
|
||||
@@ -57,7 +58,7 @@ public class TestMetricsReporterFactory {
|
||||
public void metricsReporterFactoryShouldReturnUserDefinedReporter() {
|
||||
when(config.getMetricReporterClassName()).thenReturn(DummyMetricsReporter.class.getName());
|
||||
|
||||
Properties props = new Properties();
|
||||
TypedProperties props = new TypedProperties();
|
||||
props.setProperty("testKey", "testValue");
|
||||
|
||||
when(config.getProps()).thenReturn(props);
|
||||
@@ -70,7 +71,7 @@ public class TestMetricsReporterFactory {
|
||||
@Test
|
||||
public void metricsReporterFactoryShouldThrowExceptionWhenMetricsReporterClassIsIllegal() {
|
||||
when(config.getMetricReporterClassName()).thenReturn(IllegalTestMetricsReporter.class.getName());
|
||||
when(config.getProps()).thenReturn(new Properties());
|
||||
when(config.getProps()).thenReturn(new TypedProperties());
|
||||
assertThrows(HoodieException.class, () -> MetricsReporterFactory.createReporter(config, registry));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user