Hazelcast C++ Client
Hazelcast C++ Client Library
client_properties.h
1 /*
2  * Copyright (c) 2008-2022, 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 #pragma once
18 
19 #include <string>
20 #include <unordered_map>
21 
22 #include "hazelcast/util/export.h"
23 #include "hazelcast/util/IOUtil.h"
24 
25 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
26 #pragma warning(push)
27 #pragma warning(disable : 4251) // for dll export
28 #endif
29 
30 namespace hazelcast {
31 namespace client {
32 class client_config;
33 
39 class HAZELCAST_API client_property
40 {
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 
54  const char* get_system_property() const;
55 
56 private:
57  std::string name_;
58  std::string default_value_;
59 };
60 
66 class HAZELCAST_API client_properties
67 {
68 public:
70  const std::unordered_map<std::string, std::string>& properties);
71 
72  const client_property& get_heartbeat_timeout() const;
73 
74  const client_property& get_heartbeat_interval() const;
75 
76  const client_property& get_aws_member_port() 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 
100  const client_property& cloud_base_url() const;
101 
111  static const std::string PROP_HEARTBEAT_TIMEOUT;
112  static const std::string PROP_HEARTBEAT_TIMEOUT_DEFAULT;
113 
121  static const std::string PROP_HEARTBEAT_INTERVAL;
122  static const std::string PROP_HEARTBEAT_INTERVAL_DEFAULT;
123 
133  static const std::string PROP_REQUEST_RETRY_COUNT;
134  static const std::string PROP_REQUEST_RETRY_COUNT_DEFAULT;
135 
145  static const std::string PROP_REQUEST_RETRY_WAIT_TIME;
146  static const std::string PROP_REQUEST_RETRY_WAIT_TIME_DEFAULT;
147 
155  static const std::string PROP_AWS_MEMBER_PORT;
156  static const std::string PROP_AWS_MEMBER_PORT_DEFAULT;
157 
161  static const std::string INVOCATION_RETRY_PAUSE_MILLIS;
162  static const std::string INVOCATION_RETRY_PAUSE_MILLIS_DEFAULT;
163 
175  static const std::string INVOCATION_TIMEOUT_SECONDS;
176  static const std::string INVOCATION_TIMEOUT_SECONDS_DEFAULT;
177 
181  static const std::string EVENT_THREAD_COUNT;
182  static const std::string EVENT_THREAD_COUNT_DEFAULT;
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 
241  static constexpr const char* OPERATION_BACKUP_TIMEOUT_MILLIS =
242  "hazelcast.client.operation.backup.timeout.millis";
243  static constexpr const char* OPERATION_BACKUP_TIMEOUT_MILLIS_DEFAULT =
244  "5000";
245 
254  static constexpr const char* FAIL_ON_INDETERMINATE_OPERATION_STATE =
255  "hazelcast.client.operation.fail.on.indeterminate.state";
256  static constexpr const char* FAIL_ON_INDETERMINATE_OPERATION_STATE_DEFAULT =
257  "false";
258 
263  static constexpr const char* CLOUD_URL_BASE = "hazelcast.client.cloud.url";
264  static constexpr const char* CLOUD_URL_BASE_DEFAULT =
265  "api.viridian.hazelcast.com";
266 
273  bool get_boolean(const client_property& property) const;
274 
281  int32_t get_integer(const client_property& property) const;
282 
289  int64_t get_long(const client_property& property) const;
290 
297  std::string get_string(const client_property& property) const;
298 
299 private:
300  client_property heartbeat_timeout_;
301  client_property heartbeat_interval_;
302  client_property retry_count_;
303  client_property retry_wait_time_;
304  client_property aws_member_port_;
305  client_property invocation_retry_pause_millis_;
306  client_property invocation_timeout_seconds_;
307  client_property event_thread_count_;
308  client_property internal_executor_pool_size_;
309  client_property shuffle_member_list_;
310  client_property max_concurrent_invocations_;
311  client_property backpressure_backoff_timeout_millis_;
312  client_property statistics_enabled_;
313  client_property statistics_period_seconds_;
314  client_property backup_timeout_millis_;
315  client_property fail_on_indeterminate_state_;
316  client_property cloud_base_url_;
317 
318  std::unordered_map<std::string, std::string> properties_map_;
319 };
320 
321 } // namespace client
322 } // namespace hazelcast
323 
324 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
325 #pragma warning(pop)
326 #endif
Client Properties is an internal class.
static const std::string PROP_HEARTBEAT_INTERVAL
Time interval in milliseconds between the heartbeats sent by the client to the nodes.
static const std::string PROP_REQUEST_RETRY_COUNT
Client will retry requests which either inherently retryable(idempotent client) or client_network_con...
static const std::string PROP_REQUEST_RETRY_WAIT_TIME
Client will retry requests which either inherently retryable(idempotent client) or client_network_con...
static const std::string MAX_CONCURRENT_INVOCATIONS
The maximum number of concurrent invocations allowed.
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...
static const std::string STATISTICS_PERIOD_SECONDS
The period in seconds the statistics sent to the cluster.
static const std::string EVENT_THREAD_COUNT
Number of the threads to handle the incoming event packets.
static const std::string STATISTICS_ENABLED
Use to enable the client statistics collection.
static const std::string INVOCATION_RETRY_PAUSE_MILLIS
Pause time between each retry cycle of an invocation in milliseconds.
static const std::string PROP_AWS_MEMBER_PORT
The discovery mechanism will discover only IP addresses.
static const std::string PROP_HEARTBEAT_TIMEOUT
Client will be sending heartbeat messages to members and this is the timeout.
static const std::string INVOCATION_TIMEOUT_SECONDS
When an invocation gets an exception because :
static const std::string BACKPRESSURE_BACKOFF_TIMEOUT_MILLIS
Control the maximum timeout in millis to wait for an invocation space to be available.
A client property is a configuration for hazelcast client.