Red Hat Data Grid HotRod C++ Client  7.2.0
Configuration.h
Go to the documentation of this file.
1 #ifndef ISPN_HOTROD_CONFIGURATION_H
2 #define ISPN_HOTROD_CONFIGURATION_H
3 
4 
5 
6 #include <string>
7 #include <vector>
8 #include <map>
16 
17 
18 namespace infinispan {
19 namespace hotrod {
20 
27 // TODO: should we really return references?
29 {
30  public:
31  HR_EXTERN static const char* PROTOCOL_VERSION_10;
32  HR_EXTERN static const char* PROTOCOL_VERSION_11;
33  HR_EXTERN static const char* PROTOCOL_VERSION_12;
34  HR_EXTERN static const char* PROTOCOL_VERSION_13;
35  HR_EXTERN static const char* PROTOCOL_VERSION_20;
36  HR_EXTERN static const char* PROTOCOL_VERSION_21;
37  HR_EXTERN static const char* PROTOCOL_VERSION_22;
38  HR_EXTERN static const char* PROTOCOL_VERSION_23;
39  HR_EXTERN static const char* PROTOCOL_VERSION_24;
40  HR_EXTERN static const char* PROTOCOL_VERSION_25;
41  HR_EXTERN static const char* PROTOCOL_VERSION_26;
42  HR_EXTERN static const char* DEFAULT_CLUSTER_NAME;
43 
44 
45  Configuration(const std::string &_protocolVersion,
46  const ConnectionPoolConfiguration& _connectionPoolConfiguration,
47  int _connectionTimeout,
48  bool _forceReturnValue,
49  int _keySizeEstimate,
50  std::map<std::string,std::vector<ServerConfiguration> > _serversConfiguration,
51  int _socketTimeout,
52  const SslConfiguration _sslConfiguration,
53  bool _tcpNoDelay,
54  int _valueSizeEstimate,
55  int _maxRetries,
56  NearCacheConfiguration _nearCacheConfiguration,
58  const event::EventMarshaller &eventMarshaller = event::JBasicEventMarshaller()):
59  protocolVersion(_protocolVersion), protocolVersionPtr(),
60  connectionPoolConfiguration(_connectionPoolConfiguration),
61  connectionTimeout(_connectionTimeout), forceReturnValue(_forceReturnValue),
62  keySizeEstimate(_keySizeEstimate),
63  serversMap(_serversConfiguration),
64  socketTimeout(_socketTimeout), securityConfiguration(_sslConfiguration),tcpNoDelay(_tcpNoDelay),
65  valueSizeEstimate(_valueSizeEstimate), maxRetries(_maxRetries), nearCacheConfiguration(_nearCacheConfiguration), balancingStrategyProducer(bsp),
66  eventMarshaller(eventMarshaller)
67  {}
68 
69  Configuration(const std::string &_protocolVersion,
70  const ConnectionPoolConfiguration& _connectionPoolConfiguration,
71  int _connectionTimeout,
72  bool _forceReturnValue,
73  int _keySizeEstimate,
74  std::map<std::string,std::vector<ServerConfiguration> > _serversConfiguration,
75  int _socketTimeout,
76  const SecurityConfiguration _securityConfiguration,
77  bool _tcpNoDelay,
78  int _valueSizeEstimate,
79  int _maxRetries,
80  NearCacheConfiguration _nearCacheConfiguration,
82  const event::EventMarshaller &eventMarshaller = event::JBasicEventMarshaller()):
83  protocolVersion(_protocolVersion), protocolVersionPtr(),
84  connectionPoolConfiguration(_connectionPoolConfiguration),
85  connectionTimeout(_connectionTimeout), forceReturnValue(_forceReturnValue),
86  keySizeEstimate(_keySizeEstimate),
87  serversMap(_serversConfiguration),
88  socketTimeout(_socketTimeout), securityConfiguration(_securityConfiguration),tcpNoDelay(_tcpNoDelay),
89  valueSizeEstimate(_valueSizeEstimate), maxRetries(_maxRetries), nearCacheConfiguration(_nearCacheConfiguration), balancingStrategyProducer(bsp),
90  eventMarshaller(eventMarshaller)
91  {}
92 
93 
98  HR_EXTERN const std::string &getProtocolVersion() const {
99  if (protocolVersionPtr.get() == NULL) {
100  const_cast<Configuration *>(this)->protocolVersionPtr
101  .reset(new std::string(protocolVersion.c_str()));
102  }
103  return *(protocolVersionPtr.get());
104  }
105 
111  HR_EXTERN const char *getProtocolVersionCString() const;
112 
119 
125  HR_EXTERN const int& getConnectionTimeout() const;
126 
134  HR_EXTERN const bool& isForceReturnValue() const;
135 
141  HR_EXTERN const int& getKeySizeEstimate() const;
142 
149  std::map<std::string, std::vector<ServerConfiguration> > getServersMapConfiguration() const {
150  std::map<std::string, std::vector<ServerConfiguration> > temp;
151  return serversMap;
152  }
153 
159  HR_EXTERN const int& getSocketTimeout() const;
160 
167 
173  HR_EXTERN const bool& isTcpNoDelay() const;
174 
180  HR_EXTERN const int& getValueSizeEstimate() const;
181 
187  HR_EXTERN const int& getMaxRetries() const;
188 
190 
191  const SslConfiguration& getSslConfiguration() { return securityConfiguration.getSslConfiguration(); }
192 
193  HR_EXTERN const event::EventMarshaller &getEventMarshaller() const;
194 
195  const NearCacheConfiguration& getNearCacheConfiguration() const { return nearCacheConfiguration; }
196 
197  const SecurityConfiguration& getSecurityConfiguration() const { return securityConfiguration; }
198 
199 private:
200  std::string protocolVersion;
201  std::shared_ptr<std::string> protocolVersionPtr;
202  ConnectionPoolConfiguration connectionPoolConfiguration;
203  int connectionTimeout;
204  bool forceReturnValue;
205  int keySizeEstimate;
206  std::map<std::string,std::vector<ServerConfiguration> > serversMap;
207  int socketTimeout;
208  SecurityConfiguration securityConfiguration;
209  bool tcpNoDelay;
210  int valueSizeEstimate;
211  int maxRetries;
212  const NearCacheConfiguration nearCacheConfiguration;
213  FailOverRequestBalancingStrategy::ProducerFn balancingStrategyProducer;
214  const event::EventMarshaller &eventMarshaller;
215 
216  static void deleteString(std::string *str) { delete str; }
217 };
218 
219 }} // namespace
220 
221 #endif /* ISPN_HOTROD_CONFIGURATION_H */
static HR_EXTERN const char * PROTOCOL_VERSION_10
Definition: Configuration.h:31
const NearCacheConfiguration & getNearCacheConfiguration() const
Definition: Configuration.h:195
HR_EXTERN const event::EventMarshaller & getEventMarshaller() const
static HR_EXTERN const char * PROTOCOL_VERSION_20
Definition: Configuration.h:35
const SecurityConfiguration & getSecurityConfiguration() const
Definition: Configuration.h:197
static HR_EXTERN const char * PROTOCOL_VERSION_13
Definition: Configuration.h:34
HR_EXTERN const int & getSocketTimeout() const
HR_EXTERN const int & getValueSizeEstimate() const
#define HR_EXTERN
Definition: ImportExport.h:35
static HR_EXTERN const char * PROTOCOL_VERSION_21
Definition: Configuration.h:36
static HR_EXTERN const char * PROTOCOL_VERSION_23
Definition: Configuration.h:38
Definition: NearCacheConfiguration.h:32
Configuration(const std::string &_protocolVersion, const ConnectionPoolConfiguration &_connectionPoolConfiguration, int _connectionTimeout, bool _forceReturnValue, int _keySizeEstimate, std::map< std::string, std::vector< ServerConfiguration > > _serversConfiguration, int _socketTimeout, const SslConfiguration _sslConfiguration, bool _tcpNoDelay, int _valueSizeEstimate, int _maxRetries, NearCacheConfiguration _nearCacheConfiguration, FailOverRequestBalancingStrategy::ProducerFn bsp=0, const event::EventMarshaller &eventMarshaller=event::JBasicEventMarshaller())
Definition: Configuration.h:45
HR_EXTERN const int & getKeySizeEstimate() const
static HR_EXTERN const char * PROTOCOL_VERSION_26
Definition: Configuration.h:41
static HR_EXTERN const char * PROTOCOL_VERSION_11
Definition: Configuration.h:32
static HR_EXTERN const char * PROTOCOL_VERSION_24
Definition: Configuration.h:39
Definition: AuthenticationConfiguration.h:10
HR_EXTERN const int & getMaxRetries() const
HR_EXTERN const SslConfiguration & getSslConfiguration() const
HR_EXTERN const std::string & getProtocolVersion() const
Definition: Configuration.h:98
HR_EXTERN const bool & isForceReturnValue() const
Definition: SslConfiguration.h:10
HR_EXTERN const int & getConnectionTimeout() const
Definition: Configuration.h:28
static HR_EXTERN const char * PROTOCOL_VERSION_22
Definition: Configuration.h:37
FailOverRequestBalancingStrategy *(* ProducerFn)()
Definition: FailOverRequestBalancingStrategy.h:19
HR_EXTERN const char * getProtocolVersionCString() const
std::map< std::string, std::vector< ServerConfiguration > > getServersMapConfiguration() const
Definition: Configuration.h:149
HR_EXTERN const bool & isTcpNoDelay() const
static HR_EXTERN const char * PROTOCOL_VERSION_12
Definition: Configuration.h:33
const SslConfiguration & getSslConfiguration()
Definition: Configuration.h:191
Definition: SecurityConfiguration.h:16
static HR_EXTERN const char * DEFAULT_CLUSTER_NAME
Definition: Configuration.h:42
HR_EXTERN const ConnectionPoolConfiguration & getConnectionPoolConfiguration() const
static HR_EXTERN const char * PROTOCOL_VERSION_25
Definition: Configuration.h:40
Configuration(const std::string &_protocolVersion, const ConnectionPoolConfiguration &_connectionPoolConfiguration, int _connectionTimeout, bool _forceReturnValue, int _keySizeEstimate, std::map< std::string, std::vector< ServerConfiguration > > _serversConfiguration, int _socketTimeout, const SecurityConfiguration _securityConfiguration, bool _tcpNoDelay, int _valueSizeEstimate, int _maxRetries, NearCacheConfiguration _nearCacheConfiguration, FailOverRequestBalancingStrategy::ProducerFn bsp=0, const event::EventMarshaller &eventMarshaller=event::JBasicEventMarshaller())
Definition: Configuration.h:69
Definition: ConnectionPoolConfiguration.h:21
const SslConfiguration & getSslConfiguration() const
Definition: SecurityConfiguration.h:23
HR_EXTERN FailOverRequestBalancingStrategy::ProducerFn getBalancingStrategy() const