18 #include "hazelcast/client/transaction_options.h"
19 #include "hazelcast/client/txn/TransactionProxy.h"
20 #include "hazelcast/client/transactional_map.h"
21 #include "hazelcast/client/exception/protocol_exceptions.h"
22 #include "hazelcast/client/transactional_queue.h"
23 #include "hazelcast/client/transactional_multi_map.h"
24 #include "hazelcast/client/transactional_list.h"
25 #include "hazelcast/client/transactional_set.h"
27 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
29 #pragma warning(disable: 4251)
34 class HAZELCAST_API hash<std::pair<std::string, std::string>> {
36 std::size_t operator()(
const std::pair<std::string, std::string> &val)
const noexcept;
44 class ClientTransactionManagerServiceImpl;
48 namespace connection {
49 class ClientConnectionManagerImpl;
72 boost::uuids::uuid get_txn_id()
const;
79 boost::future<void> begin_transaction();
86 boost::future<void> commit_transaction();
93 boost::future<void> rollback_transaction();
102 std::shared_ptr<transactional_map>
get_map(
const std::string &name) {
103 return get_transactional_object<transactional_map>(imap::SERVICE_NAME, name);
113 std::shared_ptr<transactional_queue>
get_queue(
const std::string &name) {
114 return get_transactional_object<transactional_queue>(iqueue::SERVICE_NAME, name);
124 std::shared_ptr<transactional_multi_map>
get_multi_map(
const std::string &name) {
125 return get_transactional_object<transactional_multi_map>(multi_map::SERVICE_NAME, name);
135 std::shared_ptr<transactional_list>
get_list(
const std::string &name) {
136 return get_transactional_object<transactional_list>(ilist::SERVICE_NAME, name);
146 std::shared_ptr<transactional_set>
get_set(
const std::string &name) {
147 return get_transactional_object<transactional_set>(iset::SERVICE_NAME, name);
159 if (transaction_.get_state() != txn::TxnState::ACTIVE) {
160 std::string message =
"No transaction is found while accessing ";
161 message +=
"transactional object -> [" + name +
"]!";
162 BOOST_THROW_EXCEPTION(
163 exception::illegal_state(
"TransactionContext::getMap(const std::string& name)",
166 auto key = std::make_pair(service_name, name);
167 std::shared_ptr<T> obj = std::static_pointer_cast<T>(txn_object_map_.get(key));
169 obj = std::shared_ptr<T>(
new T(name, transaction_));
170 txn_object_map_.put(key, obj);
178 std::shared_ptr<connection::Connection> txn_connection_;
179 txn::TransactionProxy transaction_;
180 util::SynchronizedMap<std::pair<std::string, std::string>, proxy::TransactionalObject> txn_object_map_;
185 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
Provides a context to do transactional operations; so beginning/committing transactions,...
std::shared_ptr< transactional_set > get_set(const std::string &name)
Returns the transactional set instance with the specified name.
std::shared_ptr< transactional_multi_map > get_multi_map(const std::string &name)
Returns the transactional multimap instance with the specified name.
std::shared_ptr< transactional_map > get_map(const std::string &name)
Returns the transactional distributed map instance with the specified name.
std::shared_ptr< T > get_transactional_object(const std::string &service_name, const std::string &name)
get any transactional object with template T.
std::shared_ptr< transactional_queue > get_queue(const std::string &name)
Returns the transactional queue instance with the specified name.
std::shared_ptr< transactional_list > get_list(const std::string &name)
Returns the transactional list instance with the specified name.
Contains the configuration for a Hazelcast transaction.