Hazelcast C++ Client
Hazelcast C++ Client Library
Loading...
Searching...
No Matches
hazelcast::client::client_config Class Reference

hazelcast_client configuration class. More...

#include <client_config.h>

Public Member Functions

 client_config ()
 Constructor with default values.
 client_config (const client_config &rhs)=delete
client_configoperator= (const client_config &rhs)=delete
 client_config (client_config &&rhs)
client_configoperator= (client_config &&rhs)
const std::string & get_cluster_name () const
 Returns the configured cluster name.
client_configset_cluster_name (const std::string &cluster_name)
client_configset_credentials (const std::shared_ptr< security::credentials > &credential)
 There are two types of credentials you can provide, \username_password_credentials and \token_credentials.
const std::shared_ptr< security::credentials > & get_credentials () const
client_configset_redo_operation (bool redo_operation)
 If true, client will redo the operations that were executing on the server and client lost the connection.
bool is_redo_operation () const
 see setRedoOperation returns redoOperation
client_configset_socket_interceptor (socket_interceptor &&interceptor)
 Will be called with the Socket, each time client creates a connection to any Member.
const socket_interceptorget_socket_interceptor () const
 Will be called with the Socket, each time client creates a connection to any Member.
client_configadd_listener (lifecycle_listener &&listener)
 Adds a listener to configuration to be registered when hazelcast_client starts.
const std::vector< lifecycle_listener > & get_lifecycle_listeners () const
client_configadd_listener (membership_listener &&listener)
 Adds a listener to configuration to be registered when hazelcast_client starts.
const std::vector< membership_listener > & get_membership_listeners () const
 Returns registered membershipListeners.
load_balancerget_load_balancer ()
 Used to distribute the operations to multiple Endpoints.
client_configset_load_balancer (load_balancer &&load_balancer)
 Used to distribute the operations to multiple connections.
serialization_configget_serialization_config ()
client_configset_serialization_config (serialization_config const &serialization_config)
 SerializationConfig is used to.
const std::unordered_map< std::string, std::string > & get_properties () const
 Gets a reference to properties map.
client_configset_property (const std::string &name, const std::string &value)
 Sets the value of a named property.
client_configadd_reliable_topic_config (const config::reliable_topic_config &reliable_topic_config)
 Adds a ClientReliableTopicConfig.
const config::reliable_topic_configget_reliable_topic_config (const std::string &name)
 Gets the ClientReliableTopicConfig for a given reliable topic name.
client_configadd_near_cache_config (const config::near_cache_config &near_cache_config)
 Helper method to add a new NearCacheConfig.
const config::near_cache_configget_near_cache_config (const std::string &name) const
 Gets the NearCacheConfig configured for the map / cache with name.
config::client_network_configget_network_config ()
 Gets {}.
client_configset_network_config (const config::client_network_config &network_config)
 Sets {}.
const boost::optional< std::string > & get_instance_name () const
client_configset_instance_name (const std::string &instance_name)
int32_t get_executor_pool_size () const
 Pool size for internal ExecutorService which handles responses etc.
void set_executor_pool_size (int32_t executor_pool_size)
 Sets Client side Executor pool size.
config::client_connection_strategy_configget_connection_strategy_config ()
client_configset_connection_strategy_config (const config::client_connection_strategy_config &connection_strategy_config)
const config::client_flake_id_generator_configfind_flake_id_generator_config (const std::string &name)
 Returns a {} configuration for the given flake ID generator name.
const config::client_flake_id_generator_configget_flake_id_generator_config (const std::string &name)
 Returns the {} for the given name, creating one if necessary and adding it to the collection of known configurations.
client_configadd_flake_id_generator_config (const config::client_flake_id_generator_config &config)
 Adds a flake ID generator configuration.
config::logger_configget_logger_config ()
const std::unordered_set< std::string > & get_labels () const
client_configset_labels (const std::unordered_set< std::string > &labels)
client_configadd_label (const std::string &label)
client_configbackup_acks_enabled (bool enabled)
 This feature reduces number of hops and increase performance for smart clients.
bool backup_acks_enabled ()
 Note that backup acks to client can be enabled only for smart client.

Friends

class connection::ClientConnectionManagerImpl
class reliable_topic

Detailed Description

hazelcast_client configuration class.

Definition at line 107 of file client_config.h.

Constructor & Destructor Documentation

◆ client_config()

hazelcast::client::client_config::client_config ( )

Constructor with default values.

smart(true) redoOperation(false) connectionAttemptLimit(2) attemptPeriod(3000) defaultLoadBalancer: round robin load balancer

Definition at line 1048 of file config.cpp.

1049 : cluster_name_("dev")
1050 , redo_operation_(false)
1051 , socket_interceptor_()
1052 , executor_pool_size_(-1)
1053{}

Member Function Documentation

◆ add_flake_id_generator_config()

client_config & hazelcast::client::client_config::add_flake_id_generator_config ( const config::client_flake_id_generator_config & config)

Adds a flake ID generator configuration.

The configuration is saved under the config name, which may be a pattern with which the configuration will be obtained in the future.

Parameters
configthe flake ID configuration
Returns
this config instance

Definition at line 1323 of file config.cpp.

1325{
1326 flake_id_generator_config_map_.emplace(config.get_name(), config);
1327 return *this;
1328}

◆ add_label()

client_config & hazelcast::client::client_config::add_label ( const std::string & label)

Definition at line 1357 of file config.cpp.

1358{
1359 labels_.insert(label);
1360 return *this;
1361}

◆ add_listener() [1/2]

client_config & hazelcast::client::client_config::add_listener ( lifecycle_listener && listener)

Adds a listener to configuration to be registered when hazelcast_client starts.

Warning 1: If listener should do a time consuming operation, off-load the operation to another thread. otherwise it will slow down the system.

Warning 2: Do not make a call to hazelcast. It can cause deadlock.

Parameters
listenerlifecycle_listener
Returns
itself ClientConfig

Definition at line 1104 of file config.cpp.

1105{
1106 lifecycle_listeners_.emplace_back(std::move(listener));
1107 return *this;
1108}

◆ add_listener() [2/2]

client_config & hazelcast::client::client_config::add_listener ( membership_listener && listener)

Adds a listener to configuration to be registered when hazelcast_client starts.

Warning 1: If listener should do a time consuming operation, off-load the operation to another thread. otherwise it will slow down the system.

Warning 2: Do not make a call to hazelcast. It can cause deadlock.

Parameters
listenerMembershipListener
Returns
itself ClientConfig

Definition at line 1111 of file config.cpp.

1112{
1113 membership_listeners_.emplace_back(std::move(listener));
1114 return *this;
1115}

◆ add_near_cache_config()

client_config & hazelcast::client::client_config::add_near_cache_config ( const config::near_cache_config & near_cache_config)

Helper method to add a new NearCacheConfig.

Parameters
nearCacheConfigNearCacheConfig to be added
Returns
configured client_config for chaining
See also
NearCacheConfig

Memory ownership of the config is passed to the client config

Definition at line 1209 of file config.cpp.

1211{
1212 near_cache_config_map_.emplace(near_cache_config.get_name(),
1213 near_cache_config);
1214 return *this;
1215}

◆ add_reliable_topic_config()

client_config & hazelcast::client::client_config::add_reliable_topic_config ( const config::reliable_topic_config & reliable_topic_config)

Adds a ClientReliableTopicConfig.

Parameters
reliableTopicConfigthe ReliableTopicConfig to add
Returns
configured {} for chaining

Definition at line 1170 of file config.cpp.

1172{
1173 reliable_topic_config_map_[reliable_topic_config.get_name()] =
1174 reliable_topic_config;
1175 return *this;
1176}

◆ backup_acks_enabled() [1/2]

bool hazelcast::client::client_config::backup_acks_enabled ( )

Note that backup acks to client can be enabled only for smart client.

This config has no effect for unisocket clients.

Returns
true if backup acknowledgements comes to client

Definition at line 1371 of file config.cpp.

1372{
1373 return backup_acks_enabled_;
1374}

◆ backup_acks_enabled() [2/2]

client_config & hazelcast::client::client_config::backup_acks_enabled ( bool enabled)

This feature reduces number of hops and increase performance for smart clients.

It is enabled by default for smart clients. This config has no effect for unisocket clients.

Parameters
enabledenables client to get backup acknowledgements directly from the member that backups are applied
Returns
configured \ClientConfig for chaining

Definition at line 1364 of file config.cpp.

1365{
1366 backup_acks_enabled_ = enabled;
1367 return *this;
1368}

◆ find_flake_id_generator_config()

const config::client_flake_id_generator_config * hazelcast::client::client_config::find_flake_id_generator_config ( const std::string & name)

Returns a {} configuration for the given flake ID generator name.

The name is matched by pattern to the configuration and by stripping the partition ID qualifier from the given name. If there is no config found by the name, it will return the configuration with the name "default".

Parameters
namename of the flake ID generator config
Returns
the flake ID generator configuration
Exceptions
ConfigurationExceptionif ambiguous configurations are found
See also
StringPartitioningStrategy#getBaseName(std::string)
#setConfigPatternMatcher(ConfigPatternMatcher)
#getConfigPatternMatcher()

Definition at line 1284 of file config.cpp.

1285{
1286 std::string baseName =
1287 internal::partition::strategy::StringPartitioningStrategy::get_base_name(
1288 name);
1289 auto config = internal::config::ConfigUtils::lookup_by_pattern<
1290 config::client_flake_id_generator_config>(
1291 config_pattern_matcher_, flake_id_generator_config_map_, baseName);
1292 if (config) {
1293 return config;
1294 }
1295 return get_flake_id_generator_config("default");
1296}
const config::client_flake_id_generator_config * get_flake_id_generator_config(const std::string &name)
Returns the {} for the given name, creating one if necessary and adding it to the collection of known...
Definition config.cpp:1299

◆ get_cluster_name()

const std::string & hazelcast::client::client_config::get_cluster_name ( ) const

Returns the configured cluster name.

The name is sent as part of client authentication message and may be verified on the member.

Returns
the configured cluster name

Definition at line 1331 of file config.cpp.

1332{
1333 return cluster_name_;
1334}

◆ get_connection_strategy_config()

config::client_connection_strategy_config & hazelcast::client::client_config::get_connection_strategy_config ( )

Definition at line 1270 of file config.cpp.

1271{
1272 return connection_strategy_config_;
1273}

◆ get_credentials()

const std::shared_ptr< security::credentials > & hazelcast::client::client_config::get_credentials ( ) const

Definition at line 1377 of file config.cpp.

1378{
1379 return credentials_;
1380}

◆ get_executor_pool_size()

int32_t hazelcast::client::client_config::get_executor_pool_size ( ) const

Pool size for internal ExecutorService which handles responses etc.

Returns
int Executor pool size.

Definition at line 1258 of file config.cpp.

1259{
1260 return executor_pool_size_;
1261}

◆ get_flake_id_generator_config()

const config::client_flake_id_generator_config * hazelcast::client::client_config::get_flake_id_generator_config ( const std::string & name)

Returns the {} for the given name, creating one if necessary and adding it to the collection of known configurations.

The configuration is found by matching the the configuration name pattern to the provided name without the partition qualifier (the part of the name after '@'). If no configuration matches, it will create one by cloning the "default" configuration and add it to the configuration collection.

This method is intended to easily and fluently create and add configurations more specific than the default configuration without explicitly adding it by invoking {}. Because it adds new configurations if they are not already present, this method is intended to be used before this config is used to create a hazelcast instance. Afterwards, newly added configurations may be ignored.

Parameters
namename of the flake ID generator config
Returns
the cache configuration
Exceptions
ConfigurationExceptionif ambiguous configurations are found
See also
StringPartitioningStrategy#getBaseName(std::string)

Definition at line 1299 of file config.cpp.

1300{
1301 std::string baseName =
1302 internal::partition::strategy::StringPartitioningStrategy::get_base_name(
1303 name);
1304 auto config = internal::config::ConfigUtils::lookup_by_pattern<
1305 config::client_flake_id_generator_config>(
1306 config_pattern_matcher_, flake_id_generator_config_map_, baseName);
1307 if (config) {
1308 return config;
1309 }
1310 auto defConfig = flake_id_generator_config_map_.find("default");
1311 if (defConfig == flake_id_generator_config_map_.end()) {
1312 flake_id_generator_config_map_.emplace(
1313 "default", config::client_flake_id_generator_config("default"));
1314 }
1315 defConfig = flake_id_generator_config_map_.find("default");
1316 config::client_flake_id_generator_config new_config = defConfig->second;
1317 new_config.set_name(name);
1318 flake_id_generator_config_map_.emplace(name, std::move(new_config));
1319 return &flake_id_generator_config_map_.find(name)->second;
1320}

◆ get_instance_name()

const boost::optional< std::string > & hazelcast::client::client_config::get_instance_name ( ) const

Definition at line 1245 of file config.cpp.

1246{
1247 return instance_name_;
1248}

◆ get_labels()

const std::unordered_set< std::string > & hazelcast::client::client_config::get_labels ( ) const

Definition at line 1344 of file config.cpp.

1345{
1346 return labels_;
1347}

◆ get_lifecycle_listeners()

const std::vector< lifecycle_listener > & hazelcast::client::client_config::get_lifecycle_listeners ( ) const
Returns
registered lifecycleListeners

Definition at line 1118 of file config.cpp.

1119{
1120 return lifecycle_listeners_;
1121}

◆ get_load_balancer()

load_balancer & hazelcast::client::client_config::get_load_balancer ( )

Used to distribute the operations to multiple Endpoints.

Returns
load_balancer

Definition at line 1074 of file config.cpp.

1075{
1076 if (!load_balancer_) {
1077 auto index = std::make_shared<std::atomic<size_t>>(0);
1078 load_balancer_ = load_balancer().next([=](cluster& c) {
1079 auto members = c.get_members();
1080 if (members.empty()) {
1081 return boost::optional<member>();
1082 }
1083 auto i = index->fetch_add(1);
1084 return boost::make_optional(std::move(members[i % members.size()]));
1085 });
1086 }
1087 return *load_balancer_;
1088}

◆ get_logger_config()

config::logger_config & hazelcast::client::client_config::get_logger_config ( )
Returns
The logger configuration.

Definition at line 1098 of file config.cpp.

1099{
1100 return logger_config_;
1101}

◆ get_membership_listeners()

const std::vector< membership_listener > & hazelcast::client::client_config::get_membership_listeners ( ) const

Returns registered membershipListeners.

Returns
registered membershipListeners

Definition at line 1124 of file config.cpp.

1125{
1126 return membership_listeners_;
1127}

◆ get_near_cache_config()

const config::near_cache_config * hazelcast::client::client_config::get_near_cache_config ( const std::string & name) const

Gets the NearCacheConfig configured for the map / cache with name.

Parameters
namename of the map / cache
Returns
Configured NearCacheConfig
See also
NearCacheConfig

Definition at line 1218 of file config.cpp.

1219{
1220 auto nearCacheConfig = internal::config::ConfigUtils::lookup_by_pattern(
1221 config_pattern_matcher_, near_cache_config_map_, name);
1222 if (nearCacheConfig) {
1223 return nearCacheConfig;
1224 }
1225
1226 auto config_it = near_cache_config_map_.find("default");
1227 if (config_it != near_cache_config_map_.end()) {
1228 return &near_cache_config_map_.find("default")->second;
1229 }
1230
1231 // not needed for c++ client since it is always native memory
1232 // initDefaultMaxSizeForOnHeapMaps(nearCacheConfig);
1233 return nullptr;
1234}

◆ get_network_config()

config::client_network_config & hazelcast::client::client_config::get_network_config ( )

Gets {}.

Returns
{} com.hazelcast.client.config.client_network_config

Definition at line 1203 of file config.cpp.

1204{
1205 return network_config_;
1206}

◆ get_properties()

const std::unordered_map< std::string, std::string > & hazelcast::client::client_config::get_properties ( ) const

Gets a reference to properties map.

Returns
properties map

Definition at line 1157 of file config.cpp.

1158{
1159 return properties_;
1160}

◆ get_reliable_topic_config()

const config::reliable_topic_config & hazelcast::client::client_config::get_reliable_topic_config ( const std::string & name)

Gets the ClientReliableTopicConfig for a given reliable topic name.

Parameters
namethe name of the reliable topic
Returns
the found config. If none is found, a default configured one is returned.

Definition at line 1179 of file config.cpp.

1180{
1181 auto it = reliable_topic_config_map_.find(name);
1182 if (it != reliable_topic_config_map_.end()) {
1183 return it->second;
1184 }
1185
1186 return reliable_topic_config_map_
1187 .emplace(name, config::reliable_topic_config{ name })
1188 .first->second;
1189}

◆ get_serialization_config()

serialization_config & hazelcast::client::client_config::get_serialization_config ( )
Returns
serializationConfig

Definition at line 1143 of file config.cpp.

1144{
1145 return serialization_config_;
1146}

◆ get_socket_interceptor()

const socket_interceptor & hazelcast::client::client_config::get_socket_interceptor ( ) const

Will be called with the Socket, each time client creates a connection to any Member.

Definition at line 1137 of file config.cpp.

1138{
1139 return socket_interceptor_;
1140}

◆ is_redo_operation()

bool hazelcast::client::client_config::is_redo_operation ( ) const

see setRedoOperation returns redoOperation

Definition at line 1068 of file config.cpp.

1069{
1070 return redo_operation_;
1071}

◆ set_cluster_name()

client_config & hazelcast::client::client_config::set_cluster_name ( const std::string & cluster_name)

Definition at line 1337 of file config.cpp.

1338{
1339 cluster_name_ = cluster_name;
1340 return *this;
1341}

◆ set_connection_strategy_config()

client_config & hazelcast::client::client_config::set_connection_strategy_config ( const config::client_connection_strategy_config & connection_strategy_config)

Definition at line 1276 of file config.cpp.

1278{
1279 connection_strategy_config_ = connection_strategy_config;
1280 return *this;
1281}

◆ set_credentials()

client_config & hazelcast::client::client_config::set_credentials ( const std::shared_ptr< security::credentials > & credential)

There are two types of credentials you can provide, \username_password_credentials and \token_credentials.

Returns
itself ClientConfig

Definition at line 1383 of file config.cpp.

1385{
1386 credentials_ = credential;
1387 return *this;
1388}

◆ set_executor_pool_size()

void hazelcast::client::client_config::set_executor_pool_size ( int32_t executor_pool_size)

Sets Client side Executor pool size.

Parameters
executorPoolSizepool size
Returns
configured client_config for chaining

Definition at line 1264 of file config.cpp.

1265{
1266 executor_pool_size_ = executor_pool_size;
1267}

◆ set_instance_name()

client_config & hazelcast::client::client_config::set_instance_name ( const std::string & instance_name)

Definition at line 1251 of file config.cpp.

1252{
1253 instance_name_ = instance_name;
1254 return *this;
1255}

◆ set_labels()

client_config & hazelcast::client::client_config::set_labels ( const std::unordered_set< std::string > & labels)

Definition at line 1350 of file config.cpp.

1351{
1352 labels_ = labels;
1353 return *this;
1354}

◆ set_load_balancer()

client_config & hazelcast::client::client_config::set_load_balancer ( load_balancer && load_balancer)

Used to distribute the operations to multiple connections.

If not set, round robin based load balancer is used

Parameters
load_balancer
Returns
itself ClientConfig

Definition at line 1091 of file config.cpp.

1092{
1093 this->load_balancer_ = std::move(load_balancer);
1094 return *this;
1095}

◆ set_network_config()

client_config & hazelcast::client::client_config::set_network_config ( const config::client_network_config & network_config)

Sets {}.

Parameters
networkConfig{} to be set configured client_config for chaining com.hazelcast.client.config.client_network_config

Definition at line 1237 of file config.cpp.

1239{
1240 this->network_config_ = network_config;
1241 return *this;
1242}

◆ set_property()

client_config & hazelcast::client::client_config::set_property ( const std::string & name,
const std::string & value )

Sets the value of a named property.

See also
client_properties for properties that is used to configure client
Parameters
nameproperty name
valuevalue of the property
Returns
itself ClientConfig

Definition at line 1163 of file config.cpp.

1164{
1165 properties_[name] = value;
1166 return *this;
1167}

◆ set_redo_operation()

client_config & hazelcast::client::client_config::set_redo_operation ( bool redo_operation)

If true, client will redo the operations that were executing on the server and client lost the connection.

This can be because of network, or simply because the member died. However it is not clear whether the application is performed or not. For idempotent operations this is harmless, but for non idempotent ones retrying can cause to undesirable effects. Note that the redo can perform on any member.

If false, the operation will throw io_exception.

Parameters
redoOperationreturn itself ClientConfig

Definition at line 1061 of file config.cpp.

1062{
1063 this->redo_operation_ = redo_operation;
1064 return *this;
1065}

◆ set_serialization_config()

client_config & hazelcast::client::client_config::set_serialization_config ( serialization_config const & serialization_config)

SerializationConfig is used to.

  • set version of portable classes in this client (
    See also
    versioned_portable_serializer)
    Parameters
    serializationConfig
    Returns
    itself ClientConfig

Definition at line 1149 of file config.cpp.

1151{
1152 this->serialization_config_ = serialization_config;
1153 return *this;
1154}

◆ set_socket_interceptor()

client_config & hazelcast::client::client_config::set_socket_interceptor ( socket_interceptor && interceptor)

Will be called with the Socket, each time client creates a connection to any Member.

Returns
itself ClientConfig

Definition at line 1130 of file config.cpp.

1131{
1132 this->socket_interceptor_ = std::move(interceptor);
1133 return *this;
1134}

◆ connection::ClientConnectionManagerImpl

friend class connection::ClientConnectionManagerImpl
friend

Definition at line 110 of file client_config.h.

◆ reliable_topic

friend class reliable_topic
friend

Definition at line 451 of file client_config.h.


The documentation for this class was generated from the following files: