From 3db261d45bab46759f4049675483633822b1d090 Mon Sep 17 00:00:00 2001 From: James Clampffer Date: Mon, 10 Jul 2017 14:23:13 -0400 Subject: [PATCH] HDFS-12103: libhdfs++: Provide workaround to support cancel on filesystem connect until HDFS-11437 is resolved. Contributed by James Clampffer. --- .../src/main/native/libhdfspp/lib/fs/filesystem.cc | 10 ++++++---- .../src/main/native/libhdfspp/lib/rpc/rpc_engine.cc | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filesystem.cc b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filesystem.cc index 9ef3aa0950..761ff86076 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filesystem.cc +++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filesystem.cc @@ -288,14 +288,16 @@ int FileSystemImpl::WorkerThreadCount() { } bool FileSystemImpl::CancelPendingConnect() { + 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; } - if(connect_callback_.IsCallbackAccessed()) { - LOG_DEBUG(kFileSystem, << "FileSystemImpl@" << this << "::CancelPendingConnect called after Connect completed"); - return false; - } // First invoke callback, then do proper teardown in RpcEngine and RpcConnection ConnectCallback noop_callback = [](const Status &stat, FileSystem *fs) { 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 98c41dad1f..ba5556531f 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 @@ -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);