[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:
@@ -103,7 +103,7 @@ public class TestDFSPropertiesConfiguration {
|
||||
|
||||
@Test
|
||||
public void testParsing() {
|
||||
DFSPropertiesConfiguration cfg = new DFSPropertiesConfiguration(dfs, new Path(dfsBasePath + "/t1.props"));
|
||||
DFSPropertiesConfiguration cfg = new DFSPropertiesConfiguration(dfs.getConf(), new Path(dfsBasePath + "/t1.props"));
|
||||
TypedProperties props = cfg.getProps();
|
||||
assertEquals(5, props.size());
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
@@ -131,7 +131,7 @@ public class TestDFSPropertiesConfiguration {
|
||||
|
||||
@Test
|
||||
public void testIncludes() {
|
||||
DFSPropertiesConfiguration cfg = new DFSPropertiesConfiguration(dfs, new Path(dfsBasePath + "/t3.props"));
|
||||
DFSPropertiesConfiguration cfg = new DFSPropertiesConfiguration(dfs.getConf(), new Path(dfsBasePath + "/t3.props"));
|
||||
TypedProperties props = cfg.getProps();
|
||||
|
||||
assertEquals(123, props.getInteger("int.prop"));
|
||||
@@ -144,6 +144,31 @@ public class TestDFSPropertiesConfiguration {
|
||||
}, "Should error out on a self-included file.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLocalFileSystemLoading() {
|
||||
DFSPropertiesConfiguration cfg = new DFSPropertiesConfiguration(dfs.getConf(), new Path(dfsBasePath + "/t1.props"));
|
||||
|
||||
cfg.addPropsFromFile(
|
||||
new Path(
|
||||
String.format(
|
||||
"file:%s",
|
||||
getClass().getClassLoader()
|
||||
.getResource("props/test.properties")
|
||||
.getPath()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
TypedProperties props = cfg.getProps();
|
||||
|
||||
assertEquals(123, props.getInteger("int.prop"));
|
||||
assertEquals(113.4, props.getDouble("double.prop"), 0.001);
|
||||
assertTrue(props.getBoolean("boolean.prop"));
|
||||
assertEquals("str", props.getString("string.prop"));
|
||||
assertEquals(1354354354, props.getLong("long.prop"));
|
||||
assertEquals(123, props.getInteger("some.random.prop"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoGlobalConfFileConfigured() {
|
||||
ENVIRONMENT_VARIABLES.clear(DFSPropertiesConfiguration.CONF_FILE_DIR_ENV_NAME);
|
||||
|
||||
18
hudi-common/src/test/resources/props/test.properties
Normal file
18
hudi-common/src/test/resources/props/test.properties
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
some.random.prop=123
|
||||
Reference in New Issue
Block a user