UINT32 okSize() const { return _pOkRC ? (UINT32)_pOkRC->size() : 0 ; }
UINT32 nokSize() const { return _pNokRC ? (UINT32)_pNokRC->size() : 0 ; }
//PD_TRACE_DECLARE_FUNCTION ( COORD_OPERATORDEL_EXE, "_coordDeleteOperator::execute" ) INT32 _coordDeleteOperator::execute( MsgHeader *pMsg, pmdEDUCB *cb, INT64 &contextID, rtnContextBuf *buf ) { INT32 rc = SDB_OK ; INT32 rcTmp = SDB_OK ; PD_TRACE_ENTRY ( COORD_OPERATORDEL_EXE ) ; coordSendOptions sendOpt( TRUE ) ; coordSendMsgIn inMsg( pMsg ) ; coordProcessResult result ; ROUTE_RC_MAP nokRC ; result._pNokRC = &nokRC ; coordCataSel cataSel ; MsgRouteID errNodeID ; BSONObj boDeletor ; MsgOpDelete *pDelMsg = (MsgOpDelete *)pMsg ; INT32 oldFlag = pDelMsg->flags ; pDelMsg->flags |= FLG_DELETE_RETURNNUM ; contextID = -1 ; INT32 flag = 0; CHAR *pCollectionName = NULL ; CHAR *pDeletor = NULL ; CHAR *pHint = NULL ; rc = msgExtractDelete( (CHAR*)pMsg, &flag, &pCollectionName, &pDeletor, &pHint ) ; if( rc ) { PD_LOG( PDERROR,"Failed to parse delete request, rc: %d", rc ) ; pCollectionName = NULL ; goto error ; } try { boDeletor = BSONObj( pDeletor ) ; } catch ( std::exception &e ) { PD_RC_CHECK( SDB_INVALIDARG, PDERROR, "Delete failed, received unexpected error: %s", e.what() ) ; } MON_SAVE_OP_DETAIL( cb->getMonAppCB(), pMsg->opCode, "Collection:%s, Deletor:%s, Hint:%s, " "Flag:0x%08x(%u)", pCollectionName, boDeletor.toString().c_str(), BSONObj(pHint).toString().c_str(), oldFlag, oldFlag ) ; rc = cataSel.bind( _pResource, pCollectionName, cb, FALSE, TRUE ) ; if ( rc ) { PD_LOG( PDERROR, "Get or update collection[%s]'s catalog info " "failed, rc: %d", pCollectionName, rc ) ; goto error ; } retry: pDelMsg->version = cataSel.getCataPtr()->getVersion() ; pDelMsg->w = 0 ; rcTmp = doOpOnCL( cataSel, boDeletor, inMsg, sendOpt, cb, result ) ; if ( SDB_OK == rcTmp && nokRC.empty() ) { goto done ; } else if ( checkRetryForCLOpr( rcTmp, &nokRC, cataSel, inMsg.msg(), cb, rc, &errNodeID, TRUE ) ) { nokRC.clear() ; _groupSession.getGroupCtrl()->incRetry() ; goto retry ; } else { PD_LOG( PDERROR, "Delete failed on node[%s], rc: %d", routeID2String( errNodeID ).c_str(), rc ) ; goto error ; } done: if ( oldFlag & FLG_DELETE_RETURNNUM ) { contextID = _recvNum ; } if ( pCollectionName ) { PD_AUDIT_OP( AUDIT_DML, MSG_BS_DELETE_REQ, AUDIT_OBJ_CL, pCollectionName, rc, "DeletedNum:%u, Deletor:%s, Hint:%s, Flag:0x%08x(%u)", _recvNum, boDeletor.toString().c_str(), BSONObj(pHint).toString().c_str(), oldFlag, oldFlag ) ; } PD_TRACE_EXITRC ( COORD_OPERATORDEL_EXE, rc ) ; return rc ; error: if ( buf && nokRC.size() > 0 ) { *buf = rtnContextBuf( coordBuildErrorObj( _pResource, rc, cb, &nokRC ) ) ; } goto done ; }
UINT32 ignoreSize() const { return _pIgnoreRC ? (UINT32)_pIgnoreRC->size() : 0 ; }
//PD_TRACE_DECLARE_FUNCTION ( SDB_RTNCODEL_EXECUTE, "rtnCoordDelete::execute" ) INT32 rtnCoordDelete::execute( MsgHeader *pMsg, pmdEDUCB *cb, INT64 &contextID, rtnContextBuf *buf ) { INT32 rc = SDB_OK ; INT32 rcTmp = SDB_OK ; PD_TRACE_ENTRY ( SDB_RTNCODEL_EXECUTE ) ; pmdKRCB *pKrcb = pmdGetKRCB() ; CoordCB *pCoordcb = pKrcb->getCoordCB() ; netMultiRouteAgent *pRouteAgent = pCoordcb->getRouteAgent() ; // process define rtnSendOptions sendOpt( TRUE ) ; rtnSendMsgIn inMsg( pMsg ) ; rtnProcessResult result ; ROUTE_RC_MAP nokRC ; result._pNokRC = &nokRC ; CoordCataInfoPtr cataInfo ; MsgRouteID errNodeID ; UINT64 deleteNum = 0 ; inMsg._pvtData = ( CHAR* )&deleteNum ; inMsg._pvtType = PRIVATE_DATA_NUMBERLONG ; BSONObj boDeletor ; // fill default-reply(delete success) MsgOpDelete *pDelMsg = (MsgOpDelete *)pMsg ; INT32 oldFlag = pDelMsg->flags ; pDelMsg->flags |= FLG_DELETE_RETURNNUM ; contextID = -1 ; INT32 flag = 0; CHAR *pCollectionName = NULL ; CHAR *pDeletor = NULL ; CHAR *pHint = NULL ; rc = msgExtractDelete( (CHAR*)pMsg, &flag, &pCollectionName, &pDeletor, &pHint ) ; if( rc ) { PD_LOG( PDERROR,"Failed to parse delete request, rc: %d", rc ) ; pCollectionName = NULL ; goto error ; } try { boDeletor = BSONObj( pDeletor ) ; } catch ( std::exception &e ) { PD_RC_CHECK( SDB_INVALIDARG, PDERROR, "Delete failed, received unexpected error:%s", e.what() ) ; } // add last op info MON_SAVE_OP_DETAIL( cb->getMonAppCB(), pMsg->opCode, "Collection:%s, Deletor:%s, Hint:%s, " "Flag:0x%08x(%u)", pCollectionName, boDeletor.toString().c_str(), BSONObj(pHint).toString().c_str(), oldFlag, oldFlag ) ; rc = rtnCoordGetCataInfo( cb, pCollectionName, FALSE, cataInfo ) ; PD_RC_CHECK( rc, PDERROR, "Delete failed, failed to get the " "catalogue info(collection name: %s), rc: %d", pCollectionName, rc ) ; retry: do { pDelMsg->version = cataInfo->getVersion() ; pDelMsg->w = 0 ; if ( cataInfo->isMainCL() ) { rcTmp = doOpOnMainCL( cataInfo, boDeletor, inMsg, sendOpt, pRouteAgent, cb, result ) ; } else { rcTmp = doOpOnCL( cataInfo, boDeletor, inMsg, sendOpt, pRouteAgent, cb, result ) ; } }while( FALSE ) ; if ( SDB_OK == rcTmp && nokRC.empty() ) { goto done ; } else if ( checkRetryForCLOpr( rcTmp, &nokRC, inMsg.msg(), sendOpt._retryTimes, cataInfo, cb, rc, &errNodeID, TRUE ) ) { nokRC.clear() ; ++sendOpt._retryTimes ; goto retry ; } else { PD_LOG( PDERROR, "Delete failed on node[%s], rc: %d", routeID2String( errNodeID ).c_str(), rc ) ; goto error ; } done: if ( oldFlag & FLG_DELETE_RETURNNUM ) { contextID = deleteNum ; } if ( pCollectionName ) { /// AUDIT PD_AUDIT_OP( AUDIT_DML, MSG_BS_DELETE_REQ, AUDIT_OBJ_CL, pCollectionName, rc, "DeletedNum:%u, Deletor:%s, Hint:%s, Flag:0x%08x(%u)", deleteNum, boDeletor.toString().c_str(), BSONObj(pHint).toString().c_str(), oldFlag, oldFlag ) ; } PD_TRACE_EXITRC ( SDB_RTNCODEL_EXECUTE, rc ) ; return rc ; error: goto done ; }