瀏覽代碼

HDFS-11014: libhdfs++: Make connection to HA clusters faster. Contributed by James Clampffer.

James 8 年之前
父節點
當前提交
a87e92cb5a

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/include/hdfspp/options.h

@@ -96,7 +96,7 @@ struct Options {
    * Client failover attempts before failover gives up
    **/
   int failover_max_retries;
-  static const unsigned int kDefaultFailoverMaxRetries = 15;
+  static const unsigned int kDefaultFailoverMaxRetries = 4;
 
   /**
    * Client failover attempts before failover gives up if server

+ 6 - 1
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/retry_policy.cc

@@ -60,7 +60,12 @@ RetryAction FixedDelayWithFailover::ShouldRetry(const Status &s, uint64_t retrie
   {
     // Try connecting to another NN in case this one keeps timing out
     // Can add the backoff wait specified by dfs.client.failover.sleep.base.millis here
-    return RetryAction::failover(delay_);
+    if(failovers == 0) {
+      // No delay on first failover if it looks like the NN was bad.
+      return RetryAction::failover(0);
+    } else {
+      return RetryAction::failover(delay_);
+    }
   }
 
   if(retries < max_retries_ && failovers < max_failover_retries_) {

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/rpc/rpc_engine.cc

@@ -365,7 +365,7 @@ void RpcEngine::RpcCommsError(
         ResolvedNamenodeInfo new_active_nn_info =
             ha_persisted_info_->GetFailoverAndUpdate(last_endpoints_[0]/*reverse lookup*/);
 
-        LOG_INFO(kRPC, << "Going to try connecting to alternate Datanode: " << new_active_nn_info.uri.str());
+        LOG_INFO(kRPC, << "Going to try connecting to alternate Namenode: " << new_active_nn_info.uri.str());
 
         if(ha_persisted_info_->is_resolved()) {
           last_endpoints_ = new_active_nn_info.endpoints;