Hazelcast C++ Client
Hazelcast C++ Client Library
hazelcast::client::client_config Class Reference

hazelcast_client configuration class. More...

#include <client_config.h>

Public Member Functions

 client_config ()
 Constructor with default values. More...
 
 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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
const std::vector< membership_listener > & get_membership_listeners () const
 Returns registered membershipListeners. More...
 
load_balancerget_load_balancer ()
 Used to distribute the operations to multiple Endpoints. More...
 
client_configset_load_balancer (load_balancer &&load_balancer)
 Used to distribute the operations to multiple connections. More...
 
serialization_configget_serialization_config ()
 
client_configset_serialization_config (serialization_config const &serialization_config)
 SerializationConfig is used to. More...
 
const std::unordered_map< std::string, std::string > & get_properties () const
 Gets a reference to properties map. More...
 
client_configset_property (const std::string &name, const std::string &value)
 Sets the value of a named property. More...
 
client_configadd_reliable_topic_config (const config::reliable_topic_config &reliable_topic_config)
 Adds a ClientReliableTopicConfig. More...
 
const config::reliable_topic_configget_reliable_topic_config (const std::string &name)
 Gets the ClientReliableTopicConfig for a given reliable topic name. More...
 
client_configadd_near_cache_config (const config::near_cache_config &near_cache_config)
 Helper method to add a new NearCacheConfig. More...
 
const config::near_cache_configget_near_cache_config (const std::string &name) const
 Gets the NearCacheConfig configured for the map / cache with name. More...
 
config::client_network_configget_network_config ()
 Gets {}. More...
 
client_configset_network_config (const config::client_network_config &network_config)
 Sets {}. More...
 
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. More...
 
void set_executor_pool_size (int32_t executor_pool_size)
 Sets Client side Executor pool size. More...
 
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. More...
 
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. More...
 
client_configadd_flake_id_generator_config (const config::client_flake_id_generator_config &config)
 Adds a flake ID generator configuration. More...
 
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. More...
 
bool backup_acks_enabled ()
 Note that backup acks to client can be enabled only for smart client. More...
 

Friends

class connection::ClientConnectionManagerImpl
 
class reliable_topic
 

Detailed Description

hazelcast_client configuration class.

Definition at line 102 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 763 of file config.cpp.

763  : cluster_name_("dev"), redo_operation_(false),
764  socket_interceptor_(), executor_pool_size_(-1) {}

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 961 of file config.cpp.

961  {
962  flake_id_generator_config_map_.emplace(config.get_name(), config);
963  return *this;
964  }

◆ 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 803 of file config.cpp.

803  {
804  lifecycle_listeners_.emplace_back(std::move(listener));
805  return *this;
806  }

◆ 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 808 of file config.cpp.

808  {
809  membership_listeners_.emplace_back(std::move(listener));
810  return *this;
811  }

◆ 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 875 of file config.cpp.

875  {
876  near_cache_config_map_.emplace(near_cache_config.get_name(), near_cache_config);
877  return *this;
878  }

◆ 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 848 of file config.cpp.

848  {
849  reliable_topic_config_map_[reliable_topic_config.get_name()] = reliable_topic_config;
850  return *this;
851  }

◆ 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 994 of file config.cpp.

994  {
995  return backup_acks_enabled_;
996  }

◆ 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 989 of file config.cpp.

989  {
990  backup_acks_enabled_ = enabled;
991  return *this;
992  }

◆ 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 930 of file config.cpp.

930  {
931  std::string baseName = internal::partition::strategy::StringPartitioningStrategy::get_base_name(name);
932  auto config = internal::config::ConfigUtils::lookup_by_pattern<config::client_flake_id_generator_config>(
933  config_pattern_matcher_, flake_id_generator_config_map_, baseName);
934  if (config) {
935  return config;
936  }
937  return get_flake_id_generator_config("default");
938  }
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:942

◆ 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 966 of file config.cpp.

966  {
967  return cluster_name_;
968  }

◆ 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 911 of file config.cpp.

911  {
912  return executor_pool_size_;
913  }

◆ 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 942 of file config.cpp.

942  {
943  std::string baseName = internal::partition::strategy::StringPartitioningStrategy::get_base_name(name);
944  auto config = internal::config::ConfigUtils::lookup_by_pattern<config::client_flake_id_generator_config>(
945  config_pattern_matcher_, flake_id_generator_config_map_, baseName);
946  if (config) {
947  return config;
948  }
949  auto defConfig = flake_id_generator_config_map_.find("default");
950  if (defConfig == flake_id_generator_config_map_.end()) {
951  flake_id_generator_config_map_.emplace("default", config::client_flake_id_generator_config("default"));
952  }
953  defConfig = flake_id_generator_config_map_.find("default");
954  config::client_flake_id_generator_config new_config = defConfig->second;
955  new_config.set_name(name);
956  flake_id_generator_config_map_.emplace(name, std::move(new_config));
957  return &flake_id_generator_config_map_.find(name)->second;
958  }

◆ get_lifecycle_listeners()

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

Definition at line 813 of file config.cpp.

813  {
814  return lifecycle_listeners_;
815  }

◆ 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 779 of file config.cpp.

779  {
780  if (!load_balancer_) {
781  auto index = std::make_shared<std::atomic<size_t>>(0);
782  load_balancer_ = load_balancer().next([=](cluster &c) {
783  auto members = c.get_members();
784  if (members.empty()) {
785  return boost::optional<member>();
786  }
787  auto i = index->fetch_add(1);
788  return boost::make_optional(std::move(members[i % members.size()]));
789  });
790  }
791  return *load_balancer_;
792  }

◆ get_logger_config()

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

Definition at line 799 of file config.cpp.

799  {
800  return logger_config_;
801  }

◆ 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 817 of file config.cpp.

817  {
818  return membership_listeners_;
819  }

◆ 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 880 of file config.cpp.

880  {
881  auto nearCacheConfig = internal::config::ConfigUtils::lookup_by_pattern(
882  config_pattern_matcher_, near_cache_config_map_, name);
883  if (nearCacheConfig) {
884  return nearCacheConfig;
885  }
886 
887  auto config_it = near_cache_config_map_.find("default");
888  if (config_it != near_cache_config_map_.end()) {
889  return &near_cache_config_map_.find("default")->second;
890  }
891 
892  // not needed for c++ client since it is always native memory
893  //initDefaultMaxSizeForOnHeapMaps(nearCacheConfig);
894  return nullptr;
895  }

◆ 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 871 of file config.cpp.

871  {
872  return network_config_;
873  }

◆ 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 839 of file config.cpp.

839  {
840  return properties_;
841  }

◆ 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 853 of file config.cpp.

853  {
854  auto it = reliable_topic_config_map_.find(name);
855  if (it != reliable_topic_config_map_.end()) {
856  return it->second;
857  }
858 
859  return reliable_topic_config_map_.emplace(name, name).first->second;
860  }

◆ get_serialization_config()

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

Definition at line 830 of file config.cpp.

830  {
831  return serialization_config_;
832  }

◆ 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 1002 of file config.cpp.

1002  {
1003  credentials_ = credential;
1004  return *this;
1005  }

◆ 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 915 of file config.cpp.

915  {
916  client_config::executor_pool_size_ = executor_pool_size;
917  }

◆ 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 794 of file config.cpp.

794  {
795  this->load_balancer_ = std::move(load_balancer);
796  return *this;
797  }

◆ 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 897 of file config.cpp.

897  {
898  this->network_config_ = network_config;
899  return *this;
900  }

◆ 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 843 of file config.cpp.

843  {
844  properties_[name] = value;
845  return *this;
846  }

◆ 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 770 of file config.cpp.

770  {
771  this->redo_operation_ = redo_operation;
772  return *this;
773  }

◆ 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 834 of file config.cpp.

834  {
835  this->serialization_config_ = serialization_config;
836  return *this;
837  }

◆ 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 821 of file config.cpp.

821  {
822  this->socket_interceptor_ = std::move(interceptor);
823  return *this;
824  }

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