DRILL-2307: Detect DNS name resolution failure for better error messages
Project: http://git-wip-us.apache.org/repos/asf/drill/repo Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/c7cf8839 Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/c7cf8839 Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/c7cf8839 Branch: refs/heads/master Commit: c7cf88391f0bdae891f491c83ab96bfbedac9f97 Parents: bebfe8a Author: Norris Lee <norr...@simba.com> Authored: Tue Feb 24 17:37:42 2015 -0800 Committer: Parth Chandra <pchan...@maprtech.com> Committed: Tue Mar 24 12:12:19 2015 -0700 ---------------------------------------------------------------------- contrib/native/client/src/clientlib/drillClientImpl.cpp | 4 ++++ contrib/native/client/src/include/drill/common.hpp | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/drill/blob/c7cf8839/contrib/native/client/src/clientlib/drillClientImpl.cpp ---------------------------------------------------------------------- diff --git a/contrib/native/client/src/clientlib/drillClientImpl.cpp b/contrib/native/client/src/clientlib/drillClientImpl.cpp index d14119d..71f960e 100644 --- a/contrib/native/client/src/clientlib/drillClientImpl.cpp +++ b/contrib/native/client/src/clientlib/drillClientImpl.cpp @@ -141,6 +141,10 @@ connectionStatus_t DrillClientImpl::connect(const char* host, const char* port){ } }catch(std::exception e){ + // Handle case when the hostname cannot be resolved. "resolve" is hard-coded in boost asio resolver.resolve + if (!strcmp(e.what(), "resolve")) { + return handleConnError(CONN_HOSTNAME_RESOLUTION_ERROR, getMessage(ERR_CONN_EXCEPT, e.what())); + } return handleConnError(CONN_FAILURE, getMessage(ERR_CONN_EXCEPT, e.what())); } http://git-wip-us.apache.org/repos/asf/drill/blob/c7cf8839/contrib/native/client/src/include/drill/common.hpp ---------------------------------------------------------------------- diff --git a/contrib/native/client/src/include/drill/common.hpp b/contrib/native/client/src/include/drill/common.hpp index dbfa6fe..6560692 100644 --- a/contrib/native/client/src/include/drill/common.hpp +++ b/contrib/native/client/src/include/drill/common.hpp @@ -106,7 +106,8 @@ typedef enum{ CONN_HANDSHAKE_FAILED=2, CONN_INVALID_INPUT=3, CONN_ZOOKEEPER_ERROR=4, - CONN_HANDSHAKE_TIMEOUT=5 + CONN_HANDSHAKE_TIMEOUT=5, + CONN_HOSTNAME_RESOLUTION_ERROR=6 } connectionStatus_t; typedef enum{