Hazelcast C++ Client
client_properties.h
1 /*
2  * Copyright (c) 2008-2021, Hazelcast, Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
18 #pragma once
19 
20 #include <string>
21 #include <unordered_map>
22 
23 #include "hazelcast/util/export.h"
24 #include "hazelcast/util/IOUtil.h"
25 
26 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
27 #pragma warning(push)
28 #pragma warning(disable: 4251) //for dll export
29 #endif
30 
31 namespace hazelcast {
32  namespace client {
33  class client_config;
34 
40  class HAZELCAST_API client_property {
41  public:
42  client_property(const std::string &name, const std::string &default_value);
43 
44  const std::string &get_name() const;
45 
46  const std::string &get_default_value() const;
47 
53  const char *get_system_property() const;
54 
55  private:
56  std::string name_;
57  std::string default_value_;
58  };
59 
60 
66  class HAZELCAST_API client_properties {
67  public:
68  client_properties(const std::unordered_map<std::string, std::string> &properties);
69 
70  const client_property& get_heartbeat_timeout() const;
71 
72  const client_property& get_heartbeat_interval() const;
73 
74  const client_property& get_aws_member_port() const;
75 
76  const client_property &get_clean_resources_period_millis() const;
77 
78  const client_property &get_invocation_retry_pause_millis() const;
79 
80  const client_property &get_invocation_timeout_seconds() const;
81 
82  const client_property &get_event_thread_count() const;
83 
84  const client_property &get_internal_executor_pool_size() const;
85 
86  const client_property &get_shuffle_member_list() const;
87 
88  const client_property &get_max_concurrent_invocations() const;
89 
90  const client_property &get_backpressure_backoff_timeout_millis() const;
91 
92  const client_property &get_statistics_enabled() const;
93 
94  const client_property &get_statistics_period_seconds() const;
95 
96  const client_property &backup_timeout_millis() const;
97 
98  const client_property &fail_on_indeterminate_state() const;
99 
108  static const std::string PROP_HEARTBEAT_TIMEOUT;
109  static const std::string PROP_HEARTBEAT_TIMEOUT_DEFAULT;
110 
117  static const std::string PROP_HEARTBEAT_INTERVAL;
118  static const std::string PROP_HEARTBEAT_INTERVAL_DEFAULT;
119 
129  static const std::string PROP_REQUEST_RETRY_COUNT;
130  static const std::string PROP_REQUEST_RETRY_COUNT_DEFAULT;
131 
141  static const std::string PROP_REQUEST_RETRY_WAIT_TIME;
142  static const std::string PROP_REQUEST_RETRY_WAIT_TIME_DEFAULT;
143 
149  static const std::string PROP_AWS_MEMBER_PORT;
150  static const std::string PROP_AWS_MEMBER_PORT_DEFAULT;
151 
155  static const std::string CLEAN_RESOURCES_PERIOD_MILLIS;
156  static const std::string CLEAN_RESOURCES_PERIOD_MILLIS_DEFAULT;
157 
161  static const std::string INVOCATION_RETRY_PAUSE_MILLIS;
162  static const std::string INVOCATION_RETRY_PAUSE_MILLIS_DEFAULT;
163 
174  static const std::string INVOCATION_TIMEOUT_SECONDS;
175  static const std::string INVOCATION_TIMEOUT_SECONDS_DEFAULT;
176 
180  static const std::string EVENT_THREAD_COUNT;
181  static const std::string EVENT_THREAD_COUNT_DEFAULT;
182 
183 
184  static const std::string INTERNAL_EXECUTOR_POOL_SIZE;
185  static const std::string INTERNAL_EXECUTOR_POOL_SIZE_DEFAULT;
186 
192  static const std::string SHUFFLE_MEMBER_LIST;
193  static const std::string SHUFFLE_MEMBER_LIST_DEFAULT;
194 
204  static const std::string MAX_CONCURRENT_INVOCATIONS;
205  static const std::string MAX_CONCURRENT_INVOCATIONS_DEFAULT;
206 
218  static const std::string BACKPRESSURE_BACKOFF_TIMEOUT_MILLIS;
219  static const std::string BACKPRESSURE_BACKOFF_TIMEOUT_MILLIS_DEFAULT;
220 
226  static const std::string STATISTICS_ENABLED;
227  static const std::string STATISTICS_ENABLED_DEFAULT;
228 
232  static const std::string STATISTICS_PERIOD_SECONDS;
233  static const std::string STATISTICS_PERIOD_SECONDS_DEFAULT;
234 
239  static constexpr const char * OPERATION_BACKUP_TIMEOUT_MILLIS = "hazelcast.client.operation.backup.timeout.millis";
240  static constexpr const char * OPERATION_BACKUP_TIMEOUT_MILLIS_DEFAULT = "5000";
241 
248  static constexpr const char * FAIL_ON_INDETERMINATE_OPERATION_STATE = "hazelcast.client.operation.fail.on.indeterminate.state";
249  static constexpr const char * FAIL_ON_INDETERMINATE_OPERATION_STATE_DEFAULT = "false";
250 
257  bool get_boolean(const client_property &property) const;
258 
265  int32_t get_integer(const client_property &property) const;
266 
273  int64_t get_long(const client_property &property) const;
274 
281  std::string get_string(const client_property &property) const;
282 
283  private:
284  client_property heartbeat_timeout_;
285  client_property heartbeat_interval_;
286  client_property retry_count_;
287  client_property retry_wait_time_;
288  client_property aws_member_port_;
289  client_property clean_resources_period_;
290  client_property invocation_retry_pause_millis_;
291  client_property invocation_timeout_seconds_;
292  client_property event_thread_count_;
293  client_property internal_executor_pool_size_;
294  client_property shuffle_member_list_;
295  client_property max_concurrent_invocations_;
296  client_property backpressure_backoff_timeout_millis_;
297  client_property statistics_enabled_;
298  client_property statistics_period_seconds_;
299  client_property backup_timeout_millis_;
300  client_property fail_on_indeterminate_state_;
301 
302  std::unordered_map<std::string, std::string> properties_map_;
303  };
304 
305  }
306 }
307 
308 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
309 #pragma warning(pop)
310 #endif
311 
312 
static const std::string STATISTICS_ENABLED
Use to enable the client statistics collection.
Definition: client_properties.h:226
static const std::string MAX_CONCURRENT_INVOCATIONS
The maximum number of concurrent invocations allowed.
Definition: client_properties.h:204
static const std::string PROP_REQUEST_RETRY_WAIT_TIME
Client will retry requests which either inherently retryable(idempotent client) or client_network_con...
Definition: client_properties.h:141
static const std::string BACKPRESSURE_BACKOFF_TIMEOUT_MILLIS
Control the maximum timeout in millis to wait for an invocation space to be available.
Definition: client_properties.h:218
static const std::string INVOCATION_RETRY_PAUSE_MILLIS
Pause time between each retry cycle of an invocation in milliseconds.
Definition: client_properties.h:161
static const std::string PROP_HEARTBEAT_TIMEOUT
Client will be sending heartbeat messages to members and this is the timeout.
Definition: client_properties.h:108
static const std::string PROP_REQUEST_RETRY_COUNT
Client will retry requests which either inherently retryable(idempotent client) or client_network_con...
Definition: client_properties.h:129
static const std::string PROP_AWS_MEMBER_PORT
The discovery mechanism will discover only IP addresses.
Definition: client_properties.h:149
static const std::string EVENT_THREAD_COUNT
Number of the threads to handle the incoming event packets.
Definition: client_properties.h:180
static const std::string STATISTICS_PERIOD_SECONDS
The period in seconds the statistics sent to the cluster.
Definition: client_properties.h:232
static const std::string CLEAN_RESOURCES_PERIOD_MILLIS
The period in milliseconds at which the resource cleaning is run (e.g.
Definition: client_properties.h:155
Definition: address.h:30
A client property is a configuration for hazelcast client.
Definition: client_properties.h:40
static const std::string SHUFFLE_MEMBER_LIST
Client shuffles the given member list to prevent all clients to connect to the same node when this pr...
Definition: client_properties.h:192
static const std::string INVOCATION_TIMEOUT_SECONDS
When an invocation gets an exception because :
Definition: client_properties.h:174
Client Properties is an internal class.
Definition: client_properties.h:66
static const std::string PROP_HEARTBEAT_INTERVAL
Time interval in milliseconds between the heartbeats sent by the client to the nodes.
Definition: client_properties.h:117