BrokerLoadJob的JobState流轉(zhuǎn)過程

  • There are 3 steps in BrokerLoadJob: BrokerPendingTask, LoadLoadingTask, CommitAndPublishTxn.
  • Step1: BrokerPendingTask will be created on method of unprotectedExecuteJob.
  • Step2: LoadLoadingTasks will be created by the method of onTaskFinished when BrokerPendingTask is finished.
  • Step3: CommitAndPublicTxn will be called by the method of onTaskFinished when all of LoadLoadingTasks are finished.

BrokerLoadJob.onTaskFinished

 if (attachment instanceof BrokerPendingTaskAttachment) {
            onPendingTaskFinished((BrokerPendingTaskAttachment) attachment);
        } else if (attachment instanceof BrokerLoadingTaskAttachment) {
            onLoadingTaskFinished((BrokerLoadingTaskAttachment) attachment);
        }

BrokerLoadJob.cancelJobWithoutCheck

Job狀態(tài)轉(zhuǎn)換為cancel

#LoadJob.unprotectedExecuteCancel 
   // change state
        state = JobState.CANCELLED;

BrokerLoadJob.onLoadingTaskFinished

 Catalog.getCurrentGlobalTransactionMgr().commitTransaction(
                    dbId, transactionId, commitInfos,
                    new LoadJobFinalOperation(id, loadingStatus, progress, loadStartTimestamp,
                            finishTimestamp, state, failMsg));

DatabaseTransactionMgr.commitTransaction

transactionState.afterStateTransform

   public void afterStateTransform(TransactionStatus transactionStatus, boolean txnOperated,
                                    String txnStatusChangeReason)
            throws UserException {
        // after status changed
        TxnStateChangeCallback callback = Catalog.getCurrentGlobalTransactionMgr()
                .getCallbackFactory().getCallback(callbackId);
        if (callback != null) {
            switch (transactionStatus) {
                case ABORTED:
                   //ABORTED的時候會調(diào)用unprotectedExecuteCancel ,canal Job
                   //更新JobState 為CANCELLED
                    callback.afterAborted(this, txnOperated, txnStatusChangeReason);
                    break;
                 //COMMITTED 的時候更新JobState 為COMMITTED
                case COMMITTED:
                    callback.afterCommitted(this, txnOperated);
                    break;
                //VISIBLE 的時候更新JobState 為FINISHED
                case VISIBLE:
                    callback.afterVisible(this, txnOperated);
                    break;
                default:
                    break;
            }
        }
    }
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容