21#include <boost/format.hpp>
23#include "hazelcast/util/Util.h"
24#include "hazelcast/util/IOUtil.h"
25#include "hazelcast/client/hazelcast_client.h"
26#include "hazelcast/client/transaction_context.h"
27#include "hazelcast/client/cluster.h"
28#include "hazelcast/client/spi/lifecycle_service.h"
29#include "hazelcast/client/lifecycle_listener.h"
30#include "hazelcast/client/exception/protocol_exceptions.h"
31#include "hazelcast/client/aws/aws_client.h"
32#include "hazelcast/client/spi/impl/discovery/cloud_discovery.h"
33#include "hazelcast/client/impl/statistics/Statistics.h"
34#include "hazelcast/client/impl/hazelcast_client_instance_impl.h"
35#include "hazelcast/client/impl/ClientLockReferenceIdGenerator.h"
36#include "hazelcast/client/spi/impl/ClientInvocationServiceImpl.h"
37#include "hazelcast/client/spi/impl/ClientPartitionServiceImpl.h"
38#include "hazelcast/client/spi/impl/ClientExecutionServiceImpl.h"
39#include "hazelcast/client/spi/impl/sequence/CallIdFactory.h"
40#include "hazelcast/client/spi/impl/DefaultAddressProvider.h"
41#include "hazelcast/client/spi/impl/discovery/remote_address_provider.h"
42#include "hazelcast/client/spi/impl/listener/cluster_view_listener.h"
43#include "hazelcast/client/spi/impl/listener/listener_service_impl.h"
44#include "hazelcast/client/load_balancer.h"
45#include "hazelcast/client/connection/ClientConnectionManagerImpl.h"
46#include "hazelcast/client/proxy/flake_id_generator_impl.h"
47#include "hazelcast/client/map/NearCachedClientMapProxy.h"
48#include "hazelcast/logger.h"
49#include "hazelcast/client/member_selectors.h"
50#include "hazelcast/client/client_properties.h"
51#include "hazelcast/client/big_decimal.h"
52#include "hazelcast/client/local_time.h"
53#include "hazelcast/client/local_date.h"
54#include "hazelcast/client/local_date_time.h"
55#include "hazelcast/client/offset_date_time.h"
56#ifndef HAZELCAST_VERSION
57#define HAZELCAST_VERSION "NOT_FOUND"
62hazelcast_client::hazelcast_client()
64 new impl::hazelcast_client_instance_impl(*this,
client_config()))
66 client_impl_->start();
69hazelcast_client::hazelcast_client(client_config config)
71 new impl::hazelcast_client_instance_impl(*this,
std::move(config)))
73 client_impl_->start();
79 return client_impl_->get_name();
85 return client_impl_->get_client_config();
91 return client_impl_->new_transaction_context();
97 return client_impl_->new_transaction_context(options);
103 return client_impl_->get_cluster();
115 const boost::uuids::uuid& registration_id)
117 return client_impl_->remove_lifecycle_listener(registration_id);
123 return boost::async([=]() { client_impl_->shutdown(); });
126spi::lifecycle_service&
129 return client_impl_->get_lifecycle_service();
135 return client_impl_->get_local_endpoint();
138hazelcast_client::~hazelcast_client() =
default;
143 return client_impl_->get_cp_subsystem();
149 return client_impl_->get_sql();
152const boost::string_view
155 return HAZELCAST_VERSION;
159std::atomic<int32_t> hazelcast_client_instance_impl::CLIENT_ID(0);
161hazelcast_client_instance_impl::hazelcast_client_instance_impl(
163 client_config config)
164 : client_config_(
std::move(config))
165 , client_properties_(client_config_.get_properties())
166 , client_context_(*this)
167 , schema_service_{ client_context_ }
168 , serialization_service_(client_config_.get_serialization_config(),
170 , cluster_service_(client_context_)
171 , transaction_manager_(client_context_)
172 , cluster_(cluster_service_)
173 , lifecycle_service_(client_context_,
174 client_config_.get_lifecycle_listeners())
175 , proxy_manager_(client_context_)
177 , random_generator_(
std::random_device{}())
178 , uuid_generator_{ random_generator_ }
179 , cp_subsystem_(client_context_)
180 , sql_service_(client_context_)
181 , proxy_session_manager_(client_context_)
183 auto& name = client_config_.get_instance_name();
185 instance_name_ = *name;
187 std::ostringstream out;
188 out <<
"hz.client_" << id_;
189 instance_name_ = out.str();
192 auto logger_config = client_config_.get_logger_config();
193 logger_ = std::make_shared<logger>(instance_name_,
194 client_config_.get_cluster_name(),
195 logger_config.level(),
196 logger_config.handler());
198 execution_service_ = init_execution_service();
200 initalize_near_cache_manager();
202 int32_t maxAllowedConcurrentInvocations = client_properties_.get_integer(
203 client_properties_.get_max_concurrent_invocations());
204 int64_t backofftimeoutMs = client_properties_.get_long(
205 client_properties_.get_backpressure_backoff_timeout_millis());
206 bool isBackPressureEnabled = maxAllowedConcurrentInvocations != INT32_MAX;
208 spi::impl::sequence::CallIdFactory::new_call_id_sequence(
209 isBackPressureEnabled,
210 maxAllowedConcurrentInvocations,
213 auto address_provider = create_address_provider();
215 connection_manager_ =
216 std::make_shared<connection::ClientConnectionManagerImpl>(
217 client_context_, std::move(address_provider));
219 cluster_listener_.reset(
220 new spi::impl::listener::cluster_view_listener(client_context_));
222 partition_service_.reset(
223 new spi::impl::ClientPartitionServiceImpl(client_context_));
225 invocation_service_.reset(
226 new spi::impl::ClientInvocationServiceImpl(client_context_));
228 listener_service_ = init_listener_service();
230 proxy_manager_.init();
232 lock_reference_id_generator_.reset(
233 new impl::ClientLockReferenceIdGenerator());
235 statistics_.reset(
new statistics::Statistics(client_context_));
238hazelcast_client_instance_impl::~hazelcast_client_instance_impl()
244hazelcast_client_instance_impl::start()
246 lifecycle_service_.fire_lifecycle_event(lifecycle_event::STARTING);
249 if (!lifecycle_service_.start()) {
250 lifecycle_service_.shutdown();
251 BOOST_THROW_EXCEPTION(exception::illegal_state(
252 "hazelcast_client",
"hazelcast_client could not be started!"));
254 }
catch (std::exception&) {
255 lifecycle_service_.shutdown();
261hazelcast_client_instance_impl::get_client_config()
263 return client_config_;
267hazelcast_client_instance_impl::get_cluster()
273hazelcast_client_instance_impl::add_lifecycle_listener(
280hazelcast_client_instance_impl::remove_lifecycle_listener(
281 const boost::uuids::uuid& registration_id)
283 return lifecycle_service_.remove_listener(registration_id);
287hazelcast_client_instance_impl::shutdown()
289 lifecycle_service_.shutdown();
293hazelcast_client_instance_impl::new_transaction_context()
296 return new_transaction_context(defaultOptions);
300hazelcast_client_instance_impl::new_transaction_context(
306internal::nearcache::NearCacheManager&
307hazelcast_client_instance_impl::get_near_cache_manager()
309 return *near_cache_manager_;
312serialization::pimpl::SerializationService&
313hazelcast_client_instance_impl::get_serialization_service()
315 return serialization_service_;
318const protocol::ClientExceptionFactory&
319hazelcast_client_instance_impl::get_exception_factory()
const
321 return exception_factory_;
324std::shared_ptr<spi::impl::listener::listener_service_impl>
325hazelcast_client_instance_impl::init_listener_service()
327 auto eventThreadCount = client_properties_.get_integer(
328 client_properties_.get_event_thread_count());
329 return std::make_shared<spi::impl::listener::listener_service_impl>(
330 client_context_, eventThreadCount);
333std::shared_ptr<spi::impl::ClientExecutionServiceImpl>
334hazelcast_client_instance_impl::init_execution_service()
336 return std::make_shared<spi::impl::ClientExecutionServiceImpl>(
339 client_config_.get_executor_pool_size(),
344hazelcast_client_instance_impl::on_cluster_restart()
348 "Clearing local state of the client, because of a cluster restart");
350 near_cache_manager_->clear_all_near_caches();
352 cluster_service_.clear_member_list();
355std::unique_ptr<connection::AddressProvider>
356hazelcast_client_instance_impl::create_address_provider()
359 get_client_config().get_network_config();
363 auto addresses = networkConfig.get_addresses();
364 bool addressListProvided = !addresses.empty();
365 bool awsDiscoveryEnabled = awsConfig.is_enabled();
366 bool cloud_enabled = cloudConfig.enabled;
368 check_discovery_configuration_consistency(
369 addressListProvided, awsDiscoveryEnabled, cloud_enabled);
371 auto connect_timeout = networkConfig.get_connection_timeout();
373 auto cloud_provider =
374 std::make_shared<spi::impl::discovery::cloud_discovery>(
376 client_properties_.get_string(client_properties_.cloud_base_url()),
378 return std::unique_ptr<connection::AddressProvider>(
379 new spi::impl::discovery::remote_address_provider(
380 [=]() {
return cloud_provider->get_addresses(); },
true));
383 if (awsDiscoveryEnabled) {
384 auto aws_addr_provider = std::make_shared<aws::aws_client>(
385 connect_timeout, awsConfig, client_properties_, *logger_);
386 return std::unique_ptr<connection::AddressProvider>(
387 new spi::impl::discovery::remote_address_provider(
388 [=]() {
return aws_addr_provider->get_addresses(); },
389 !awsConfig.is_inside_aws()));
392 return std::unique_ptr<connection::AddressProvider>(
393 new spi::impl::DefaultAddressProvider(networkConfig));
397hazelcast_client_instance_impl::get_name()
const
399 return instance_name_;
402spi::lifecycle_service&
403hazelcast_client_instance_impl::get_lifecycle_service()
405 return lifecycle_service_;
408const std::shared_ptr<ClientLockReferenceIdGenerator>&
409hazelcast_client_instance_impl::get_lock_reference_id_generator()
const
411 return lock_reference_id_generator_;
415hazelcast_client_instance_impl::get_proxy_manager()
417 return proxy_manager_;
421hazelcast_client_instance_impl::initalize_near_cache_manager()
423 near_cache_manager_.reset(
new internal::nearcache::NearCacheManager(
424 execution_service_, serialization_service_, *logger_));
428hazelcast_client_instance_impl::get_local_endpoint()
const
430 return cluster_service_.get_local_client();
434boost::shared_future<std::shared_ptr<imap>>
435hazelcast_client_instance_impl::get_distributed_object(
const std::string& name)
437 auto nearCacheConfig = client_config_.get_near_cache_config(name);
438 if (nearCacheConfig) {
439 return proxy_manager_
440 .get_or_create_proxy<
441 map::NearCachedClientMapProxy<serialization::pimpl::data,
442 serialization::pimpl::data>>(
443 imap::SERVICE_NAME, name)
447 boost::shared_future<std::shared_ptr<
448 map::NearCachedClientMapProxy<serialization::pimpl::data,
449 serialization::pimpl::data>>> f) {
450 return std::static_pointer_cast<imap>(f.get());
453 return proxy_manager_.get_or_create_proxy<
imap>(imap::SERVICE_NAME,
458const std::shared_ptr<logger>&
459hazelcast_client_instance_impl::get_logger()
const
465hazelcast_client_instance_impl::random_uuid()
467 std::lock_guard<std::mutex> g(uuid_generator_lock_);
468 return uuid_generator_();
472hazelcast_client_instance_impl::get_cp_subsystem()
474 return cp_subsystem_;
478hazelcast_client_instance_impl::get_sql()
484hazelcast_client_instance_impl::send_state_to_cluster()
486 schema_service_.replicate_all_schemas();
490hazelcast_client_instance_impl::should_check_urgent_invocations()
const
492 return schema_service_.has_any_schemas();
496hazelcast_client_instance_impl::check_discovery_configuration_consistency(
497 bool address_list_provided,
502 if (address_list_provided)
509 BOOST_THROW_EXCEPTION(exception::illegal_state(
510 "hazelcast_client_instance_impl::check_discovery_configuration_"
513 "Only one discovery method can be enabled at a time. cluster "
514 "members given explicitly : %1%, aws discovery: %2%, "
515 "hazelcast.cloud enabled : %3%") %
516 address_list_provided % aws_enabled % cloud_enabled)
521BaseEventHandler::~BaseEventHandler() =
default;
523BaseEventHandler::BaseEventHandler(logger &logger)
528BaseEventHandler::get_logger()
const
534constexpr int address::ID;
543 : host_(
std::move(url))
550 : host_(
std::move(hostname))
553 , scope_id_(scope_id)
559 return rhs.port_ == port_ && rhs.type_ == type_ &&
560 0 == rhs.host_.compare(host_);
566 return !(*
this == rhs);
582address::operator<(
const address& rhs)
const
584 if (host_ < rhs.host_) {
587 if (rhs.host_ < host_) {
590 if (port_ < rhs.port_) {
593 if (rhs.port_ < port_) {
596 return type_ < rhs.type_;
602 return type_ == IPV4;
606address::get_scope_id()
const
612address::to_string()
const
614 std::ostringstream out;
620operator<<(std::ostream& stream,
const address& address)
622 return stream << address.to_string();
628 return lhs.unscaled == rhs.unscaled && lhs.scale == rhs.scale;
634 if (lhs.scale != rhs.scale) {
635 return lhs.scale < rhs.scale;
637 return lhs.unscaled < rhs.unscaled;
643 return lhs.hours == rhs.hours && lhs.minutes == rhs.minutes &&
644 lhs.seconds == rhs.seconds && lhs.nanos == rhs.nanos;
653hash_value(
const T& v)
655 return std::hash<T>()(v);
661 if (lhs.hours < rhs.hours) {
664 if (rhs.hours < lhs.hours) {
667 if (lhs.minutes < rhs.minutes) {
670 if (rhs.minutes < lhs.minutes) {
673 if (lhs.seconds < rhs.seconds) {
676 if (rhs.seconds < lhs.seconds) {
679 return lhs.nanos < rhs.nanos;
685 return lhs.year == rhs.year && lhs.month == rhs.month &&
686 lhs.day_of_month == rhs.day_of_month;
692 if (lhs.year < rhs.year) {
695 if (rhs.year < lhs.year) {
698 if (lhs.month < rhs.month) {
701 if (rhs.month < lhs.month) {
704 return lhs.day_of_month < rhs.day_of_month;
710 return lhs.date == rhs.date && lhs.time == rhs.time;
716 if (lhs.date < rhs.date) {
719 if (rhs.date < lhs.date) {
722 return lhs.time < rhs.time;
728 return lhs.date_time == rhs.date_time &&
729 lhs.zone_offset_in_seconds == rhs.zone_offset_in_seconds;
735 if (lhs.date_time < rhs.date_time) {
738 if (rhs.date_time < lhs.date_time) {
741 return lhs.zone_offset_in_seconds < rhs.zone_offset_in_seconds;
747twos_complement(std::vector<int8_t>& a)
751 for (
auto& item : a) {
756 for (
int i = a.size() - 1; i >= 0; i--) {
766boost::multiprecision::cpp_int
767from_bytes(std::vector<int8_t> v)
769 boost::multiprecision::cpp_int i;
770 bool is_negative = v[0] < 0;
774 import_bits(i, v.begin(), v.end(), 8);
782to_bytes(
const boost::multiprecision::cpp_int& i)
784 std::vector<int8_t> v;
785 export_bits(i, std::back_inserter(v), 8);
790 v.insert(v.begin(), -1);
795 v.insert(v.begin(), 0);
802namespace serialization {
819 out.write<int32_t>(
object.port_);
820 out.write<
byte>(
object.type_);
821 out.write(
object.host_);
828 object.port_ = in.read<int32_t>();
829 object.type_ = in.read<
byte>();
830 object.host_ = in.read<std::string>();
835iexecutor_service::iexecutor_service(
const std::string& name,
836 spi::ClientContext* context)
837 : ProxyImpl(SERVICE_NAME, name, context)
838 , consecutive_submits_(0)
839 , last_submit_time_(0)
845 std::vector<member> selected;
846 std::vector<member> members =
847 get_context().get_client_cluster_service().get_member_list();
848 for (
const member& member : members) {
849 if (member_selector.select(member)) {
850 selected.push_back(member);
853 if (selected.empty()) {
854 BOOST_THROW_EXCEPTION(exception::rejected_execution(
855 "IExecutorService::selectMembers",
856 "No member could be selected with member selector"));
861std::pair<boost::future<protocol::ClientMessage>,
862 std::shared_ptr<spi::impl::ClientInvocation>>
863iexecutor_service::invoke_on_target(protocol::ClientMessage&& request,
864 boost::uuids::uuid target)
867 std::shared_ptr<spi::impl::ClientInvocation> clientInvocation =
868 spi::impl::ClientInvocation::create(
869 get_context(), request, get_name(), target);
870 return std::make_pair(clientInvocation->invoke(), clientInvocation);
871 }
catch (exception::iexception&) {
872 util::exception_util::rethrow(std::current_exception());
874 return std::pair<boost::future<protocol::ClientMessage>,
875 std::shared_ptr<spi::impl::ClientInvocation>>();
878std::pair<boost::future<protocol::ClientMessage>,
879 std::shared_ptr<spi::impl::ClientInvocation>>
880iexecutor_service::invoke_on_partition_owner(protocol::ClientMessage&& request,
884 std::shared_ptr<spi::impl::ClientInvocation> clientInvocation =
885 spi::impl::ClientInvocation::create(
886 get_context(), request, get_name(), partition_id);
887 return std::make_pair(clientInvocation->invoke(), clientInvocation);
888 }
catch (exception::iexception&) {
889 util::exception_util::rethrow(std::current_exception());
891 return std::pair<boost::future<protocol::ClientMessage>,
892 std::shared_ptr<spi::impl::ClientInvocation>>();
896iexecutor_service::is_sync_computation(
bool prevent_sync)
898 int64_t now = util::current_time_millis();
900 int64_t last = last_submit_time_;
901 last_submit_time_ = now;
903 if (last + MIN_TIME_RESOLUTION_OF_CONSECUTIVE_SUBMITS < now) {
904 consecutive_submits_ = 0;
908 return !prevent_sync &&
909 (consecutive_submits_++ % MAX_CONSECUTIVE_SUBMITS == 0);
913iexecutor_service::get_member_address(
const member&
member)
916 get_context().get_client_cluster_service().get_member(member.get_uuid());
918 throw(exception::exception_builder<exception::hazelcast_>(
919 "IExecutorService::getMemberAddress(Member)")
920 << member <<
" is not available!")
923 return m->get_address();
927iexecutor_service::random_partition_id()
929 auto& partitionService = get_context().get_partition_service();
930 return rand() % partitionService.get_partition_count();
936 auto request = protocol::codec::executorservice_shutdown_encode(get_name());
944 protocol::codec::executorservice_isshutdown_encode(get_name());
945 return invoke_and_get_future<bool>(request);
955 "hazelcast_client_heartbeat_timeout";
956const std::string client_properties::PROP_HEARTBEAT_TIMEOUT_DEFAULT =
"60000";
958 "hazelcast_client_heartbeat_interval";
959const std::string client_properties::PROP_HEARTBEAT_INTERVAL_DEFAULT =
"5000";
961 "hazelcast_client_request_retry_count";
962const std::string client_properties::PROP_REQUEST_RETRY_COUNT_DEFAULT =
"20";
964 "hazelcast_client_request_retry_wait_time";
965const std::string client_properties::PROP_REQUEST_RETRY_WAIT_TIME_DEFAULT =
"1";
968const std::string client_properties::PROP_AWS_MEMBER_PORT_DEFAULT =
"5701";
971 "hazelcast.client.invocation.retry.pause.millis";
972const std::string client_properties::INVOCATION_RETRY_PAUSE_MILLIS_DEFAULT =
976 "hazelcast.client.invocation.timeout.seconds";
977const std::string client_properties::INVOCATION_TIMEOUT_SECONDS_DEFAULT =
"120";
980 "hazelcast.client.event.thread.count";
981const std::string client_properties::EVENT_THREAD_COUNT_DEFAULT =
"5";
983const std::string client_properties::INTERNAL_EXECUTOR_POOL_SIZE =
984 "hazelcast.client.internal.executor.pool.size";
985const std::string client_properties::INTERNAL_EXECUTOR_POOL_SIZE_DEFAULT =
"3";
988 "hazelcast.client.shuffle.member.list";
989const std::string client_properties::SHUFFLE_MEMBER_LIST_DEFAULT =
"true";
992 "hazelcast.client.max.concurrent.invocations";
993const std::string client_properties::MAX_CONCURRENT_INVOCATIONS_DEFAULT =
994 util::IOUtil::to_string<int32_t>(INT32_MAX);
997 "hazelcast.client.invocation.backoff.timeout.millis";
999 client_properties::BACKPRESSURE_BACKOFF_TIMEOUT_MILLIS_DEFAULT =
"-1";
1002 "hazelcast.client.statistics.enabled";
1003const std::string client_properties::STATISTICS_ENABLED_DEFAULT =
"false";
1006 "hazelcast.client.statistics.period.seconds";
1007const std::string client_properties::STATISTICS_PERIOD_SECONDS_DEFAULT =
"3";
1009client_property::client_property(
const std::string& name,
1010 const std::string& default_value)
1012 , default_value_(default_value)
1016client_property::get_name()
const
1022client_property::get_default_value()
const
1024 return default_value_;
1030#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
1031#pragma warning(push)
1035 return std::getenv(name_.c_str());
1036#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
1041client_properties::client_properties(
1042 const std::unordered_map<std::string, std::string>& properties)
1043 : heartbeat_timeout_(PROP_HEARTBEAT_TIMEOUT, PROP_HEARTBEAT_TIMEOUT_DEFAULT)
1044 , heartbeat_interval_(PROP_HEARTBEAT_INTERVAL,
1045 PROP_HEARTBEAT_INTERVAL_DEFAULT)
1046 , retry_count_(PROP_REQUEST_RETRY_COUNT, PROP_REQUEST_RETRY_COUNT_DEFAULT)
1047 , retry_wait_time_(PROP_REQUEST_RETRY_WAIT_TIME,
1048 PROP_REQUEST_RETRY_WAIT_TIME_DEFAULT)
1049 , aws_member_port_(PROP_AWS_MEMBER_PORT, PROP_AWS_MEMBER_PORT_DEFAULT)
1050 , invocation_retry_pause_millis_(INVOCATION_RETRY_PAUSE_MILLIS,
1051 INVOCATION_RETRY_PAUSE_MILLIS_DEFAULT)
1052 , invocation_timeout_seconds_(INVOCATION_TIMEOUT_SECONDS,
1053 INVOCATION_TIMEOUT_SECONDS_DEFAULT)
1054 , event_thread_count_(EVENT_THREAD_COUNT, EVENT_THREAD_COUNT_DEFAULT)
1055 , internal_executor_pool_size_(INTERNAL_EXECUTOR_POOL_SIZE,
1056 INTERNAL_EXECUTOR_POOL_SIZE_DEFAULT)
1057 , shuffle_member_list_(SHUFFLE_MEMBER_LIST, SHUFFLE_MEMBER_LIST_DEFAULT)
1058 , max_concurrent_invocations_(MAX_CONCURRENT_INVOCATIONS,
1059 MAX_CONCURRENT_INVOCATIONS_DEFAULT)
1060 , backpressure_backoff_timeout_millis_(
1061 BACKPRESSURE_BACKOFF_TIMEOUT_MILLIS,
1062 BACKPRESSURE_BACKOFF_TIMEOUT_MILLIS_DEFAULT)
1063 , statistics_enabled_(STATISTICS_ENABLED, STATISTICS_ENABLED_DEFAULT)
1064 , statistics_period_seconds_(STATISTICS_PERIOD_SECONDS,
1065 STATISTICS_PERIOD_SECONDS_DEFAULT)
1066 , backup_timeout_millis_(OPERATION_BACKUP_TIMEOUT_MILLIS,
1067 OPERATION_BACKUP_TIMEOUT_MILLIS_DEFAULT)
1068 , fail_on_indeterminate_state_(FAIL_ON_INDETERMINATE_OPERATION_STATE,
1069 FAIL_ON_INDETERMINATE_OPERATION_STATE_DEFAULT)
1070 , cloud_base_url_(CLOUD_URL_BASE, CLOUD_URL_BASE_DEFAULT)
1071 , partition_arg_cache_size_(PARTITION_ARGUMENT_CACHE_SIZE,
1072 PARTITION_ARGUMENT_CACHE_SIZE_DEFAULT)
1073 , properties_map_(properties)
1076const client_property&
1077client_properties::get_heartbeat_timeout()
const
1079 return heartbeat_timeout_;
1082const client_property&
1083client_properties::get_heartbeat_interval()
const
1085 return heartbeat_interval_;
1089client_properties::get_aws_member_port()
const
1091 return aws_member_port_;
1095client_properties::get_invocation_retry_pause_millis()
const
1097 return invocation_retry_pause_millis_;
1101client_properties::get_invocation_timeout_seconds()
const
1103 return invocation_timeout_seconds_;
1107client_properties::get_event_thread_count()
const
1109 return event_thread_count_;
1113client_properties::get_internal_executor_pool_size()
const
1115 return internal_executor_pool_size_;
1119client_properties::get_shuffle_member_list()
const
1121 return shuffle_member_list_;
1125client_properties::get_max_concurrent_invocations()
const
1127 return max_concurrent_invocations_;
1131client_properties::get_backpressure_backoff_timeout_millis()
const
1133 return backpressure_backoff_timeout_millis_;
1137client_properties::get_statistics_enabled()
const
1139 return statistics_enabled_;
1143client_properties::get_statistics_period_seconds()
const
1145 return statistics_period_seconds_;
1151 std::unordered_map<std::string, std::string>::const_iterator valueIt =
1152 properties_map_.find(property.get_name());
1153 if (valueIt != properties_map_.end()) {
1154 return valueIt->second;
1157 const char* value =
property.get_system_property();
1158 if (value != NULL) {
1162 return property.get_default_value();
1168 return util::IOUtil::to_value<bool>(
get_string(property));
1174 return util::IOUtil::to_value<int32_t>(
get_string(property));
1180 return util::IOUtil::to_value<int64_t>(
get_string(property));
1184client_properties::backup_timeout_millis()
const
1186 return backup_timeout_millis_;
1189const client_property&
1190client_properties::fail_on_indeterminate_state()
const
1192 return fail_on_indeterminate_state_;
1195const client_property&
1196client_properties::cloud_base_url()
const
1198 return cloud_base_url_;
1202client_properties::partition_arg_cache_size()
const
1204 return partition_arg_cache_size_;
1207namespace exception {
1208iexception::iexception(std::string exception_name,
1210 std::string message,
1211 std::string details,
1213 std::exception_ptr cause,
1216 : src_(std::move(source))
1217 , msg_(std::move(message))
1218 , details_(std::move(details))
1219 , error_code_(error_no)
1220 , cause_(std::move(cause))
1221 , runtime_exception_(is_runtime)
1222 , retryable_(retryable)
1223 , report_((boost::format(
"%1% {%2%. Error code:%3%, Details:%4%.} at %5%.") %
1224 exception_name % msg_ % error_code_ % details_ % src_)
1228iexception::~iexception() noexcept = default;
1233 return report_.c_str();
1237iexception::get_source()
const
1243iexception::get_message()
const
1249operator<<(std::ostream& os,
const iexception& exception)
1251 os << exception.what();
1256iexception::get_details()
const
1262iexception::get_error_code()
const
1268iexception::is_runtime()
const
1270 return runtime_exception_;
1274iexception::is_retryable()
const
1279iexception::iexception() =
default;
1281retryable_hazelcast::retryable_hazelcast(std::string source,
1282 std::string message,
1283 std::string details,
1284 std::exception_ptr cause)
1285 : retryable_hazelcast(
"retryable_hazelcast",
1286 protocol::RETRYABLE_HAZELCAST,
1295retryable_hazelcast::retryable_hazelcast(std::string error_name,
1298 std::string message,
1299 std::string details,
1300 std::exception_ptr cause,
1303 : hazelcast_(std::move(error_name),
1313member_left::member_left(std::string source,
1314 std::string message,
1315 std::string details,
1316 std::exception_ptr cause)
1317 : execution(
"member_left",
1318 protocol::MEMBER_LEFT,
1327consistency_lost::consistency_lost(std::string source,
1328 std::string message,
1329 std::string details,
1330 std::exception_ptr cause)
1331 : hazelcast_(
"consistency_lost",
1332 protocol::CONSISTENCY_LOST_EXCEPTION,
1341query::query(std::string source,
1342 std::string message,
1343 std::string details,
1344 std::exception_ptr cause)
1345 : hazelcast_(std::move(source),
1353query::query(int32_t code,
1354 std::string message,
1355 std::exception_ptr cause,
1356 boost::uuids::uuid originating_member_id,
1357 std::string suggestion)
1358 : hazelcast_(
"", std::move(message),
"", std::move(cause))
1360 , suggestion_(std::move(suggestion))
1361 , originating_member_uuid_(originating_member_id)
1372query::suggestion()
const
1377const boost::uuids::uuid&
1378query::originating_member_uuid()
const
1380 return originating_member_uuid_;
1383invocation_might_contain_compact_data::invocation_might_contain_compact_data(
1385 const spi::impl::ClientInvocation& invocation)
1390 "The invocation %1% might contain Compact serialized "
1391 "data and it is not safe to invoke it when the client is not "
1392 "yet initialized on the cluster") %
1401boost::future<client::hazelcast_client>
1407boost::future<client::hazelcast_client>
1410 return boost::async(
1420hash<hazelcast::client::address>::operator()(
1421 const hazelcast::client::address& address)
const noexcept
1423 std::size_t seed = 0;
1424 boost::hash_combine(seed, address.get_host());
1425 boost::hash_combine(seed, address.get_port());
1426 boost::hash_combine(seed, address.type_);
1431hash<hazelcast::client::big_decimal>::operator()(
1432 const hazelcast::client::big_decimal& dec)
const
1434 std::size_t seed = 0;
1435 boost::hash_combine(seed, dec.unscaled);
1436 boost::hash_combine(seed, dec.scale);
1441hash<hazelcast::client::local_time>::operator()(
1442 const hazelcast::client::local_time& v)
const
1444 std::size_t seed = 0;
1445 boost::hash_combine(seed, v.
hours);
1446 boost::hash_combine(seed, v.
minutes);
1447 boost::hash_combine(seed, v.
seconds);
1448 boost::hash_combine(seed, v.
nanos);
1453hash<hazelcast::client::local_date>::operator()(
1454 const hazelcast::client::local_date& v)
const
1456 std::size_t seed = 0;
1457 boost::hash_combine(seed, v.
year);
1458 boost::hash_combine(seed, v.
month);
1464hash<hazelcast::client::local_date_time>::operator()(
1465 const hazelcast::client::local_date_time& v)
const
1467 std::size_t seed = 0;
1468 boost::hash_combine<hazelcast::client::local_date>(seed, v.date);
1469 boost::hash_combine<hazelcast::client::local_time>(seed, v.time);
1474hash<hazelcast::client::offset_date_time>::operator()(
1475 const hazelcast::client::offset_date_time& v)
const
1477 std::size_t seed = 0;
1478 boost::hash_combine<hazelcast::client::local_date_time>(seed, v.
date_time);
Represents an address of a client or member in the cluster.
const std::string & get_host() const
bool operator==(const address &address) const
bool operator!=(const address &address) const
hazelcast_client configuration 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(idempotentclient) or client_network_conf...
static const std::string PROP_REQUEST_RETRY_WAIT_TIME
Client will retry requests which either inherently retryable(idempotentclient) or client_network_conf...
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.
std::string get_string(const client_property &property) const
Returns the configured value of a ClientProperty as std::string.
int32_t get_integer(const client_property &property) const
Returns the configured int32_t value of a ClientProperty.
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 :
bool get_boolean(const client_property &property) const
Returns the configured boolean value of a ClientProperty.
int64_t get_long(const client_property &property) const
Returns the configured int64_t value of a ClientProperty.
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.
const char * get_system_property() const
Gets the system environment property value of the property.
Hazelcast cluster interface.
The client_aws_config contains the configuration for client to connect to nodes in aws environment.
Contains configuration parameters for client network related behaviour.
char const * what() const noexcept override
return pointer to the explanation string.
cp::cp_subsystem & get_cp_subsystem()
boost::future< void > shutdown()
Shuts down this hazelcast_client.
bool remove_lifecycle_listener(const boost::uuids::uuid ®istration_id)
Remove lifecycle listener.
client_config & get_client_config()
cluster & get_cluster()
Returns the Cluster that connected Hazelcast instance is a part of.
local_endpoint get_local_endpoint() const
Returns the local endpoint which this HazelcastInstance belongs to.
sql::sql_service & get_sql()
transaction_context new_transaction_context()
Creates a new transaction_context associated with the current thread using default options.
boost::uuids::uuid add_lifecycle_listener(lifecycle_listener &&lifecycle_listener)
Add listener to listen lifecycle events.
const std::string & get_name() const
Returns the name of this client instance.
spi::lifecycle_service & get_lifecycle_service()
Returns the lifecycle service for this instance.
boost::future< bool > is_shutdown()
Returns true if this executor has been shut down.
boost::future< bool > is_terminated()
Returns true if all tasks have completed following shut down.
void shutdown()
Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will...
Concurrent, distributed, observable and queryable map client.
Listener object for listening lifecycle events of hazelcast instance.
The Client interface allows to get information about a connected client's socket address,...
A service to execute SQL statements.
Provides a context to do transactional operations; so beginning/committing transactions,...
Contains the configuration for a Hazelcast transaction.
CP Subsystem is a component of Hazelcast that builds a strongly consistent layer for a set of distrib...
An arbitrary precision and scale floating point number.
hazelcast.cloud configuration to let the client connect the cluster via hazelcast....
A date-time without a time-zone in the ISO-8601 calendar system, such as 2007-12-03T10:15:30.
A date without a time-zone in the ISO-8601 calendar system, such as 2007-12-03.
uint8_t day_of_month
minimum value is 1 maximum value is 31
int32_t year
minimum value is -999999999 maximum value is 999999999
uint8_t month
minimum value is 1 maximum value is 12
A time without a time-zone in the ISO-8601 calendar system, such as 10:15:30.
uint8_t hours
the hour-of-day to represent, from 0 to 23
uint8_t seconds
the second-of-minute to represent, from 0 to 59
int32_t nanos
the nanosecond-of-second to represent, from 0 to 999,999,999
uint8_t minutes
the minute-of-hour to represent, from 0 to 59
A date-time with an offset from UTC/Greenwich in the ISO-8601 calendar system, such as 2007-12-03T10:...
int32_t zone_offset_in_seconds
The offset from UTC/Greenwich.
local_date_time date_time
The local date-time.