Kudu C++ client API
|
#include <client.h>
Classes | |
class | SerializationOptions |
Public Member Functions | |
Status | CreateSession (sp::shared_ptr< KuduSession > *session) WARN_UNUSED_RESULT |
Status | Commit () WARN_UNUSED_RESULT |
Status | StartCommit () WARN_UNUSED_RESULT |
Status | IsCommitComplete (bool *is_complete, Status *completion_status) WARN_UNUSED_RESULT |
Status | Rollback () WARN_UNUSED_RESULT |
Status | Serialize (std::string *serialized_txn, const SerializationOptions &options=SerializationOptions()) const WARN_UNUSED_RESULT |
Static Public Member Functions | |
static Status | Deserialize (const sp::shared_ptr< KuduClient > &client, const std::string &serialized_txn, sp::shared_ptr< KuduTransaction > *txn) WARN_UNUSED_RESULT |
A class representing a multi-row transaction in Kudu. Once created using KuduClient::BeginTransaction()
or KuduTransaction::Deserialize
method, KuduTransaction
instance can be used to commit or rollback the underlying multi-row transaction and create a transactional session.
KuduTransaction
should be kept in scope to maintain automatic keep-alive heartbeating for the corresponding transaction. Once this object goes out of scope, the heartbeating stops and the transaction may automatically be aborted soon if no other clients do the heartbeating.Status kudu::client::KuduTransaction::Commit | ( | ) |
Commit the transaction.
This method automatically flushes all transactional sessions created off this transaction handle via KuduTransaction::CreateSession()
, initiates committing the transaction, and then waits for the commit phase to finalize. The flushing of all the derivative transactional sessions helps avoiding unintentional data loss when those sessions are not flushed explicitly before committing. No new operations should be pushed into the derivative transactional sessions created off this handle once the method has been called.
Status::OK()
if all the stages of the transaction's commit sequence were successful, i.e. the status of various pre-commit work, the status of starting the commit phase, the status of the commit phase itself once it's completed. Returns non-OK status of the very first failed stage of the transaction's commit sequence. Status kudu::client::KuduTransaction::CreateSession | ( | sp::shared_ptr< KuduSession > * | session | ) |
Create a new KuduSession
with "transactional" semantics.
Every write operation performed in the context of the newly created "transactional" session becomes a part of the corresponding multi-row transaction represented by an instance of this class. Multiple sessions can be created in the context of the same multi-row distributed transaction by the same or different Kudu clients residing on a single or multiple nodes.
[out] | session | The result session object. |
|
static |
Re-create KuduTransaction object given its serialized representation.
This method doesn't perform any RPC under the hood. The newly created object automatically does or does not send keep-alive messages depending on the KuduTransaction::SerializationOptions::enable_keepalive()
setting when the original KuduTransaction
object was serialized using KuduTransaction::Serialize()
.
[in] | client | Client instance to bound the result object to. |
[in] | serialized_txn | String containing serialized representation of KuduTransaction object. |
[out] | txn | The result KuduTransaction object, wrapped into a smart pointer. |
Status kudu::client::KuduTransaction::IsCommitComplete | ( | bool * | is_complete, |
Status * | completion_status | ||
) |
Whether the commit has completed i.e. no longer in progress of finalizing.
This method checks for the transaction's commit status, setting the is_complete
out parameter to true
and the completion_status
parameter to the finalization status of the commit process, assuming the method returning Status::OK()
. The happy case is when the method returns Status::OK()
, is_complete
is set to true
and completion_status
is set to Status::OK()
– that means the transaction has successfully finalized its commit phase.
[out] | is_complete | Whether the process of finalizing the commit of the transaction has ended, including both success and failure outcomes. In other words, the value of this out parameter indicates whether the finalization of the transaction's commit phase is no longer in progress: it already succeeded or failed by the time of processing the request. This parameter is assigned a meaningful value iff the method returns Status::OK() . |
[out] | completion_status | The status of finalization of the transaction's commit phase:
|
is_complete
and completion_status
are set iff the method returns Status::OK()
. Status kudu::client::KuduTransaction::Rollback | ( | ) |
Rollback/abort the transaction.
Status kudu::client::KuduTransaction::Serialize | ( | std::string * | serialized_txn, |
const SerializationOptions & | options = SerializationOptions() |
||
) | const |
Export the information on this transaction in a serialized form.
The serialized information on a Kudu transaction can be passed among different Kudu clients running at multiple nodes, so those separate Kudu clients can perform operations to be a part of the same distributed transaction. The resulting string is referred as "transaction token" and can be deserialized into a transaction handle (i.e. an object of the KuduTransaction
class) via the KuduTransaction::Deserialize()
method.
This method doesn't perform any RPC under the hood. The behavior of this method is controlled by SerializationOptions
set for this transaction handle.
[out] | serialized_txn | Result string to output the serialized transaction information. |
[in] | options | Options to use when serializing the handle (optional). If omitted, the default serialization parameters are used – the same as it would be for a default-constructed instance of SerializationOptions used for this parameter. |
Status kudu::client::KuduTransaction::StartCommit | ( | ) |
Start committing this transaction, but don't wait for the commit phase to finalize.
This method initiates the commit phase for this transaction, not waiting for the commit phase to finalize. It requires all the transactional sessions created off this handle via KuduTransaction::CreateSession()
to be flushed already. No new operations should be pushed into the derivative transactional sessions created off this handle once the method has been called. To check for the transaction's commit status, use the KuduTransaction::IsCommitComplete()
method.
Status::IllegalState()
.