You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by zh...@apache.org on 2026/04/21 09:27:59 UTC
(seatunnel) branch dev updated: [Improve][Connector-v2][File] error handling for file and directory operations in HadoopFileSystemProxy (#10433)
This is an automated email from the ASF dual-hosted git repository.
Carl-Zhou-CN pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/seatunnel.git
The following commit(s) were added to refs/heads/dev by this push:
new 52bf50cadb [Improve][Connector-v2][File] error handling for file and directory operations in HadoopFileSystemProxy (#10433)
52bf50cadb is described below
commit 52bf50cadb78addd43d67f3ae5be57c1f25e3c02
Author: Jast <sh...@apache.org>
AuthorDate: Tue Apr 21 17:27:52 2026 +0800
[Improve][Connector-v2][File] error handling for file and directory operations in HadoopFileSystemProxy (#10433)
---
.../file/hadoop/HadoopFileSystemProxy.java | 87 +++++++++++++++++++---
1 file changed, 78 insertions(+), 9 deletions(-)
diff --git a/seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/hadoop/HadoopFileSystemProxy.java b/seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/hadoop/HadoopFileSystemProxy.java
index cdee0214ec..db067cac1f 100644
--- a/seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/hadoop/HadoopFileSystemProxy.java
+++ b/seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/hadoop/HadoopFileSystemProxy.java
@@ -105,11 +105,11 @@ public class HadoopFileSystemProxy implements Serializable, Closeable {
if (!fileExist(oldPath.toString())) {
log.warn(
- "rename file :["
- + oldPath
- + "] to ["
- + newPath
- + "] already finished in the last commit, skip");
+ "rename file:[{}] to [{}] already finished in the last commit, skip. "
+ + "WARNING: In cluster mode with LocalFile without shared storage, "
+ + "the file may not be actually synced successfully, but the status shows success.",
+ oldPath,
+ newPath);
return Void.class;
}
@@ -137,10 +137,19 @@ public class HadoopFileSystemProxy implements Serializable, Closeable {
execute(
() -> {
Path dfs = new Path(filePath);
- if (!getFileSystem().mkdirs(dfs)) {
- throw CommonError.fileOperationFailed("SeaTunnel", "create", filePath);
+ FileSystem fs = getFileSystem();
+
+ if (fs.mkdirs(dfs)) {
+ return Void.class;
}
- return Void.class;
+
+ if (fs.exists(dfs)) {
+ return Void.class;
+ }
+
+ IOException enhanced = enhanceMkdirsException(fs, dfs, "create directory");
+ throw CommonError.fileOperationFailed(
+ "SeaTunnel", "create", filePath, enhanced);
});
}
@@ -194,7 +203,20 @@ public class HadoopFileSystemProxy implements Serializable, Closeable {
}
public FSDataOutputStream getOutputStream(String filePath) throws IOException {
- return execute(() -> getFileSystem().create(new Path(filePath), true));
+ return execute(
+ () -> {
+ Path path = new Path(filePath);
+ FileSystem fs = getFileSystem();
+ try {
+ return fs.create(path, true);
+ } catch (IOException e) {
+ IOException enhanced =
+ enhanceMkdirsException(
+ fs, path.getParent(), "create file " + path.getName(), e);
+ throw CommonError.fileOperationFailed(
+ "SeaTunnel", "create", filePath, enhanced);
+ }
+ });
}
public FSDataInputStream getInputStream(String filePath) throws IOException {
@@ -267,6 +289,53 @@ public class HadoopFileSystemProxy implements Serializable, Closeable {
return configuration;
}
+ private IOException enhanceMkdirsException(FileSystem fs, Path path, String operation)
+ throws IOException {
+ return enhanceMkdirsException(fs, path, operation, null);
+ }
+
+ private IOException enhanceMkdirsException(
+ FileSystem fs, Path path, String operation, IOException cause) throws IOException {
+ StringBuilder reason = new StringBuilder();
+
+ if (!fs.exists(path)) {
+ Path parent = path.getParent();
+ if (parent != null && !fs.exists(parent)) {
+ reason.append("Parent directory does not exist: ").append(parent).append(". ");
+ } else {
+ reason.append("Directory does not exist and creation failed: ")
+ .append(path)
+ .append(". ");
+ }
+
+ try {
+ fs.getFileStatus(path);
+ } catch (IOException e) {
+ if (e.getMessage() != null) {
+ if (e.getMessage().contains("Permission denied")) {
+ reason.append("Permission denied. ");
+ } else {
+ reason.append("Hadoop error: ").append(e.getMessage()).append(". ");
+ }
+ }
+ }
+ } else {
+ reason.append("Path exists but may be inaccessible: ").append(path).append(". ");
+ }
+
+ reason.append("Operation: ")
+ .append(operation)
+ .append(". ")
+ .append("Current working directory: ")
+ .append(fs.getWorkingDirectory());
+
+ IOException enhanced = new IOException(reason.toString());
+ if (cause != null) {
+ enhanced.addSuppressed(cause);
+ }
+ return enhanced;
+ }
+
private boolean enableKerberos() {
boolean kerberosPrincipalEmpty = StringUtils.isBlank(hadoopConf.getKerberosPrincipal());
boolean kerberosKeytabPathEmpty = StringUtils.isBlank(hadoopConf.getKerberosKeytabPath());