You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by pa...@apache.org on 2017/02/04 03:58:54 UTC

[4/8] drill git commit: DRILL-5220: Provide API to set application/client names in C++ connector

DRILL-5220: Provide API to set application/client names in C++ connector

Add method to DrillClientConfig to set the client and the application names
in the C++ connector.

Allow the ODBC driver (or any user of the C++ connector) to provide more
specific informations like the application using the client.

This closes #728


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/53ca55f9
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/53ca55f9
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/53ca55f9

Branch: refs/heads/master
Commit: 53ca55f91c40dcc488d6ecbd08b3e04907b62399
Parents: 63ae6cf
Author: Laurent Goujon <la...@dremio.com>
Authored: Wed Jan 25 10:52:31 2017 -0800
Committer: Parth Chandra <pc...@maprtech.com>
Committed: Fri Feb 3 17:41:44 2017 -0800

----------------------------------------------------------------------
 .../native/client/src/clientlib/drillClient.cpp | 22 ++++++++++
 .../client/src/clientlib/drillClientImpl.cpp    |  3 +-
 .../client/src/include/drill/drillClient.hpp    | 42 ++++++++++++++++++++
 3 files changed, 66 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/53ca55f9/contrib/native/client/src/clientlib/drillClient.cpp
----------------------------------------------------------------------
diff --git a/contrib/native/client/src/clientlib/drillClient.cpp b/contrib/native/client/src/clientlib/drillClient.cpp
index fe9c3a6..b456d17 100644
--- a/contrib/native/client/src/clientlib/drillClient.cpp
+++ b/contrib/native/client/src/clientlib/drillClient.cpp
@@ -52,6 +52,8 @@ int32_t DrillClientConfig::s_socketTimeout=0;
 int32_t DrillClientConfig::s_handshakeTimeout=5;
 int32_t DrillClientConfig::s_queryTimeout=180;
 int32_t DrillClientConfig::s_heartbeatFrequency=15; // 15 seconds
+std::string DrillClientConfig::s_clientName(DRILL_CONNECTOR_NAME);
+std::string DrillClientConfig::s_applicationName;
 
 boost::mutex DrillClientConfig::s_mutex;
 
@@ -136,6 +138,26 @@ logLevel_t DrillClientConfig::getLogLevel(){
     return s_logLevel;
 }
 
+const std::string& DrillClientConfig::getClientName() {
+	boost::lock_guard<boost::mutex> configLock(DrillClientConfig::s_mutex);
+	return s_clientName;
+}
+
+void DrillClientConfig::setClientName(const std::string& name) {
+	boost::lock_guard<boost::mutex> configLock(DrillClientConfig::s_mutex);
+	s_clientName = name;
+}
+
+const std::string& DrillClientConfig::getApplicationName() {
+	boost::lock_guard<boost::mutex> configLock(DrillClientConfig::s_mutex);
+	return s_applicationName;
+}
+
+void DrillClientConfig::setApplicationName(const std::string& name) {
+	boost::lock_guard<boost::mutex> configLock(DrillClientConfig::s_mutex);
+	s_applicationName = name;
+}
+
 //Using boost assign to initialize maps. 
 const std::map<std::string, uint32_t>  DrillUserProperties::USER_PROPERTIES=boost::assign::map_list_of
     ( USERPROP_USERNAME,    USERPROP_FLAGS_SERVERPROP|USERPROP_FLAGS_USERNAME|USERPROP_FLAGS_STRING )

http://git-wip-us.apache.org/repos/asf/drill/blob/53ca55f9/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 038ca90..8794044 100644
--- a/contrib/native/client/src/clientlib/drillClientImpl.cpp
+++ b/contrib/native/client/src/clientlib/drillClientImpl.cpp
@@ -351,7 +351,8 @@ connectionStatus_t DrillClientImpl::validateHandshake(DrillUserProperties* prope
 
     // Adding version info
     exec::user::RpcEndpointInfos* infos = u2b.mutable_client_infos();
-    infos->set_name(DRILL_CONNECTOR_NAME);
+    infos->set_name(DrillClientConfig::getClientName());
+    infos->set_application(DrillClientConfig::getApplicationName());
     infos->set_version(DRILL_VERSION_STRING);
     infos->set_majorversion(DRILL_VERSION_MAJOR);
     infos->set_minorversion(DRILL_VERSION_MINOR);

http://git-wip-us.apache.org/repos/asf/drill/blob/53ca55f9/contrib/native/client/src/include/drill/drillClient.hpp
----------------------------------------------------------------------
diff --git a/contrib/native/client/src/include/drill/drillClient.hpp b/contrib/native/client/src/include/drill/drillClient.hpp
index 29ae6c2..00ff723 100644
--- a/contrib/native/client/src/include/drill/drillClient.hpp
+++ b/contrib/native/client/src/include/drill/drillClient.hpp
@@ -91,6 +91,43 @@ class DECLSPEC_DRILL_CLIENT DrillClientConfig{
         static int32_t getQueryTimeout();
         static int32_t getHeartbeatFrequency();
         static logLevel_t getLogLevel();
+
+        /**
+         * Return the client name sent to the server when connecting
+         *
+         * @return the current client name
+         */
+        static const std::string& getClientName();
+
+        /**
+         * Set the client name to be sent to the server when connecting.
+         *
+         * Only new connections will use the new value. Existing connections
+         * will be left unchanged.
+         *
+         * @param name the name to be send to the server
+         */
+        static void setClientName(const std::string& name);
+
+        /**
+         * Return the application name sent to the server when connecting
+         *
+         * @return the current application name
+         */
+        static const std::string& getApplicationName();
+
+        /**
+         * Set the application name to be sent to the server when connecting.
+         *
+         * Only new connections will use the new value. Existing connections
+         * will be left unchanged.
+         *
+         * @param name the name to be send to the server
+         */
+        static void setApplicationName(const std::string& name);
+
+
+
     private:
         // The logging level
         static logLevel_t s_logLevel;
@@ -122,6 +159,11 @@ class DECLSPEC_DRILL_CLIENT DrillClientConfig{
         static int32_t s_queryTimeout;
         static int32_t s_heartbeatFrequency;
         static boost::mutex s_mutex;
+
+        // The client name (default to DRILL_CONNECTOR_NAME)
+        static std::string s_clientName;
+        // The application name (default to <empty>)
+        static std::string s_applicationName;
 };