Browse Source

HDFS-12103: libhdfs++: Provide workaround to support cancel on filesystem connect until HDFS-11437 is resolved. Contributed by James Clampffer.

James Clampffer 7 năm trước cách đây
mục cha
commit
0c33214be1

+ 6 - 4
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filesystem.cc

@@ -288,12 +288,14 @@ int FileSystemImpl::WorkerThreadCount() {
 }
 
 bool FileSystemImpl::CancelPendingConnect() {
-  if(!connect_callback_.IsCallbackSet()) {
-    LOG_DEBUG(kFileSystem, << "FileSystemImpl@" << this << "::CancelPendingConnect called before Connect started");
-    return false;
-  }
   if(connect_callback_.IsCallbackAccessed()) {
+    // Temp fix for failover hangs, allow CancelPendingConnect to be called so it can push a flag through the RPC engine
     LOG_DEBUG(kFileSystem, << "FileSystemImpl@" << this << "::CancelPendingConnect called after Connect completed");
+    return nn_.CancelPendingConnect();
+  }
+
+  if(!connect_callback_.IsCallbackSet()) {
+    LOG_DEBUG(kFileSystem, << "FileSystemImpl@" << this << "::CancelPendingConnect called before Connect started");
     return false;
   }
 

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

@@ -220,7 +220,9 @@ void RpcEngine::RpcCommsError(
 
     RetryAction retry = RetryAction::fail(""); // Default to fail
 
-    if (status.notWorthRetry()) {
+    if(connect_canceled_) {
+      retry = RetryAction::fail("Operation canceled");
+    } else 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);