Apache Ignite C++
transaction.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
23 #ifndef _IGNITE_TRANSACTIONS_TRANSACTION
24 #define _IGNITE_TRANSACTIONS_TRANSACTION
25 
26 #include <ignite/common/concurrent.h>
27 
28 #include "ignite/impl/transactions/transaction_impl.h"
30 
31 namespace ignite
32 {
33  namespace transactions
34  {
47  class IGNITE_FRIEND_EXPORT Transaction
48  {
49  public:
57  Transaction(common::concurrent::SharedPointer<impl::transactions::TransactionImpl> impl);
58 
64  Transaction(const Transaction& other);
65 
72  Transaction& operator=(const Transaction& other);
73 
77  ~Transaction();
78 
86  void Commit();
87 
97  void Commit(IgniteError& err);
98 
106  void Rollback();
107 
117  void Rollback(IgniteError& err);
118 
126  void Close();
127 
137  void Close(IgniteError& err);
138 
150  void SetRollbackOnly();
151 
165  void SetRollbackOnly(IgniteError& err);
166 
178  bool IsRollbackOnly();
179 
194  bool IsRollbackOnly(IgniteError& err);
195 
205  TransactionState GetState();
206 
217  TransactionState GetState(IgniteError& err);
218 
227  {
228  return static_cast<TransactionConcurrency>(impl.Get()->GetConcurrency());
229  }
230 
239  {
240  return static_cast<TransactionIsolation>(impl.Get()->GetIsolation());
241  }
242 
250  int64_t GetTimeout() const
251  {
252  return impl.Get()->GetTimeout();
253  }
254 
266  bool IsValid() const
267  {
268  return impl.IsValid();
269  }
270 
271  private:
273  common::concurrent::SharedPointer<impl::transactions::TransactionImpl> impl;
274  };
275  }
276 }
277 
278 #endif //_IGNITE_TRANSACTIONS_TRANSACTION
TransactionConcurrency GetConcurrency() const
Get concurrency.
Definition: transaction.h:226
int64_t GetTimeout() const
Get timeout.
Definition: transaction.h:250
TransactionConcurrency
Transaction concurrency control model.
Definition: transaction_consts.h:33
TransactionState
Cache transaction state.
Definition: transaction_consts.h:112
TransactionIsolation
Defines different cache transaction isolation levels.
Definition: transaction_consts.h:68
bool IsValid() const
Check if the instance is valid and can be used.
Definition: transaction.h:266
Ignite cache transaction.
Definition: transaction.h:47
TransactionIsolation GetIsolation() const
Get isolation.
Definition: transaction.h:238
Declares Transaction-related enumerations.
Ignite error information.
Definition: ignite_error.h:89
Apache Ignite API.
Definition: cache.h:43