📄 ndbtransaction.hpp
字号:
void* anyObject, AbortOption abortOption = AbortOnError);#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED void executeAsynchPrepare(::ExecType execType, NdbAsynchCallback callback, void* anyObject, ::AbortOption abortOption = ::AbortOnError) { executeAsynchPrepare((ExecType)execType, callback, anyObject, (AbortOption)abortOption); }#endif /** * Prepare and send an asynchronous transaction. * * This method perform the same action as * NdbTransaction::executeAsynchPrepare * but also sends the operations to the NDB kernel. * * See NdbTransaction::executeAsynchPrepare for information * about the parameters of this method. * * See @ref secAsync for more information on * how to use this method. */ void executeAsynch(ExecType aTypeOfExec, NdbAsynchCallback aCallback, void* anyObject, AbortOption abortOption = AbortOnError, int forceSend= 0);#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED void executeAsynch(::ExecType aTypeOfExec, NdbAsynchCallback aCallback, void* anyObject, ::AbortOption abortOption= ::AbortOnError, int forceSend= 0) { executeAsynch((ExecType)aTypeOfExec, aCallback, anyObject, (AbortOption)abortOption, forceSend); }#endif#endif /** * Refresh * Update timeout counter of this transaction * in the database. If you want to keep the transaction * active in the database longer than the * transaction abort timeout. * @note It's not advised to take a lock on a record and keep it * for a extended time since this can impact other transactions. * */ int refresh(); /** * Close transaction * * @note Equivalent to to calling Ndb::closeTransaction() */#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL /** * @note It is not allowed to call NdbTransaction::close after sending the * transaction asynchronously before the callback method has * been called. * (The application should keep track of the number of * outstanding transactions and wait until all of them * has completed before calling NdbTransaction::close). * If the transaction is not committed it will be aborted. */#endif void close();#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL /** * Restart transaction * * Once a transaction has been completed successfully * it can be started again wo/ calling closeTransaction/startTransaction * * @note This method also releases completed operations * * @note This method does not close open scans, * c.f. NdbScanOperation::close() * * @note This method can only be called _directly_ after commit * and only if commit is successful */ int restart();#endif /** @} *********************************************************************/ /** * @name Meta Information * @{ */ /** * Get global checkpoint identity (GCI) of transaction. * * Each committed transaction belong to a GCI. * The log for the committed transaction is saved on * disk when a global checkpoint occurs. * * Whether or not the global checkpoint with this GCI has been * saved on disk or not cannot be determined by this method. * * By comparing the GCI of a transaction with the value * last GCI restored in a restarted NDB Cluster one can determine * whether the transaction was restored or not. * * @note Global Checkpoint Identity is undefined for scan transactions * (This is because no updates are performed in scan transactions.) * * @return GCI of transaction or -1 if GCI is not available. * (Note that there has to be an NdbTransaction::execute call * with Ndb::Commit for the GCI to be available.) */ int getGCI(); /** * Get transaction identity. * * @return Transaction id. */ Uint64 getTransactionId(); /** * The commit status of the transaction. */ enum CommitStatusType { NotStarted, ///< Transaction not yet started Started, ///< <i>Missing explanation</i> Committed, ///< Transaction has been committed Aborted, ///< Transaction has been aborted NeedAbort ///< <i>Missing explanation</i> }; /** * Get the commit status of the transaction. * * @return The commit status of the transaction */ CommitStatusType commitStatus(); /** @} *********************************************************************/ /** * @name Error Handling * @{ */ /** * Get error object with information about the latest error. * * @return An error object with information about the latest error. */ const NdbError & getNdbError() const; /** * Get the latest NdbOperation which had an error. * This method is used on the NdbTransaction object to find the * NdbOperation causing an error. * To find more information about the * actual error, use method NdbOperation::getNdbError() * on the returned NdbOperation object. * * @return The NdbOperation causing the latest error. */ NdbOperation* getNdbErrorOperation(); /** * Get the method number where the latest error occured. * * @return Line number where latest error occured. */ int getNdbErrorLine(); /** * Get completed (i.e. executed) operations of a transaction * * This method should only be used <em>after</em> a transaction * has been executed. * - NdbTransaction::getNextCompletedOperation(NULL) returns the * first NdbOperation object. * - NdbTransaction::getNextCompletedOperation(op) returns the * NdbOperation object defined after the NdbOperation "op". * * This method is typically used to fetch all NdbOperation:s of * a transaction to check for errors (use NdbOperation::getNdbError * to fetch the NdbError object of an NdbOperation). * * @note This method should only be used after the transaction has been * executed and before the transaction has been closed. * * @param op Operation, NULL means get first operation * @return Operation "after" op */ const NdbOperation * getNextCompletedOperation(const NdbOperation * op)const;#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL const NdbOperation* getFirstDefinedOperation()const{return theFirstOpInList;} const NdbOperation* getLastDefinedOperation()const{return theLastOpInList;} /** @} *********************************************************************/ /** * Execute the transaction in NoCommit mode if there are any not-yet * executed blob part operations of given types. Otherwise do * nothing. The flags argument is bitwise OR of (1 << optype) where * optype comes from NdbOperation::OperationType. Only the basic PK * ops are used (read, insert, update, delete). */ int executePendingBlobOps(Uint8 flags = 0xFF); /** * Get nodeId of TC for this transaction */ Uint32 getConnectedNodeId(); // Get Connected node id#endifprivate: /** * Release completed operations */ void releaseCompletedOperations(); typedef Uint64 TimeMillis_t; /************************************************************************** * These methods are service methods to other classes in the NDBAPI. * **************************************************************************/ /************************************************************************** * These are the create and delete methods of this class. * **************************************************************************/ NdbTransaction(Ndb* aNdb); ~NdbTransaction(); int init(); // Initialize connection object for new transaction int executeNoBlobs(ExecType execType, AbortOption abortOption = AbortOnError, int force = 0 ); /** * Set Connected node id * and sequence no */ void setConnectedNodeId( Uint32 nodeId, Uint32 sequence); void setMyBlockReference( int ); // Set my block refrerence void setTC_ConnectPtr( Uint32 ); // Sets TC Connect pointer int getTC_ConnectPtr(); // Gets TC Connect pointer void setBuddyConPtr(Uint32); // Sets Buddy Con Ptr Uint32 getBuddyConPtr(); // Gets Buddy Con Ptr NdbTransaction* next(); // Returns the next pointer void next(NdbTransaction*); // Sets the next pointer enum ConStatusType { NotConnected, Connecting, Connected, DisConnecting, ConnectFailure }; ConStatusType Status(); // Read the status information void Status(ConStatusType); // Set the status information Uint32 get_send_size(); // Get size to send void set_send_size(Uint32); // Set size to send; int receiveDIHNDBTAMPER(NdbApiSignal* anApiSignal); int receiveTCSEIZECONF(NdbApiSignal* anApiSignal); int receiveTCSEIZEREF(NdbApiSignal* anApiSignal); int receiveTCRELEASECONF(NdbApiSignal* anApiSignal); int receiveTCRELEASEREF(NdbApiSignal* anApiSignal); int receiveTC_COMMITCONF(const class TcCommitConf *); int receiveTCKEYCONF(const class TcKeyConf *, Uint32 aDataLength); int receiveTCKEY_FAILCONF(const class TcKeyFailConf *); int receiveTCKEY_FAILREF(NdbApiSignal* anApiSignal); int receiveTC_COMMITREF(NdbApiSignal* anApiSignal); int receiveTCROLLBACKCONF(NdbApiSignal* anApiSignal); // Rec TCPREPARECONF ? int receiveTCROLLBACKREF(NdbApiSignal* anApiSignal); // Rec TCPREPAREREF ? int receiveTCROLLBACKREP(NdbApiSignal* anApiSignal); int receiveTCINDXCONF(const class TcIndxConf *, Uint32 aDataLength); int receiveTCINDXREF(NdbApiSignal*); int receiveSCAN_TABREF(NdbApiSignal*); int receiveSCAN_TABCONF(NdbApiSignal*, const Uint32*, Uint32 len); int doSend(); // Send all operations int sendROLLBACK(); // Send of an ROLLBACK int sendTC_HBREP(); // Send a TCHBREP signal; int sendCOMMIT(); // Send a TC_COMMITREQ signal; void setGCI(int GCI); // Set the global checkpoint identity int OpCompleteFailure(Uint8 abortoption, bool setFailure = true); int OpCompleteSuccess(); void CompletedOperations(); // Move active ops to list of completed void OpSent(); // Operation Sent with success // Free connection related resources and close transaction void release(); // Release all operations in connection void releaseOperations(); // Release all cursor operations in connection void releaseOps(NdbOperation*); void releaseScanOperations(NdbIndexScanOperation*); bool releaseScanOperation(NdbIndexScanOperation** listhead, NdbIndexScanOperation** listtail, NdbIndexScanOperation* op); void releaseExecutedScanOperation(NdbIndexScanOperation*); // Set the transaction identity of the transaction void setTransactionId(Uint64 aTransactionId); // Indicate something went wrong in the definition phase void setErrorCode(int anErrorCode); // Indicate something went wrong in the definition phase void setOperationErrorCode(int anErrorCode); // Indicate something went wrong in the definition phase void setOperationErrorCodeAbort(int anErrorCode, int abortOption = -1); int checkMagicNumber(); // Verify correct object NdbOperation* getNdbOperation(const class NdbTableImpl* aTable, NdbOperation* aNextOp = 0); NdbIndexScanOperation* getNdbScanOperation(const class NdbTableImpl* aTable); NdbIndexOperation* getNdbIndexOperation(const class NdbIndexImpl* anIndex, const class NdbTableImpl* aTable, NdbOperation* aNextOp = 0); NdbIndexScanOperation* getNdbIndexScanOperation(const NdbIndexImpl* index, const NdbTableImpl* table); void handleExecuteCompletion(); /**************************************************************************** * These are the private variables of this class. ****************************************************************************/ Uint32 ptr2int(); Uint32 theId; // Keeps track of what the send method should do. enum SendStatusType { NotInit, InitState, sendOperations, sendCompleted, sendCOMMITstate, sendABORT, sendABORTfail, sendTC_ROLLBACK, sendTC_COMMIT,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -