-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[HUDI-2840] Fixed DeltaStreaemer to properly respect configuration passed t/h properties file #4090
Changes from all commits
a42ee8f
de8fbf8
1458ca5
487e4ce
0352d08
2af3d92
7a736b3
0d496ff
8bee589
ad022fa
869be7e
7378e6e
7a34a66
2a01801
5795833
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,12 +21,15 @@ | |
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.fs.FileSystem; | ||
import org.apache.hadoop.fs.Path; | ||
import org.apache.hudi.common.fs.FSUtils; | ||
import org.apache.hudi.common.util.Option; | ||
import org.apache.hudi.common.util.StringUtils; | ||
import org.apache.hudi.common.util.ValidationUtils; | ||
import org.apache.log4j.LogManager; | ||
import org.apache.log4j.Logger; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
import java.io.BufferedReader; | ||
import java.io.File; | ||
import java.io.IOException; | ||
|
@@ -58,7 +61,8 @@ public class DFSPropertiesConfiguration { | |
// props read from hudi-defaults.conf | ||
private static TypedProperties GLOBAL_PROPS = loadGlobalProps(); | ||
|
||
private final FileSystem fs; | ||
@Nullable | ||
private final Configuration hadoopConfig; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general we can keep |
||
|
||
private Path currentFilePath; | ||
|
||
|
@@ -68,16 +72,16 @@ public class DFSPropertiesConfiguration { | |
// Keep track of files visited, to detect loops | ||
private final Set<String> visitedFilePaths; | ||
|
||
public DFSPropertiesConfiguration(FileSystem fs, Path filePath) { | ||
this.fs = fs; | ||
public DFSPropertiesConfiguration(@Nonnull Configuration hadoopConf, @Nonnull Path filePath) { | ||
this.hadoopConfig = hadoopConf; | ||
this.currentFilePath = filePath; | ||
this.hoodieConfig = new HoodieConfig(); | ||
this.visitedFilePaths = new HashSet<>(); | ||
addPropsFromFile(filePath); | ||
} | ||
|
||
public DFSPropertiesConfiguration() { | ||
this.fs = null; | ||
this.hadoopConfig = null; | ||
this.currentFilePath = null; | ||
this.hoodieConfig = new HoodieConfig(); | ||
this.visitedFilePaths = new HashSet<>(); | ||
|
@@ -119,13 +123,13 @@ public void addPropsFromFile(Path filePath) { | |
if (visitedFilePaths.contains(filePath.toString())) { | ||
throw new IllegalStateException("Loop detected; file " + filePath + " already referenced"); | ||
} | ||
FileSystem fileSystem; | ||
try { | ||
fileSystem = fs != null ? fs : filePath.getFileSystem(new Configuration()); | ||
} catch (IOException e) { | ||
throw new IllegalArgumentException("Cannot get the file system from file path", e); | ||
} | ||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(fileSystem.open(filePath)))) { | ||
|
||
FileSystem fs = FSUtils.getFs( | ||
filePath.toString(), | ||
Option.ofNullable(hadoopConfig).orElseGet(Configuration::new) | ||
); | ||
Comment on lines
+127
to
+130
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nsivabalan This is changed to get the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Most changes in this PR are related to this so just to make sure there is no hidden implication. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is called just once to load props from external file right? I mean, once per write operation. looks ok to me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FileSystem instance is also cached at the hadoop client level. so this itself may be ok. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Had to fix local file-system access (for properties), since it got broken after #3416 (we're passing Hadoop FS in ctor, and we're using to try to access local files) |
||
|
||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(fs.open(filePath)))) { | ||
visitedFilePaths.add(filePath.toString()); | ||
currentFilePath = filePath; | ||
addPropsFromStream(reader); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra space?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accidental