aboutsummaryrefslogtreecommitdiff
path: root/contrib/native/client/src/include/drill/drillConfig.hpp
blob: 669267d86421e920442c9d41f32999e10bc12df0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


#ifndef DRILL_CONFIG_H
#define DRILL_CONFIG_H

#include "drill/common.hpp"
#include <boost/thread.hpp>



#if defined _WIN32 || defined __CYGWIN__
  #ifdef DRILL_CLIENT_EXPORTS
      #define DECLSPEC_DRILL_CLIENT __declspec(dllexport)
  #else
    #ifdef USE_STATIC_LIBDRILL
      #define DECLSPEC_DRILL_CLIENT
    #else
      #define DECLSPEC_DRILL_CLIENT  __declspec(dllimport)
    #endif
  #endif
#else
  #if __GNUC__ >= 4
    #define DECLSPEC_DRILL_CLIENT __attribute__ ((visibility ("default")))
  #else
    #define DECLSPEC_DRILL_CLIENT
  #endif
#endif

namespace exec{
    namespace shared{
        class DrillPBError;
    };
};

namespace Drill{

// Only one instance of this class exists. A static member of DrillClientImpl;
 
class DECLSPEC_DRILL_CLIENT DrillClientConfig{
    public:
        DrillClientConfig();
        ~DrillClientConfig();
        static void initLogging(const char* path);
        static void setLogLevel(logLevel_t l);
        static void setSaslPluginPath(const char* path);
        static const char* getSaslPluginPath();
        static void setBufferLimit(uint64_t l);
        static uint64_t getBufferLimit();
        static void setSocketTimeout(int32_t l);
        static void setHandshakeTimeout(int32_t l);
        static void setQueryTimeout(int32_t l);
        static void setHeartbeatFrequency(int32_t l);
        static int32_t getSocketTimeout();
        static int32_t getHandshakeTimeout();
        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;
        // The total amount of memory to be allocated by an instance of DrillClient.
        // For future use. Currently, not enforced.
        static uint64_t s_bufferLimit;

        static const char* s_saslPluginPath;

        /**
         * DrillClient configures timeout (in seconds) in a fine granularity.
         * Disabled by setting the value to zero.
         *
         * s_socketTimout: (default 0)
         *      set SO_RCVTIMEO and SO_SNDTIMEO socket options and place a
         *		timeout on socket receives and sends. It is disabled by default.
         *
         * s_handshakeTimeout: (default 5)
         *      place a timeout on validating handshake. When an endpoint (host:port)
         *		is reachable but drillbit hangs or running another service. It will
         *		avoid the client hanging.
         *
         * s_queryTimeout: (default 180)
         *      place a timeout on waiting result of querying.
         *
         * s_heartbeatFrequency: (default 30)
         *      Seconds of idle activity after which a heartbeat is sent to the drillbit
         */
        static int32_t s_socketTimeout;
        static int32_t s_handshakeTimeout;
        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;
};



} // namespace Drill

#endif