hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject hadoop git commit: HDFS-11027: libbhdfs++: Don't retry if there is an authentication failure. Contributed by Xiaowei Zhu.
Date Mon, 24 Oct 2016 14:49:35 GMT
Repository: hadoop
Updated Branches:
  refs/heads/HDFS-8707 4d33cb52a -> 4f3696d7e


HDFS-11027: libbhdfs++: Don't retry if there is an authentication failure.  Contributed by
Xiaowei Zhu.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/4f3696d7
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/4f3696d7
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/4f3696d7

Branch: refs/heads/HDFS-8707
Commit: 4f3696d7edfa49c7abc8bc54b1bcea8e42a81596
Parents: 4d33cb5
Author: James <jhc@apache.org>
Authored: Mon Oct 24 10:47:15 2016 -0400
Committer: James <jhc@apache.org>
Committed: Mon Oct 24 10:47:15 2016 -0400

----------------------------------------------------------------------
 .../src/main/native/libhdfspp/include/hdfspp/status.h  |  3 +++
 .../src/main/native/libhdfspp/lib/common/status.cc     | 13 ++++++++++++-
 .../src/main/native/libhdfspp/lib/rpc/rpc_engine.cc    |  4 +++-
 3 files changed, 18 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/4f3696d7/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/include/hdfspp/status.h
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/include/hdfspp/status.h
b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/include/hdfspp/status.h
index ffbb2bf..39cf8c6 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/include/hdfspp/status.h
+++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/include/hdfspp/status.h
@@ -62,6 +62,9 @@ class Status {
   // get error code
   int code() const { return code_; }
 
+  // if retry can possibly recover an error
+  bool notWorthRetry() const;
+
   enum Code {
     kOk = 0,
     kInvalidArgument = static_cast<unsigned>(std::errc::invalid_argument),

http://git-wip-us.apache.org/repos/asf/hadoop/blob/4f3696d7/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/status.cc
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/status.cc
b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/status.cc
index 540f8c1..15d304a 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/status.cc
+++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/status.cc
@@ -22,6 +22,7 @@
 #include <sstream>
 #include <cstring>
 #include <map>
+#include <set>
 
 namespace hdfs {
 
@@ -49,6 +50,12 @@ const static std::map<std::string, int> kKnownServerExceptionClasses
= {
                                             {kPathIsNotEmptyDirectoryException, Status::kPathIsNotEmptyDirectory}
                                         };
 
+// Errors that retry cannot fix. TODO: complete the list.
+const static std::set<int> noRetryExceptions = {
+  Status::kPermissionDenied,
+  Status::kAuthenticationFailed,
+  Status::kAccessControlException
+};
 
 Status::Status(int code, const char *msg1)
                : code_(code) {
@@ -120,7 +127,7 @@ Status Status::Exception(const char *exception_class_name, const char
*error_mes
 }
 
 Status Status::Error(const char *error_message) {
-  return Status(kAuthenticationFailed, error_message);
+  return Exception("Exception", error_message);
 }
 
 Status Status::AuthenticationFailed() {
@@ -147,4 +154,8 @@ std::string Status::ToString() const {
   return ss.str();
 }
 
+bool Status::notWorthRetry() const {
+    return noRetryExceptions.find(code_) != noRetryExceptions.end();
+}
+
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/4f3696d7/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/rpc/rpc_engine.cc
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/rpc/rpc_engine.cc
b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/rpc/rpc_engine.cc
index 72a0c55..7c280b8 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/rpc/rpc_engine.cc
+++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/rpc/rpc_engine.cc
@@ -322,7 +322,9 @@ void RpcEngine::RpcCommsError(
 
     RetryAction retry = RetryAction::fail(""); // Default to fail
 
-    if (retry_policy()) {
+    if (status.notWorthRetry()) {
+      retry = RetryAction::fail(status.ToString().c_str());
+    } else if (retry_policy()) {
       retry = retry_policy()->ShouldRetry(status, req->IncrementRetryCount(), req->get_failover_count(),
true);
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message