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>>
37 std::size_t operator()(
38 const std::pair<std::string, std::string>& val)
const noexcept;
46 class ClientTransactionManagerServiceImpl;
50 namespace connection {
51 class ClientConnectionManagerImpl;
71 spi::impl::ClientTransactionManagerServiceImpl& transaction_manager,
77 boost::uuids::uuid get_txn_id()
const;
84 boost::future<void> begin_transaction();
92 boost::future<void> commit_transaction();
99 boost::future<void> rollback_transaction();
109 std::shared_ptr<transactional_map>
get_map(
const std::string& name)
111 return get_transactional_object<transactional_map>(imap::SERVICE_NAME,
122 std::shared_ptr<transactional_queue>
get_queue(
const std::string& name)
124 return get_transactional_object<transactional_queue>(
125 iqueue::SERVICE_NAME, name);
136 const std::string& name)
138 return get_transactional_object<transactional_multi_map>(
139 multi_map::SERVICE_NAME, name);
149 std::shared_ptr<transactional_list>
get_list(
const std::string& name)
151 return get_transactional_object<transactional_list>(ilist::SERVICE_NAME,
162 std::shared_ptr<transactional_set>
get_set(
const std::string& name)
164 return get_transactional_object<transactional_set>(iset::SERVICE_NAME,
177 const std::string& name)
179 if (transaction_.get_state() != txn::TxnState::ACTIVE) {
180 std::string message =
"No transaction is found while accessing ";
181 message +=
"transactional object -> [" + name +
"]!";
182 BOOST_THROW_EXCEPTION(exception::illegal_state(
183 "TransactionContext::getMap(const std::string& name)", message));
185 auto key = std::make_pair(service_name, name);
186 std::shared_ptr<T> obj =
187 std::static_pointer_cast<T>(txn_object_map_.get(key));
189 obj = std::shared_ptr<T>(
new T(name, transaction_));
190 txn_object_map_.put(key, obj);
198 std::shared_ptr<connection::Connection> txn_connection_;
199 txn::TransactionProxy transaction_;
200 util::SynchronizedMap<std::pair<std::string, std::string>,
201 proxy::TransactionalObject>
207 #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.