Xuanwo commented on code in PR #3933:
URL:
https://github.com/apache/incubator-opendal/pull/3933#discussion_r1453507148
##########
core/Cargo.toml:
##########
@@ -328,6 +329,8 @@ suppaftp = { version = "5.2", default-features = false,
features = [
], optional = true }
# for services-tikv
tikv-client = { version = "0.3.0", optional = true, default-features = false }
+# for services-hdfs-native
+hdfs-native = { version = "0.6.0"}
Review Comment:
Please add `optional = true` and enable it in `services-hdfs-native` so we
won't enable this feature by default.
##########
core/src/raw/hdfs_native_error_util.rs:
##########
@@ -0,0 +1,65 @@
+// 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.
+
+use crate::*;
+use hdfs_native::HdfsError;
+
+/// Parse hdfs-native error into opendal::Error.
+pub fn parse_hdfs_error(hdfs_error: HdfsError) -> Error {
+ let (kind, retryable, msg) = match &hdfs_error {
+ HdfsError::IOError(err) => (ErrorKind::Unexpected, false,
err.to_string()),
+ HdfsError::DataTransferError(msg) => (ErrorKind::Unexpected, false,
msg.clone()),
+ HdfsError::ChecksumError => (
+ ErrorKind::Unexpected,
+ false,
+ "checksums didn't match".to_string(),
+ ),
+ HdfsError::InvalidPath(msg) => (ErrorKind::InvalidInput, false,
msg.clone()),
+ HdfsError::InvalidArgument(msg) => (ErrorKind::InvalidInput, false,
msg.clone()),
+ HdfsError::UrlParseError(err) => (ErrorKind::Unexpected, false,
err.to_string()),
+ HdfsError::AlreadyExists(msg) => (ErrorKind::AlreadyExists, false,
msg.clone()),
+ HdfsError::OperationFailed(msg) => (ErrorKind::Unexpected, false,
msg.clone()),
+ HdfsError::FileNotFound(msg) => (ErrorKind::NotFound, false,
msg.clone()),
+ HdfsError::BlocksNotFound(msg) => (ErrorKind::NotFound, false,
msg.clone()),
+ HdfsError::IsADirectoryError(msg) => (ErrorKind::IsADirectory, false,
msg.clone()),
+ HdfsError::UnsupportedErasureCodingPolicy(msg) => {
+ (ErrorKind::Unsupported, false, msg.clone())
+ }
+ HdfsError::ErasureCodingError(msg) => (ErrorKind::Unexpected, false,
msg.clone()),
+ HdfsError::UnsupportedFeature(msg) => (ErrorKind::Unsupported, false,
msg.clone()),
+ HdfsError::InternalError(msg) => (ErrorKind::Unexpected, false,
msg.clone()),
Review Comment:
We don't need to list all errors out, we can convert errors we unexpected by
`_ => (ErrorKind::Unexpected, false, "unexpected error from hdfs"),`
##########
core/src/raw/mod.rs:
##########
@@ -62,6 +62,9 @@ pub use tokio_util::*;
mod std_io_util;
pub use std_io_util::*;
+mod hdfs_native_error_util;
Review Comment:
Please keep those error handling logic in `hdfs_native` mod instead.
--
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]