// PD_TRACE_DECLARE_FUNCTION( SDB__QGMPTRTABLE_GETOWNATTR, "_qgmPtrTable::getOwnAttr" ) INT32 _qgmPtrTable::getOwnAttr( const CHAR *begin, UINT32 size, qgmDbAttr &attr ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY( SDB__QGMPTRTABLE_GETOWNATTR ) ; UINT32 pos = 0 ; BOOLEAN hasDot = qgmUtilFirstDot( begin, size, pos ) ; if ( hasDot && ( 0 == pos || size - 1 == pos ) ) { PD_LOG( PDERROR, "the first char and the last char can not be '.'" ) ; rc = SDB_INVALIDARG ; goto error ; } if ( hasDot ) { rc = getOwnField( begin, pos, attr.relegation() ) ; if ( SDB_OK != rc ) { goto error ; } ++pos ; } rc = getOwnField( begin + pos, size - pos, attr.attr() ) ; if ( SDB_OK != rc ) { goto error ; } done: PD_TRACE_EXITRC( SDB__QGMPTRTABLE_GETOWNATTR, rc ) ; return rc ; error: goto done ; }
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 ; }
// PD_TRACE_DECLARE_FUNCTION ( SDB_RTNCOORDCLOSELOB_EXECUTE, "rtnCoordCloseLob::execute" ) INT32 rtnCoordCloseLob::execute( CHAR *pReceiveBuffer, SINT32 packSize, CHAR **ppResultBuffer, pmdEDUCB *cb, MsgOpReply &replyHeader, BSONObj** ppErrorObj ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY( SDB_RTNCOORDCLOSELOB_EXECUTE ) ; const MsgOpLob *header = NULL ; const MsgHeader *baseHeader = ( const MsgHeader * )pReceiveBuffer ; replyHeader.header.messageLength = sizeof( MsgOpReply ) ; replyHeader.header.opCode = MSG_BS_LOB_CLOSE_RES ; replyHeader.header.requestID = baseHeader->requestID ; replyHeader.header.routeID.value = 0 ; replyHeader.header.TID = baseHeader->TID ; replyHeader.contextID = -1 ; replyHeader.flags = SDB_OK ; replyHeader.numReturned = 0 ; replyHeader.startFrom = 0 ; rc = msgExtractCloseLobRequest( pReceiveBuffer, &header ) ; if ( SDB_OK != rc ) { PD_LOG( PDERROR, "failed to extract msg:%d", rc ) ; goto error ; } rc = rtnCloseLob( header->contextID, cb ) ; if ( SDB_OK != rc ) { PD_LOG( PDERROR, "failed to close lob:%d", rc ) ; goto error ; } done: PD_TRACE_EXITRC( SDB_RTNCOORDCLOSELOB_EXECUTE, rc ) ; return rc ; error: replyHeader.flags = rc ; goto done ; }
// PD_TRACE_DECLARE_FUNCTION ( SDB_OSSSK__GETADDR, "ossSocket::_getAddress" ) INT32 _ossSocket::_getAddress ( sockaddr_in *addr, CHAR *pAddress, UINT32 length ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY ( SDB_OSSSK__GETADDR ); length = length < NI_MAXHOST ? length : NI_MAXHOST ; rc = getnameinfo ( (struct sockaddr *)addr, sizeof(sockaddr), pAddress, length, NULL, 0, NI_NUMERICHOST ) ; if ( rc ) { PD_LOG ( PDERROR, "Failed to getnameinfo, rc = %d", SOCKET_GETLASTERROR ) ; rc = SDB_NETWORK ; goto error ; } done : PD_TRACE_EXITRC ( SDB_OSSSK__GETADDR, rc ); return rc ; error : goto done ; }
// 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_RTNLOCALLOBSTREAM__ENSURELOB, "_rtnLocalLobStream::_ensureLob" ) INT32 _rtnLocalLobStream::_ensureLob( _pmdEDUCB *cb, _dmsLobMeta &meta, BOOLEAN &isNew ) { INT32 rc = SDB_OK ; _dmsLobMeta tmpMeta ; PD_TRACE_ENTRY( SDB_RTNLOCALLOBSTREAM__ENSURELOB ) ; rc = _su->lob()->getLobMeta( getOID(), _mbContext, cb, tmpMeta ) ; if ( SDB_OK == rc ) { if ( !tmpMeta.isDone() ) { PD_LOG( PDINFO, "Lob[%s] meta[%s] is not available", getOID().str().c_str(), tmpMeta.toString().c_str() ) ; rc = SDB_LOB_IS_NOT_AVAILABLE ; goto error ; } isNew = FALSE ; goto done ; } else if ( SDB_FNE != rc ) { PD_LOG( PDERROR, "Failed to get meta of lob, rc:%d", rc ) ; goto error ; } else { rc = SDB_OK ; isNew = TRUE ; } done: PD_TRACE_EXITRC( SDB_RTNLOCALLOBSTREAM__ENSURELOB, rc ) ; return rc ; error: goto done ; }
INT32 _dpsLogPage::fill( UINT32 offset, const CHAR *src, UINT32 len ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY ( SDB__DPSLGPAGE ); if ( !_mb ) { _mb = SDB_OSS_NEW _dpsMessageBlock( DPS_DEFAULT_PAGE_SIZE ); if ( NULL == _mb ) { pdLog(PDERROR, __FUNC__, __FILE__, __LINE__, "new _dpsMessageBlock failed!"); rc = SDB_OOM ; goto error ; } } ossMemcpy ( _mb->offset( offset ), src, len ) ; done : PD_TRACE_EXITRC ( SDB__DPSLGPAGE, rc ); return rc ; error : goto done ; }
// 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 ; }
INT32 _qgmPlNLJoin::_init() { PD_TRACE_ENTRY( SDB__QGMPLNLJOIN__INIT ) ; INT32 rc = SDB_OK ; SDB_ASSERT( SQL_GRAMMAR::SQLMAX != _joinType, "impossible" ) ; SDB_ASSERT( 2 == inputSize(), "impossible" ) ; if ( SQL_GRAMMAR::R_OUTERJOIN == _joinType ) { _joinType = SQL_GRAMMAR::L_OUTERJOIN ; _outerAlias = &(input( 1 )->alias()) ; _outer = input( 1 ) ; _innerAlias = &(input( 0 )->alias()) ; _inner = input( 0 ) ; } else { _outerAlias = &(input( 0 )->alias()) ; _outer = input( 0 ) ; _innerAlias = &(input( 1 )->alias()) ; _inner = input( 1 ) ; } _innerF = SDB_OSS_NEW qgmFetchOut() ; if ( NULL == _innerF ) { PD_LOG( PDERROR, "failed to allocate mem." ) ; rc = SDB_OOM ; goto error ; } _makeOuterInner = TRUE ; done: PD_TRACE_EXITRC( SDB__QGMPLNLJOIN__INIT, rc ) ; 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 ; }
// PD_TRACE_DECLARE_FUNCTION( SDB__UTILCOMPRESSORSNAPPY_COMPRESS, "_utilCompressorSnappy::compress") INT32 _utilCompressorSnappy::compress( const CHAR *source, UINT32 sourceLen, CHAR *dest, UINT32 &destLen, const utilDictHandle dictionary, const utilCompressStrategy *strategy ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY( SDB__UTILCOMPRESSORSNAPPY_COMPRESS ) ; size_t resultLen = 0 ; (void)dictionary ; (void)strategy ; SDB_ASSERT( UTIL_INVALID_DICT == dictionary, "snappy does not use any dictionary" ) ; SDB_ASSERT( destLen >= (UINT32)snappy::MaxCompressedLength( sourceLen ), "Buffer for decompressed data is not big enough" ) ; snappy::RawCompress ( source, (size_t)sourceLen, dest, &resultLen ) ; destLen = ( UINT32 )resultLen ; PD_TRACE_EXITRC( SDB__UTILCOMPRESSORSNAPPY_COMPRESS, rc ) ; return rc ; }
INT32 restAdaptor::init( INT32 maxHttpHeaderSize, INT32 maxHttpBodySize, INT32 timeout ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY( SDB__RESTADP_INIT ); http_parser_settings *pSettings = NULL ; pSettings = (http_parser_settings *)SDB_OSS_MALLOC( sizeof( http_parser_settings ) ) ; if ( !pSettings ) { rc = SDB_OOM ; PD_LOG ( PDERROR, "Unable to allocate %d bytes memory", sizeof( http_parser_settings ) ) ; goto error ; } ossMemset( pSettings, 0, sizeof( http_parser_settings ) ) ; pSettings->on_message_begin = restAdaptor::on_message_begin ; pSettings->on_url = restAdaptor::on_url ; pSettings->on_header_field = restAdaptor::on_header_field ; pSettings->on_header_value = restAdaptor::on_header_value ; pSettings->on_headers_complete = restAdaptor::on_headers_complete ; pSettings->on_body = restAdaptor::on_body ; pSettings->on_message_complete = restAdaptor::on_message_complete ; _maxHttpHeaderSize = maxHttpHeaderSize ; _maxHttpBodySize = maxHttpBodySize ; _timeout = timeout ; _pSettings = pSettings ; done: PD_TRACE_EXITRC ( SDB__RESTADP_INIT, rc ) ; return rc ; error: goto done ; }
// PD_TRACE_DECLARE_FUNCTION ( SDB__DPSLGWRAPP_COMPLETEOPR, "_dpsLogWrapper::completeOpr" ) INT32 _dpsLogWrapper::completeOpr( _pmdEDUCB * cb, INT32 w ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY ( SDB__DPSLGWRAPP_COMPLETEOPR ) ; if ( w > 1 && cb && 0 != cb->getLsnCount() && _vecEventHandler.size() > 0 ) { for( UINT32 i = 0 ; i < _vecEventHandler.size() ; ++i ) { rc = _vecEventHandler[i]->onCompleteOpr( cb, w ) ; if ( rc ) { break ; } } cb->resetLsn() ; } PD_TRACE_EXITRC ( SDB__DPSLGWRAPP_COMPLETEOPR, rc ) ; return rc ; }
// PD_TRACE_DECLARE_FUNCTION( SDB__QGMPLCOMMAND__FETCHNEXT, "_qgmPlCommand::_fetchNext" ) INT32 _qgmPlCommand::_fetchNext( qgmFetchOut &next ) { PD_TRACE_ENTRY( SDB__QGMPLCOMMAND__FETCHNEXT ) ; INT32 rc = SDB_OK ; rtnContextBuf buffObj ; SDB_RTNCB *rtnCB = pmdGetKRCB()->getRTNCB() ; rc = rtnGetMore( _contextID, 1, buffObj, _eduCB, rtnCB ) ; if ( SDB_OK != rc ) { if ( SDB_DMS_EOC != rc ) { PD_LOG( PDERROR, "Failed to getmore from non-coord, rc = %d", rc) ; } goto error ; } try { next.obj = BSONObj( buffObj.data() ) ; } catch ( std::exception &e ) { PD_LOG( PDERROR, "unexcepted err happened:%s", e.what() ) ; rc = SDB_SYS ; goto error ; } done: PD_TRACE_EXITRC( SDB__QGMPLCOMMAND__FETCHNEXT, rc ) ; return rc ; error: if ( SDB_DMS_EOC == rc ) _contextID = -1 ; goto done ; }
// 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__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 ; }
// 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_RTNLOCALLOBSTREAM__WRITE, "_rtnLocalLobStream::_write" ) INT32 _rtnLocalLobStream::_write( const _rtnLobTuple &tuple, _pmdEDUCB *cb, BOOLEAN orUpdate ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY( SDB_RTNLOCALLOBSTREAM__WRITE ) ; _dmsLobRecord record ; record.set( &getOID(), tuple.tuple.columns.sequence, tuple.tuple.columns.offset, tuple.tuple.columns.len, tuple.data ) ; if ( orUpdate ) { rc = _su->lob()->writeOrUpdate( record, _mbContext, cb, _getDPSCB() ) ; } else { rc = _su->lob()->write( record, _mbContext, cb, _getDPSCB() ) ; } if ( SDB_OK != rc ) { PD_LOG( PDERROR, "failed to write lob[%s]," "sequence:%d, rc:%d", record._oid->str().c_str(), record._sequence, rc ) ; goto error ; } done: PD_TRACE_EXITRC( SDB_RTNLOCALLOBSTREAM__WRITE, 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__DPSLGWRAPP_ACTIVE, "_dpsLogWrapper::active" ) INT32 _dpsLogWrapper::active () { INT32 rc = SDB_OK ; PD_TRACE_ENTRY ( SDB__DPSLGWRAPP_ACTIVE ) ; pmdEDUMgr *pEDUMgr = pmdGetKRCB()->getEDUMgr() ; EDUID eduID = PMD_INVALID_EDUID ; rc = pEDUMgr->startEDU( EDU_TYPE_LOGGW, (void*)this, &eduID ) ; if ( rc ) { PD_LOG( PDERROR, "Start dps log writer failed, rc: %d", rc ) ; goto error ; } rc = pEDUMgr->startEDU( EDU_TYPE_DPSROLLBACK, NULL, &eduID ) ; if ( rc ) { PD_LOG( PDERROR, "Start dps trans rollback failed, rc: %d", rc ) ; goto error ; } if ( pmdGetKRCB()->getOptionCB()->archiveOn() ) { rc = pEDUMgr->startEDU( EDU_TYPE_LOGARCHIVEMGR, (void*)this, &eduID ) ; if ( rc ) { PD_LOG( PDERROR, "Start dps log archiving failed, rc: %d", rc ) ; goto error ; } } done: PD_TRACE_EXITRC( SDB__DPSLGWRAPP_ACTIVE, rc ) ; return rc ; error: goto done ; }
INT32 _qgmMatcher::match( const qgmFetchOut &fetch, BOOLEAN &r ) { PD_TRACE_ENTRY( SDB__QGMMATCHER_MATCH ) ; INT32 rc = SDB_OK ; if ( !ready() ) { PD_LOG( PDERROR, "matcher is not ready yet" ) ; rc = SDB_SYS ; goto error ; } rc = _match( _condition, fetch, r ) ; if ( SDB_OK != rc ) { goto error ; } done: PD_TRACE_EXITRC( SDB__QGMMATCHER_MATCH, rc ) ; return rc ; error: goto done ; }
// 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 ; }
// PD_TRACE_DECLARE_FUNCTION (SDB__CLSREELECTION__WAIT4ALLWRITEDONE, "_clsReelection::_wait4AllWriteDone" ) INT32 _clsReelection::_wait4AllWriteDone( UINT32 &timePassed, UINT32 timeout, pmdEDUCB *cb ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY( SDB__CLSREELECTION__WAIT4ALLWRITEDONE ) ; pmdEDUMgr *eduMgr = pmdGetKRCB()->getEDUMgr() ; UINT32 writingCount = 0 ; while ( timePassed < timeout ) { if ( cb->isInterrupted() ) { rc = SDB_APP_INTERRUPT ; goto error ; } writingCount = eduMgr->getWritingEDUCount() ; if ( 0 == writingCount ) { break ; } ossSleepsecs( 1 ) ; ++timePassed ; } if ( 0 < writingCount ) { rc = SDB_TIMEOUT ; goto error ; } done: PD_TRACE_EXITRC( SDB__CLSREELECTION__WAIT4ALLWRITEDONE, rc ) ; return rc ; error: goto done ; }
// PD_TRACE_DECLARE_FUNCTION ( SDB__MTHSELECTOR__RESORTOBJ, "_mthSelector::_resortObj" ) INT32 _mthSelector::_resortObj( const bson::BSONObj &pattern, const bson::BSONObj &src, bson::BSONObj &obj ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY( SDB__MTHSELECTOR__RESORTOBJ ) ; BSONObjBuilder builder ; hash_map fMap ; BSONObjIterator i( src ) ; while ( i.more() ) { BSONElement e = i.next() ; fMap.insert( std::make_pair( e.fieldName(), e ) ) ; } BSONObjIterator j( pattern ) ; while ( j.more() ) { BSONElement e = j.next() ; hash_map::const_iterator itr = fMap.find( e.fieldName() ) ; if ( fMap.end() != itr ) { builder.append( itr->second ) ; } else { PD_LOG( PDWARNING, "field[%s] in pattern does not exist in src[%s]", e.fieldName(), src.toString( FALSE, TRUE ).c_str() ) ; } } obj = builder.obj() ; PD_TRACE_EXITRC( SDB__MTHSELECTOR__RESORTOBJ, rc ) ; return rc ; }
INT32 _rtnIXScanner::relocateRID ( const BSONObj &keyObj, const dmsRecordID &rid ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY ( SDB__RTNIXSCAN_RELORID1 ) ; PD_CHECK ( _indexCB, SDB_OOM, error, PDERROR, "Failed to allocate memory for indexCB" ) ; PD_CHECK ( _indexCB->isInitialized(), SDB_RTN_INDEX_NOTEXIST, error, PDERROR, "Index does not exist" ) ; PD_CHECK ( _indexCB->getFlag() == IXM_INDEX_FLAG_NORMAL, SDB_IXM_UNEXPECTED_STATUS, error, PDERROR, "Unexpected index status: %d", _indexCB->getFlag() ) ; { monAppCB * pMonAppCB = _cb ? _cb->getMonAppCB() : NULL ; dmsExtentID rootExtent = _indexCB->getRoot() ; ixmExtent root ( rootExtent, _su->index() ) ; BOOLEAN found = FALSE ; rc = root.locate ( keyObj, rid, _order, _curIndexRID, found, _direction, _indexCB ) ; PD_RC_CHECK ( rc, PDERROR, "Failed to locate from new keyobj and rid: %s, %d,%d", keyObj.toString().c_str(), rid._extent, rid._offset ) ; _savedObj = keyObj.copy() ; _savedRID = rid ; DMS_MON_OP_COUNT_INC( pMonAppCB, MON_INDEX_READ, 1 ) ; DMS_MON_CONTEXT_COUNT_INC ( _pMonCtxCB, MON_INDEX_READ, 1 ) ; } _init = TRUE ; done : PD_TRACE_EXITRC ( SDB__RTNIXSCAN_RELORID1, rc ) ; return rc ; error : goto done ; }
// PD_TRACE_DECLARE_FUNCTION ( SDB__RTNCONTEXTLOB_READ, "_rtnContextLob::read" ) INT32 _rtnContextLob::read( UINT32 len, SINT64 offset, _pmdEDUCB *cb ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY( SDB__RTNCONTEXTLOB_READ ) ; _readLen = len ; _offset = offset ; if ( -1 != _offset && _offset != _stream->curOffset() ) { _empty() ; /// clear data in context. rc = _stream->seek( _offset, cb ) ; if ( SDB_OK != rc ) { PD_LOG( PDERROR, "failed to seek lob:%d", rc ) ; goto error ; } } done: PD_TRACE_EXITRC( SDB__RTNCONTEXTLOB_READ, rc ) ; return rc ; error: goto done ; }
// PD_TRACE_DECLARE_FUNCTION ( SDB_OSSREGSIGHND, "ossRegisterSignalHandle" ) INT32 ossRegisterSignalHandle ( ossSigSet & sigSet, SIG_HANDLE handle ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY ( SDB_OSSREGSIGHND ); struct sigaction newact ; sigemptyset ( &newact.sa_mask ) ; newact.sa_flags = 0 ; newact.sa_handler = ( __sighandler_t )handle ; sigSet.sigDel ( SIGKILL ) ; sigSet.sigDel ( SIGSTOP ) ; INT32 sig = 1 ; while ( sig <= OSS_MAX_SIGAL ) { if ( sigSet.isMember( sig ) && sigaction ( sig, &newact, NULL ) ) { PD_LOG ( PDWARNING, "Failed to register signal handler for %d, " "errno = %d", sig, ossGetLastError() ) ; } ++sig ; } PD_TRACE_EXITRC ( SDB_OSSREGSIGHND, rc ); return rc ; }
INT32 _dpsLogPage::allocate( UINT32 len ) { INT32 rc = SDB_OK; PD_TRACE_ENTRY ( SDB__DPSLGPAGE2 ); if ( !_mb ) { _mb = SDB_OSS_NEW _dpsMessageBlock( DPS_DEFAULT_PAGE_SIZE ); if ( NULL == _mb ) { pdLog(PDERROR, __FUNC__, __FILE__, __LINE__, "new _dpsMessageBlock failed!"); rc = SDB_OOM ; goto error ; } } SDB_ASSERT ( getLastSize() >= len, "len is greater than buffer size" ) ; _mb->writePtr( len + _mb->length() ); done : PD_TRACE_EXITRC ( SDB__DPSLGPAGE2, rc ); return rc ; error : goto done ; }
INT32 restAdaptor::getHttpHeader( pmdRestSession *pSession, const CHAR *pKey, const CHAR **ppValue ) { INT32 rc = SDB_OK ; SDB_ASSERT ( pSession, "pSession is NULL" ) ; SDB_ASSERT ( pKey, "pKey is NULL" ) ; SDB_ASSERT ( ppValue, "ppValue is NULL" ) ; PD_TRACE_ENTRY( SDB__RESTADP_GETHEADER ) ; httpConnection *pHttpCon = pSession->getRestConn() ; COLNAME_MAP_IT it ; it = pHttpCon->_requestHeaders.find( pKey ) ; if ( it == pHttpCon->_requestHeaders.end() ) { *ppValue = NULL ; } else { *ppValue = it->second ; } PD_TRACE_EXITRC( SDB__RESTADP_GETHEADER, rc ) ; return rc ; }
INT32 restAdaptor::_parse_http_query( httpConnection *pHttpConnection, CHAR *pBuffer, INT32 length ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY( SDB__RESTADP_PARQUERY ) ; INT32 keyOffset = 0 ; INT32 valueOffset = 0 ; const CHAR *pValueBuf = NULL ; for ( INT32 i = 0; i < length; ++i ) { if ( pBuffer[i] == '=' && pValueBuf == NULL ) { pBuffer[i] = 0 ; valueOffset = i + 1 ; pValueBuf = pBuffer + valueOffset ; } else if ( pBuffer[i] == '&' || ( i + 1 == length ) ) { if ( i + 1 == length ) { pBuffer[i+1] = 0 ; } else { pBuffer[i] = 0 ; } pHttpConnection->_requestQuery.insert( std::make_pair(pBuffer + keyOffset, pValueBuf) ) ; pValueBuf = NULL ; keyOffset = i + 1 ; } } PD_TRACE_EXITRC ( SDB__RESTADP_PARQUERY, rc ) ; return rc ; }