// PD_TRACE_DECLARE_FUNCTION ( SDB_RTNLOCALLOBSTREAM__GETACCESSPRIVILEGE, "_rtnLocalLobStream::_getAccessPrivilege" ) INT32 _rtnLocalLobStream::_getAccessPrivilege( const CHAR *fullName, const bson::OID &oid, INT32 mode ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY( SDB_RTNLOCALLOBSTREAM__GETACCESSPRIVILEGE ) ; for ( INT32 i = 0 ; i < RTN_LOB_ACCESS_PRIVILEGE_RETRY_TIMES ; i++ ) { rc = sdbGetRTNCB()->getLobAccessManager()->getAccessPrivilege( fullName, oid, mode, uniqueId(), SDB_LOB_MODE_WRITE == mode ? &_accessInfo : NULL ) ; if ( SDB_OK == rc ) { _hasLobPrivilege = TRUE ; break ; } else if ( SDB_LOB_IS_IN_USE == rc ) { ossSleepmillis( RTN_LOB_ACCESS_PRIVILEGE_RETRY_INTERVAL ) ; continue ; } else { PD_LOG( PDERROR, "Failed to get lob privilege:%d", rc ) ; goto error ; } } done: PD_TRACE_EXITRC( SDB_RTNLOCALLOBSTREAM__GETACCESSPRIVILEGE, rc ) ; return rc ; error: goto done ; }
_rtnDataSet::~_rtnDataSet() { if ( -1 != _contextID ) { sdbGetRTNCB()->contextDelete( _contextID, _cb ) ; _contextID = -1 ; } }
_rtnDataSet::_rtnDataSet( SINT64 contextID, _pmdEDUCB *cb ) :_contextID( contextID ), _cb( cb ), _lastErr( SDB_OK ), _rtnCB( sdbGetRTNCB() ), _pBuff( NULL ), _ownned( FALSE ) { }
_rtnDataSet::_rtnDataSet( SINT64 contextID, _pmdEDUCB *cb ) :_contextID( contextID ), _cb( cb ), _lastErr( SDB_OK ), _fetchFromContext( TRUE ), _rtnCB( NULL ) { _rtnCB = sdbGetRTNCB() ; }
_rtnDataSet::_rtnDataSet( MsgOpReply *pReply, _pmdEDUCB *cb, BOOLEAN ownned ) :_contextID( -1 ), _cb( cb ), _lastErr( SDB_OK ), _rtnCB( sdbGetRTNCB() ), _pBuff( NULL ), _ownned( FALSE ) { initByReply( pReply, cb, ownned ) ; }
_rtnDataSet::_rtnDataSet( const rtnQueryOptions &options, _pmdEDUCB *cb ) :_contextID( -1 ), _cb( cb ), _lastErr( SDB_OK ), _rtnCB( sdbGetRTNCB() ), _pBuff( NULL ), _ownned( FALSE ) { initByQuery( options, cb ) ; }
void _pmdController::registerCB( SDB_ROLE dbrole ) { // For data node we need DPS ( log ), Transaction, Cluster and Bufferpool if ( SDB_ROLE_DATA == dbrole ) { PMD_REGISTER_CB( sdbGetDPSCB() ) ; // DPS PMD_REGISTER_CB( sdbGetTransCB() ) ; // TRANS PMD_REGISTER_CB( sdbGetClsCB() ) ; // CLS PMD_REGISTER_CB( sdbGetBPSCB() ) ; // BPS } // For coord node we need Transaction, Coordinator and FMP else if ( SDB_ROLE_COORD == dbrole ) { PMD_REGISTER_CB( sdbGetTransCB() ) ; // TRANS PMD_REGISTER_CB( sdbGetCoordCB() ) ; // COORD PMD_REGISTER_CB( sdbGetFMPCB () ) ; // FMP } // For catalog node we need DPS ( log ), Transaction, Cluster, Catalog // Bufferpool and Authentication else if ( SDB_ROLE_CATALOG == dbrole ) { PMD_REGISTER_CB( sdbGetDPSCB() ) ; // DPS PMD_REGISTER_CB( sdbGetTransCB() ) ; // TRANS PMD_REGISTER_CB( sdbGetClsCB() ) ; // CLS PMD_REGISTER_CB( sdbGetCatalogueCB() ) ; // CATALOGUE PMD_REGISTER_CB( sdbGetBPSCB() ) ; // BPS PMD_REGISTER_CB( sdbGetAuthCB() ) ; // AUTH } // For standalone mode we need DPS ( log ), Transaction and Bufferpool else if ( SDB_ROLE_STANDALONE == dbrole ) { PMD_REGISTER_CB( sdbGetDPSCB() ) ; // DPS PMD_REGISTER_CB( sdbGetTransCB() ) ; // TRANS PMD_REGISTER_CB( sdbGetBPSCB() ) ; // BPS } // For OM we need DPS ( log ), transaction, bufferpool, Authentication // and OMService else if ( SDB_ROLE_OM == dbrole ) { PMD_REGISTER_CB( sdbGetDPSCB() ) ; // DPS PMD_REGISTER_CB( sdbGetTransCB() ) ; // TRANS PMD_REGISTER_CB( sdbGetBPSCB() ) ; // BPS PMD_REGISTER_CB( sdbGetAuthCB() ) ; // AUTH PMD_REGISTER_CB( sdbGetOMManager() ) ; // OMSVC } // Everyone need DMS ( data management ), Runtime, SQL, Aggregator // and Controller PMD_REGISTER_CB( sdbGetDMSCB() ) ; // DMS PMD_REGISTER_CB( sdbGetRTNCB() ) ; // RTN PMD_REGISTER_CB( sdbGetSQLCB() ) ; // SQL PMD_REGISTER_CB( sdbGetAggrCB() ) ; // AGGR PMD_REGISTER_CB( sdbGetPMDController() ) ; // CONTROLLER }
_rtnDataSet::_rtnDataSet( const rtnQueryOptions &options, _pmdEDUCB *cb ) :_contextID( -1 ), _cb( cb ), _lastErr( SDB_OK ), _fetchFromContext( TRUE ), _rtnCB( NULL ) { _rtnCB = sdbGetRTNCB() ; _lastErr = rtnQuery( options._fullName, options._query, options._selector, options._orderBy, options._hint, options._flag, _cb, options._skip, options._limit, sdbGetDMSCB(), _rtnCB, _contextID, NULL, FALSE ) ; }
void _rtnDataSet::clear() { _contextBuf.release() ; if ( -1 != _contextID && _cb ) { sdbGetRTNCB()->contextDelete( _contextID, _cb ) ; _contextID = -1 ; } if ( _pBuff && _ownned ) { SDB_OSS_FREE( _pBuff ) ; } _pBuff = NULL ; _ownned = FALSE ; _lastErr = SDB_OK ; }
void _pmdController::registerCB( SDB_ROLE dbrole ) { if ( SDB_ROLE_DATA == dbrole ) { PMD_REGISTER_CB( sdbGetDPSCB() ) ; // DPS PMD_REGISTER_CB( sdbGetTransCB() ) ; // TRANS PMD_REGISTER_CB( sdbGetClsCB() ) ; // CLS PMD_REGISTER_CB( sdbGetBPSCB() ) ; // BPS } else if ( SDB_ROLE_COORD == dbrole ) { PMD_REGISTER_CB( sdbGetTransCB() ) ; // TRANS PMD_REGISTER_CB( sdbGetCoordCB() ) ; // COORD PMD_REGISTER_CB( sdbGetFMPCB () ) ; // FMP } else if ( SDB_ROLE_CATALOG == dbrole ) { PMD_REGISTER_CB( sdbGetDPSCB() ) ; // DPS PMD_REGISTER_CB( sdbGetTransCB() ) ; // TRANS PMD_REGISTER_CB( sdbGetClsCB() ) ; // CLS PMD_REGISTER_CB( sdbGetCatalogueCB() ) ; // CATALOGUE PMD_REGISTER_CB( sdbGetBPSCB() ) ; // BPS PMD_REGISTER_CB( sdbGetAuthCB() ) ; // AUTH } else if ( SDB_ROLE_STANDALONE == dbrole ) { PMD_REGISTER_CB( sdbGetDPSCB() ) ; // DPS PMD_REGISTER_CB( sdbGetTransCB() ) ; // TRANS PMD_REGISTER_CB( sdbGetBPSCB() ) ; // BPS } else if ( SDB_ROLE_OM == dbrole ) { PMD_REGISTER_CB( sdbGetDPSCB() ) ; // DPS PMD_REGISTER_CB( sdbGetTransCB() ) ; // TRANS PMD_REGISTER_CB( sdbGetBPSCB() ) ; // BPS PMD_REGISTER_CB( sdbGetAuthCB() ) ; // AUTH PMD_REGISTER_CB( sdbGetOMManager() ) ; // OMSVC } PMD_REGISTER_CB( sdbGetDMSCB() ) ; // DMS PMD_REGISTER_CB( sdbGetRTNCB() ) ; // RTN PMD_REGISTER_CB( sdbGetSQLCB() ) ; // SQL PMD_REGISTER_CB( sdbGetAggrCB() ) ; // AGGR PMD_REGISTER_CB( sdbGetPMDController() ) ; // CONTROLLER }
INT32 _clsLocalValidation::run() { INT32 rc = SDB_OK ; const UINT32 pLen = 512 ; SDB_RTNCB *rtnCB = sdbGetRTNCB() ; SDB_DMSCB *dmsCB = sdbGetDMSCB() ; CHAR *p = (CHAR *)SDB_OSS_MALLOC( pLen ) ; if ( NULL == p ) { PD_LOG( PDERROR, "failed to allocate mem." ) ; rc = SDB_OOM ; goto error ; } *p = '\0' ; *( p + pLen - 1 ) = '\0' ; /*try { boost::thread t( func ) ; t.join() ; } catch( std::exception &e ) { PD_LOG( PDERROR, "failed to create new thread:%s", e.what() ) ; rc = SDB_SYS ; goto error ; }*/ pmdUpdateValidationTick() ; done: SAFE_OSS_FREE( p ) ; return rc ; error: goto done ; }
void _rtnLocalLobStream::_closeInner( _pmdEDUCB *cb ) { if ( _hasLobPrivilege ) { sdbGetRTNCB()->getLobAccessManager()->releaseAccessPrivilege( getFullName(), getOID(), _getMode(), uniqueId() ) ; _hasLobPrivilege = FALSE ; } if ( _mbContext && _su ) { _su->data()->releaseMBContext( _mbContext ) ; _mbContext = NULL ; } if ( _su && _dmsCB ) { sdbGetDMSCB()->suUnlock ( _su->CSID() ) ; _su = NULL ; } if ( _writeDMS ) { _dmsCB->writeDown( cb ) ; _writeDMS = FALSE ; } }
INT32 _coordCMDListCLInDomain::_rebuildListResult( const vector<BSONObj> &infoFromCata, pmdEDUCB *cb, SINT64 &contextID ) { INT32 rc = SDB_OK ; rtnContext *context = NULL ; SDB_RTNCB *rtnCB = sdbGetRTNCB() ; rc = rtnCB->contextNew( RTN_CONTEXT_DUMP, &context, contextID, cb ) ; if ( SDB_OK != rc ) { PD_LOG( PDERROR, "failed to create new context:%d", rc ) ; goto error ; } rc = (( rtnContextDump * )context)->open( BSONObj(), BSONObj() ) ; if ( SDB_OK != rc ) { PD_LOG( PDERROR, "failed to open context:%d", rc ) ; goto error ; } for ( vector<BSONObj>::const_iterator itr = infoFromCata.begin(); itr != infoFromCata.end(); itr++ ) { BSONElement cl ; BSONElement cs = itr->getField( FIELD_NAME_NAME ) ; if ( String != cs.type() ) { PD_LOG( PDERROR, "invalid collection space info:%s", itr->toString().c_str() ) ; rc = SDB_SYS ; goto error ; } cl = itr->getField( FIELD_NAME_COLLECTION ) ; if ( Array != cl.type() ) { PD_LOG( PDERROR, "invalid collection space info:%s", itr->toString().c_str() ) ; rc = SDB_SYS ; goto error ; } else { BSONObjIterator clItr( cl.embeddedObject() ) ; while ( clItr.more() ) { stringstream ss ; BSONElement clName ; BSONElement oneCl = clItr.next() ; if ( Object != oneCl.type() ) { PD_LOG( PDERROR, "invalid collection space info:%s", itr->toString().c_str() ) ; rc = SDB_SYS ; goto error ; } clName = oneCl.embeddedObject().getField( FIELD_NAME_NAME ) ; if ( String != clName.type() ) { PD_LOG( PDERROR, "invalid collection space info: %s", itr->toString().c_str() ) ; rc = SDB_SYS ; goto error ; } ss << cs.valuestr() << "." << clName.valuestr() ; context->append( BSON( FIELD_NAME_NAME << ss.str() ) ) ; } } } done: return rc ; error: if ( -1 != contextID ) { rtnCB->contextDelete ( contextID, cb ) ; contextID = -1 ; } goto done ; }