INT32 getOption( CHAR **optAddr, UINT32 *optSize = NULL ) const { INT32 rc = SDB_OK ; SDB_ASSERT( optAddr, "Option buffer is NULL" ) ; if ( 0 == _optSize ) { rc = SDB_SYS ; goto error ; } *optAddr = (CHAR *)this + sizeof(_dmsOptExtent) ; if ( optSize ) { *optSize = _optSize ; } done: return rc ; error: goto done ; }
INT32 qgmDump ( _qgmPlanContainer *op, CHAR *pBuffer, INT32 bufferSize ) { INT32 rc = SDB_OK ; INT32 id = 0 ; SDB_ASSERT ( op && pBuffer, "op and pBuffer can't be NULL" ) ; _qgmOperatorElement rootElement ; rc = qgmCalcElement ( op->plan(), &rootElement, id, 0 ) ; PD_RC_CHECK ( rc, PDERROR, "Failed to calc element, rc = %d", rc ) ; rc = qgmAssignPos ( &rootElement, 0 ) ; PD_RC_CHECK ( rc, PDERROR, "Failed to assign pos, rc = %d", rc ) ; rc = qgmPrint ( &rootElement, pBuffer, bufferSize ) ; PD_RC_CHECK ( rc, PDERROR, "Failed to print, rc = %d", rc ) ; id = 0 ; rc = qgmDumpDetails ( op->plan(), pBuffer, bufferSize, id ) ; PD_RC_CHECK ( rc, PDERROR, "Failed to dump details, rc = %d", rc ) ; done : return rc ; error : goto done ; }
INT32 utilStrJoin( const CHAR **src, UINT32 cnt, CHAR *join, UINT32 &joinSize ) { SDB_ASSERT( NULL != join, "impossible" ) ; INT32 rc = SDB_OK ; UINT32 len = 0 ; for ( UINT32 i = 0; i < cnt; i++ ) { if ( NULL != src[i] ) { UINT32 sLen = ossStrlen(src[i]) ; ossMemcpy( join + len, src[i], sLen ) ; len += sLen ; } } joinSize = len ; return rc ; }
// PD_TRACE_DECLARE_FUNCTION ( SDB__DMSSU__RESETCOLLECTION, "_dmsStorageUnit::_resetCollection" ) INT32 _dmsStorageUnit::_resetCollection( dmsMBContext *context ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY ( SDB__DMSSU__RESETCOLLECTION ) ; SDB_ASSERT( context, "context can't be NULL" ) ; rc = _pIndexSu->dropAllIndexes( context, NULL, NULL ) ; if ( rc ) { PD_LOG( PDERROR, "Drop all indexes failed, rc: %d", rc ) ; } rc = _pDataSu->_truncateCollection( context ) ; if ( rc ) { PD_LOG( PDERROR, "Truncate collection data failed, rc: %d", rc ) ; } PD_TRACE_EXITRC ( SDB__DMSSU__RESETCOLLECTION, rc ) ; return rc ; }
void dmsStorageLoadOp::_initExtentHeader ( dmsExtent *extAddr, UINT16 numPages ) { SDB_ASSERT ( _pageSize * numPages == _currentExtentSize, "extent size doesn't match" ) ; extAddr->_eyeCatcher[0] = DMS_EXTENT_EYECATCHER0 ; extAddr->_eyeCatcher[1] = DMS_EXTENT_EYECATCHER1 ; extAddr->_blockSize = numPages ; extAddr->_mbID = 0 ; extAddr->_flag = DMS_EXTENT_FLAG_INUSE ; extAddr->_version = DMS_EXTENT_CURRENT_V ; extAddr->_logicID = DMS_INVALID_EXTENT ; extAddr->_prevExtent = DMS_INVALID_EXTENT ; extAddr->_nextExtent = DMS_INVALID_EXTENT ; extAddr->_recCount = 0 ; extAddr->_firstRecordOffset = DMS_INVALID_EXTENT ; extAddr->_lastRecordOffset = DMS_INVALID_EXTENT ; extAddr->_freeSpace = _pageSize * numPages - sizeof(dmsExtent) ; }
INT32 migMaster::sendMsgToClient ( const CHAR *format, ... ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY ( SDB__MIGLOADJSONPS__SENDMSG ); SDB_ASSERT ( _sock, "_sock is NULL" ) ; va_list ap; pmdEDUCB *eduCB = pmdGetKRCB()->getEDUMgr()->getEDU() ; CHAR buffer[ PD_LOG_STRINGMAX ] ; boost::unique_lock<boost::mutex> lock ( _mutex ) ; ossMemset ( buffer, 0, PD_LOG_STRINGMAX ) ; va_start(ap, format) ; vsnprintf(buffer, PD_LOG_STRINGMAX, format, ap) ; va_end(ap) ; if ( _sendMsg ) { ossMemset ( _sendMsg, 0, _sendSize ) ; } rc = msgBuildMsgMsg ( &_sendMsg, &_sendSize, 0, buffer ) ; if ( rc ) { PD_LOG ( PDERROR, "Failed to msgBuildMsgMsg" ) ; goto error ; } rc = pmdSend ( _sendMsg, *(INT32 *)_sendMsg, _sock, eduCB ) ; if ( rc ) { PD_LOG ( PDERROR, "Failed to send buff, rc=%d", rc ) ; goto error ; } done: PD_TRACE_EXITRC ( SDB__MIGLOADJSONPS__SENDMSG, rc ); return rc ; error: goto done ; }
///PD_TRACE_DECLARE_FUNCTION ( SDB__MTHINCLUDEPARSER_PARSE, "_mthIncludeParser::parse" ) INT32 _mthIncludeParser::parse( const bson::BSONElement &e, _mthSAction &action ) const { INT32 rc = SDB_OK ; PD_TRACE_ENTRY( SDB__MTHINCLUDEPARSER_PARSE ) ; SDB_ASSERT( !e.eoo(), "can not be eoo" ) ; if ( !e.isNumber() ) { PD_LOG( PDERROR, "invalid element type[%d]", e.type() ) ; rc = SDB_INVALIDARG ; goto error ; } #if defined (_DEBUG) if ( 0 != _name.compare( e.fieldName() ) ) { PD_LOG( PDERROR, "field name[%s] is not valid", e.fieldName() ) ; rc = SDB_INVALIDARG ; goto error ; } #endif action.setName( _name.c_str() ) ; if ( 0 == e.numberLong() ) { action.setAttribute( MTH_S_ATTR_EXCLUDE ) ; } else { action.setAttribute( MTH_S_ATTR_INCLUDE ) ; action.setFunc( &mthIncludeBuild, &mthIncludeGet ) ; } done: PD_TRACE_EXITRC( SDB__MTHINCLUDEPARSER_PARSE, rc ) ; return rc ; error: goto done ; }
// PD_TRACE_DECLARE_FUNCTION( SDB__QGMCONDITIONNODEHELPER_SEPARATE2, "_qgmConditionNodeHelper::_separate2" ) void _qgmConditionNodeHelper::_separate( _qgmConditionNode *predicate, qgmConditionNodePtrVec &nodes ) { PD_TRACE_ENTRY( SDB__QGMCONDITIONNODEHELPER_SEPARATE2 ) ; SDB_ASSERT( NULL != predicate, "predicate can't be NULL" ) ; if ( SQL_GRAMMAR::AND == predicate->type ) { _separate( predicate->left, nodes ) ; _separate( predicate->right, nodes ) ; predicate->dettach() ; SAFE_OSS_DELETE( predicate ) ; } else if ( predicate ) { nodes.push_back( predicate ) ; } PD_TRACE_EXIT( SDB__QGMCONDITIONNODEHELPER_SEPARATE2 ) ; }
// PD_TRACE_DECLARE_FUNCTION ( SDB_OSSSK_SETSKLI, "ossSocket::setSocketLi" ) INT32 _ossSocket::setSocketLi ( INT32 lOnOff, INT32 linger ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY ( SDB_OSSSK_SETSKLI ); SDB_ASSERT ( _init, "socket is not initialized" ) ; struct linger _linger ; _linger.l_onoff = lOnOff ; _linger.l_linger = linger ; PD_CHECK( _init, SDB_SYS, error, PDWARNING, "Socket is not init" ) ; rc = setsockopt ( _fd, SOL_SOCKET, SO_LINGER, (const char*)&_linger, sizeof (_linger) ) ; done: PD_TRACE_EXITRC ( SDB_OSSSK_SETSKLI, rc ); return rc ; error: goto done ; }
void *_pmdEDUCB::getAlignedMemory( UINT32 alignment, UINT32 size ) { SDB_ASSERT( alignment == OSS_FILE_DIRECT_IO_ALIGNMENT, "rewrite this function if u want to use new alignment" ) ; if ( _alignedMemSize < size ) { if ( NULL != _alignedMem ) { SDB_OSS_ORIGINAL_FREE( _alignedMem ) ; _alignedMemSize = 0 ; _alignedMem = NULL ; } _alignedMem = ossAlignedAlloc( alignment, size ) ; if ( NULL != _alignedMem ) { _alignedMemSize = size ; } } return _alignedMem ; }
INT32 _qgmPlNLJoin::_modifyInnerCondition( BSONObj &obj ) { PD_TRACE_ENTRY( SDB__QGMPLNLJOIN__MODIFYINNERCONDITION ) ; SDB_ASSERT( NULL != _param, "impossible" ) ; INT32 rc = SDB_OK ; QGM_VARLIST::const_iterator itr = _varlist.begin() ; for ( ; itr != _varlist.end(); itr++ ) { rc = _param->setVar( *itr, obj ) ; if ( SDB_OK != rc ) { goto error ; } } done: PD_TRACE_EXITRC( SDB__QGMPLNLJOIN__MODIFYINNERCONDITION, rc ) ; return rc ; error: goto done ; }
// PD_TRACE_DECLARE_FUNCTION ( SDB__IXMINXCB_GETKEY, "_ixmIndexCB::getKeysFromObject" ) INT32 _ixmIndexCB::getKeysFromObject ( const BSONObj &obj, BSONObjSet &keys ) const { INT32 rc = SDB_OK ; SDB_ASSERT ( _isInitialized, "index details must be initialized first" ) ; PD_TRACE_ENTRY ( SDB__IXMINXCB_GETKEY ); ixmIndexKeyGen keyGen(this) ; rc = keyGen.getKeys ( obj, keys ) ; if ( rc ) { PD_LOG ( PDERROR, "Failed to generate key from object, rc: %d", rc ) ; goto error ; } done : PD_TRACE_EXITRC ( SDB__IXMINXCB_GETKEY, rc ); return rc ; error : goto done ; }
// PD_TRACE_DECLARE_FUNCTION ( SDB__CLSREPSET_UNREGSN, "_clsReplicateSet::unregSession" ) void _clsReplicateSet::unregSession ( _clsDataSrcBaseSession * pSession ) { PD_TRACE_ENTRY ( SDB__CLSREPSET_UNREGSN ); SDB_ASSERT ( pSession, "Session can't be null" ) ; _vecLatch.lock_w () ; std::vector<_clsDataSrcBaseSession*>::iterator it = _vecSrcSessions.begin() ; while ( it != _vecSrcSessions.end() ) { if ( *it == pSession ) { _vecSrcSessions.erase ( it ) ; _srcSessionNum-- ; break ; } ++it ; } _vecLatch.release_w () ; PD_TRACE_EXIT ( SDB__CLSREPSET_UNREGSN ); }
INT32 _qgmPlScan::_executeOnCoord( _pmdEDUCB *eduCB ) { PD_TRACE_ENTRY( SDB__QGMPLSCAN__EXECONCOORD ) ; INT32 rc = SDB_OK ; INT32 bufSize = 0 ; CHAR *qMsg = NULL ; MsgOpReply dummyReply ; BSONObj *err = NULL ; BSONObj selector = _selector.selector() ; rc = msgBuildQueryMsg ( &qMsg, &bufSize, _collection.toString().c_str(),0, 0, _skip, _return, &_condition, &selector, &_orderby, &_hint ) ; if ( SDB_OK != rc ) { goto error ; } rc = _coordQuery.execute ( qMsg, *(SINT32*)qMsg, eduCB, dummyReply, NULL ) ; SDB_ASSERT( NULL == err, "impossible" ) ; PD_RC_CHECK ( rc, PDERROR, "Failed to execute coordQuery, rc = %d", rc ) ; _contextID = dummyReply.contextID ; done: if ( NULL != qMsg ) { SDB_OSS_FREE( qMsg ) ; qMsg = NULL ; } PD_TRACE_EXITRC( SDB__QGMPLSCAN__EXECONCOORD, rc ) ; return rc ; error: goto done ; }
INT32 _coordCMDEval::_buildContext( _spdSession *session, pmdEDUCB *cb, SINT64 &contextID ) { INT32 rc = SDB_OK ; const BSONObj &evalRes = session->getRetMsg() ; SDB_ASSERT( !evalRes.isEmpty(), "impossible" ) ; SDB_RTNCB *rtnCB = pmdGetKRCB()->getRTNCB() ; rtnContextSP *context = NULL ; rc = rtnCB->contextNew ( RTN_CONTEXT_SP, (rtnContext**)&context, contextID, cb ) ; PD_RC_CHECK( rc, PDERROR, "Failed to create new context, rc: %d", rc ) ; rc = context->open( session ) ; PD_RC_CHECK( rc, PDERROR, "Failed to open context[%lld], rc: %d", context->contextID(), rc ) ; done: return rc ; error: goto done ; }
// PD_TRACE_DECLARE_FUNCTION ( SDB_GETEXECNM, "getExecutableName" ) static INT32 getExecutableName ( const CHAR * exeName , CHAR * buf , UINT32 bufSize ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY ( SDB_GETEXECNM ); SDB_ASSERT ( exeName && buf && bufSize > 0 , "invalid argument" ) ; try { string strName = exeName ; string strEnd = ".exe" ; if ( strName.length() <= strEnd.length() || 0 != strName.compare ( strName.length() - strEnd.length() , strEnd.length() , strEnd ) ) { strName += strEnd ; } if ( strName.length() >= bufSize ) { rc = SDB_INVALIDSIZE ; goto error ; } ossStrcpy ( buf , strName.c_str() ) ; } catch ( std::bad_alloc & ) { rc = SDB_OOM ; goto error ; } done : PD_TRACE_EXITRC ( SDB_GETEXECNM, rc ); return rc ; error : goto done ; }
_rtnIXScanner::_rtnIXScanner ( ixmIndexCB *indexCB, rtnPredicateList *predList, dmsStorageUnit *su, pmdEDUCB *cb ) : _predList(predList), _listIterator(*predList), _order(Ordering::make(indexCB->keyPattern())), _su(su), _pMonCtxCB(NULL), _cb(cb), _direction(predList->getDirection()) { SDB_ASSERT ( indexCB && _predList && _su, "indexCB, predList and su can't be NULL" ) ; _dedupBufferSize = RTN_IXSCANNER_DEDUPBUFSZ_DFT ; indexCB->getIndexID ( _indexOID ) ; _indexCBExtent = indexCB->getExtentID () ; _indexLID = indexCB->getLogicalID() ; _indexCB = SDB_OSS_NEW ixmIndexCB ( _indexCBExtent, su->index(), NULL ) ; reset() ; }
BOOLEAN qgmUtilFirstDot( const CHAR *str, UINT32 len, UINT32 &num ) { PD_TRACE_ENTRY( SDB__QGMUTILFIRSTDOT ) ; SDB_ASSERT( NULL != str, "impossible" ) ; BOOLEAN found = FALSE ; UINT32 tLen = 0 ; while ( tLen < len ) { const CHAR *tmp = str + tLen ; if ( '.' == *tmp ) { num = tLen + 1 ; found = TRUE ; break ; } ++tLen ; } PD_TRACE_EXIT( SDB__QGMUTILFIRSTDOT ) ; return found ; }
// PD_TRACE_DECLARE_FUNCTION ( SDB_NETMLTRTAGT_MULTSYNCSND, "netMultiRouteAgent::multiSyncSend" ) void netMultiRouteAgent::multiSyncSend( const ROUTE_SET &routeSet, void *header ) { PD_TRACE_ENTRY ( SDB_NETMLTRTAGT_MULTSYNCSND ); MsgHeader *pHeader = (MsgHeader *)header ; SDB_ASSERT( _pNetWork && header, "_pNetWork && header can't be NULL") ; pHeader->routeID.value = MSG_INVALID_ROUTEID ; ROUTE_SET::const_iterator iterSet = routeSet.begin(); while ( iterSet != routeSet.end() ) { UINT64 reqId = _pReqID->inc(); pHeader->requestID = reqId; MsgRouteID routeID; routeID.value = *iterSet; _pNetWork->syncSend( routeID, header ); ++iterSet; } PD_TRACE_EXIT ( SDB_NETMLTRTAGT_MULTSYNCSND ); }
// PD_TRACE_DECLARE_FUNCTION ( SDB_NETMLTRTAGT_SYNCSENDWITHOUTSESSION, "netMultiRouteAgent::syncSendWithoutSession" ) INT32 netMultiRouteAgent::syncSendWithoutCheck( const MsgRouteID &id, void *header, UINT64 &reqID, pmdEDUCB *pEduCB, void *body, UINT32 bodyLen ) { INT32 rc = SDB_OK; PD_TRACE_ENTRY ( SDB_NETMLTRTAGT_SYNCSENDWITHOUTSESSION ); MsgHeader *pHeader = (MsgHeader *)header ; CoordSession *pSession = NULL; if ( pEduCB ) { pHeader->TID = pEduCB->getTID(); pSession = pEduCB->getCoordSession(); SDB_ASSERT( pSession, "pSession can't be NULL!" ) ; pSession->addSubSessionWithoutCheck( id ); } reqID = _pReqID->inc(); pHeader->requestID = reqID; pHeader->routeID.value = MSG_INVALID_ROUTEID ; PD_LOG ( PDDEBUG, "Send request to node(opCode=%d, requestID=%llu, " "TID=%u, groupID=%u, nodeID=%u, serviceID=%u)", pHeader->opCode, pHeader->requestID, pHeader->TID, id.columns.groupID, id.columns.nodeID, id.columns.serviceID ); if ( !body ) { rc = _pNetWork->syncSend( id, header ); } else { rc = _pNetWork->syncSend( id, pHeader, body, bodyLen ) ; } if ( SDB_OK == rc && pSession ) { pSession->addRequest( reqID, id ); } return rc; PD_TRACE_EXITRC ( SDB_NETMLTRTAGT_SYNCSENDWITHOUTSESSION, rc ); }
// PD_TRACE_DECLARE_FUNCTION ( SDB__DMSROUNIT_IMPMME, "_dmsReorgUnit::importMME" ) INT32 _dmsReorgUnit::importMME ( const CHAR *pMME ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY ( SDB__DMSROUNIT_IMPMME ); SDB_ASSERT ( pMME, "pMME can't be NULL" ) ; INT32 restSize = DMS_MB_SIZE ; INT64 writeSize = 0 ; INT32 bufSize = restSize ; if ( _readOnly ) { PD_LOG ( PDERROR, "Modify is not allowed" ) ; rc = SDB_DMS_REORG_FILE_READONLY ; goto error ; } rc = ossSeek ( &_file, _headSize, OSS_SEEK_SET ) ; if ( rc ) { PD_LOG ( PDERROR, "Failed to seek to %d from file %s, rc = %d", _headSize, _fileName, rc ) ; goto error ; } while ( restSize != 0 ) { rc = ossWrite ( &_file, &pMME[bufSize-restSize], restSize, &writeSize ) ; if ( rc && SDB_INTERRUPT != rc ) { PD_LOG ( PDERROR, "Failed to write MME into file: %s, rc = %d", _fileName, rc ) ; goto error ; } restSize -= (INT32)writeSize ; rc = SDB_OK ; } done : PD_TRACE_EXITRC ( SDB__DMSROUNIT_IMPMME, rc ); return rc ; error : goto done ; }
HANDLE ossGetSysMutexHandle( SYS_MUTEX_TYPE type ) { static HANDLE s_sysMutexes[ _NumOfFunctions ] = {0} ; static BOOLEAN s_init = FALSE ; static ossSpinXLatch s_latch ; if ( FALSE == s_init ) { s_latch.get() ; if ( FALSE == s_init ) { for ( int i = _SymInitialize; i < _NumOfFunctions ; i++ ) { if ( ! s_sysMutexes[i] ) { if ( i != _SymCleanup ) { s_sysMutexes[i] = CreateMutex( NULL, // default security attr false, // initially not owned NULL ) ; // unnamed mutex } else { s_sysMutexes[i] = s_sysMutexes[ _SymInitialize ] ; } } } s_init = TRUE ; } s_latch.release() ; } if ( type >= _SymInitialize && type < _NumOfFunctions ) { return s_sysMutexes[ (INT32)type ] ; } SDB_ASSERT( FALSE, "Invalid sys mutex type" ) ; return 0 ; }
// PD_TRACE_DECLARE_FUNCTION ( SDB__SDB_DMSCB_DROPCSP1, "_SDB_DMSCB::dropCollectionSpaceP1" ) INT32 _SDB_DMSCB::dropCollectionSpaceP1 ( const CHAR *pName, _pmdEDUCB *cb, SDB_DPSCB *dpsCB ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY ( SDB__SDB_DMSCB_DROPCSP1 ) ; if ( !pName ) { rc = SDB_INVALIDARG ; goto error ; } { _mutex.get_shared() ; SDB_DMS_CSCB *cscb = NULL; rc = _CSCBNameLookup( pName, &cscb ) ; if ( rc ) { _mutex.release_shared() ; goto error ; } dmsStorageUnit *su = cscb->_su ; SDB_ASSERT ( su, "storage unit pointer can't be NULL" ) ; _mutex.release_shared() ; rc = _CSCBNameRemoveP1( pName, cb, dpsCB ) ; if ( rc ) { PD_LOG( PDERROR, "Failed to drop cs[%s], rc: %d", pName, rc ) ; goto error ; } } done : PD_TRACE_EXITRC ( SDB__SDB_DMSCB_DROPCSP1, rc ); return rc ; error : goto done ; }
///PD_TRACE_DECLARE_FUNCTION ( SDB__MTHSACTIONPARSER_GETACTION, "_mthSActionParser::getAction" ) INT32 _mthSActionParser::parse( const bson::BSONElement &e, _mthSAction &action ) const { INT32 rc = SDB_OK ; PD_TRACE_ENTRY( SDB__MTHSACTIONPARSER_GETACTION ) ; SDB_ASSERT( !e.eoo(), "can not be invalid" ) ; const CHAR *fieldName = e.fieldName() ; action.clear() ; if ( '$' != *fieldName ) { goto done ; } { PARSERS::const_iterator itr = _parsers.find( fieldName ) ; if ( _parsers.end() == itr ) { PD_LOG( PDERROR, "can not find the parser of action[%s]", fieldName ) ; rc = SDB_INVALIDARG ; goto error ; } rc = itr->second->parse( e, action ) ; if ( SDB_OK != rc ) { PD_LOG( PDERROR, "failed to parse action:%d", rc ) ; goto error ; } } done: PD_TRACE_EXITRC( SDB__MTHSACTIONPARSER_GETACTION, rc ) ; return rc ; error: goto done ; }
// PD_TRACE_DECLARE_FUNCTION( SDB__QGMPTRTABLE_GETOWNFIELD, "_qgmPtrTable::getOwnField" ) INT32 _qgmPtrTable::getOwnField( const CHAR *begin, UINT32 size, qgmField &field ) { PD_TRACE_ENTRY( SDB__QGMPTRTABLE_GETOWNFIELD ) ; SDB_ASSERT( NULL != begin, "impossible" ) ; INT32 rc = SDB_OK ; qgmField f ; PTR_TABLE::const_iterator itr ; if ( NULL == begin || 0 == size ) { rc = SDB_INVALIDARG ; goto error ; } f._begin = begin ; f._size = size ; f._ptrTable = this ; itr = _table.find( f ) ; if ( _table.end() == itr ) { field._begin = getOwnedString( f.toString().c_str() ) ; field._size = ossStrlen( field._begin ) ; field._ptrTable = this ; _table.insert( field ) ; } else { field = *itr ; } done: PD_TRACE_EXITRC( SDB__QGMPTRTABLE_GETOWNFIELD, rc ) ; return rc ; error: goto done ; }
// PD_TRACE_DECLARE_FUNCTION ( SDB__DMSSU_INSERTRECORD, "_dmsStorageUnit::insertRecord" ) INT32 _dmsStorageUnit::insertRecord ( const CHAR *pName, BSONObj &record, pmdEDUCB *cb, SDB_DPSCB *dpscb, BOOLEAN mustOID, BOOLEAN canUnLock, dmsMBContext *context ) { INT32 rc = SDB_OK ; BOOLEAN getContext = FALSE ; PD_TRACE_ENTRY ( SDB__DMSSU_INSERTRECORD ) ; if ( NULL == context ) { SDB_ASSERT( pName, "Collection name can't be NULL" ) ; rc = _pDataSu->getMBContext( &context, pName, -1 ) ; PD_RC_CHECK( rc, PDERROR, "Get collection[%s] mb context failed, " "rc: %d", pName, rc ) ; getContext = TRUE ; } rc = _pDataSu->insertRecord( context, record, cb, dpscb, mustOID, canUnLock ) ; if ( rc ) { goto error ; } done : if ( getContext && context ) { _pDataSu->releaseMBContext( context ) ; } PD_TRACE_EXITRC ( SDB__DMSSU_INSERTRECORD, rc ) ; return rc ; error : goto done ; }
void _pmdSession::attach( _pmdEDUCB * cb ) { SDB_ASSERT( cb, "cb can't be NULL" ) ; PD_LOG( PDINFO, "Session[%s] attach edu[%d]", sessionName(), cb->getID() ) ; _pDPSCB = pmdGetKRCB()->getDPSCB() ; if ( SDB_ROLE_COORD != pmdGetDBRole() && _pDPSCB && !_pDPSCB->isLogLocal() ) { _pDPSCB = NULL ; } _pEDUCB = cb ; _eduID = cb->getID() ; _pEDUCB->attachSession( this ) ; _pEDUCB->setName( sessionName() ) ; _pEDUCB->setClientSock( socket() ) ; _client.attachCB( cb ) ; _onAttach() ; }
void ossSHMDetach( ossSHMMid & shmMid, CHAR **ppBuf ) { SDB_ASSERT( ppBuf != NULL, "ppBuf can't be NULL!" ) ; #if defined (_LINUX) if ( NULL != ppBuf ) { shmdt( *ppBuf ); *ppBuf = NULL; } shmMid = -1; #elif defined (_WINDOWS) if ( *ppBuf != NULL ) { UnmapViewOfFile( *ppBuf ); *ppBuf = NULL; } if ( shmMid != NULL ) { CloseHandle( shmMid ); shmMid = NULL; } #endif }
// PD_TRACE_DECLARE_FUNCTION ( SDB__DPSLOGFILE_RESET, "_dpsLogFile::reset" ) INT32 _dpsLogFile::reset ( UINT32 logID, const DPS_LSN_OFFSET &offset, const DPS_LSN_VER &version ) { PD_TRACE_ENTRY ( SDB__DPSLOGFILE_RESET ); if ( DPS_INVALID_LOG_FILE_ID != logID ) { SDB_ASSERT ( offset/_fileSize == logID , "logical log file id error" ) ; _logHeader._firstLSN.offset= offset ; _logHeader._firstLSN.version = version ; } else { _logHeader._firstLSN.version = DPS_INVALID_LSN_VERSION ; _logHeader._firstLSN.offset = DPS_INVALID_LSN_OFFSET ; } _logHeader._logID = logID ; _idleSize = _fileSize ; _dirty = FALSE ; INT32 rc = _flushHeader () ; PD_TRACE_EXITRC ( SDB__DPSLOGFILE_RESET, rc ); return rc ; }
INT32 _SDB_DMSCB::nameToSUAndLock ( const CHAR *pName, dmsStorageUnitID &suID, _dmsStorageUnit **su, OSS_LATCH_MODE lockType, INT32 millisec ) { INT32 rc = SDB_OK; SDB_DMS_CSCB *cscb = NULL; SDB_ASSERT( su, "su can't be null!" ); if ( !pName ) { return SDB_INVALIDARG ; } ossScopedLock _lock(&_mutex, SHARED) ; rc = _CSCBNameLookupAndLock( pName, suID, &cscb, lockType, millisec ) ; if ( SDB_OK == rc ) { *su = cscb->_su; } return rc ; }