INT32 migMaster::_stopAndWaitWorker ( pmdEDUCB *eduCB, UINT32 &success, UINT32 &failure ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY ( SDB__MIGLOADJSONPS__STOPWAIT ); _workerReturn *workerRe = NULL ; pmdEDUEvent event ; for ( UINT32 i = 0; i < _pParameters->workerNum; ++i ) { pushToQueue ( 0, 0, 0, 0 ) ; } for ( UINT32 i = 0; i < _pParameters->workerNum; ) { if ( eduCB->waitEvent ( event, 100 ) ) { workerRe = (_workerReturn *)event._Data ; success += workerRe->success ; failure += workerRe->failure ; ++i ; pmdEduEventRelase( event, eduCB ) ; } } PD_TRACE_EXITRC ( SDB__MIGLOADJSONPS__STOPWAIT, rc ); return rc ; }
void _pmdEDUCB::clear() { pmdEDUEvent data ; while ( _queue.try_pop( data ) ) { pmdEduEventRelase( data, this ) ; } _processEventCount = 0 ; _Name[0] = 0 ; _userName = "" ; _passWord = "" ; #if defined ( SDB_ENGINE ) clearTransInfo() ; releaseAlignedMemory() ; resetLsn() ; #endif // SDB_ENGINE if ( _pCompressBuff ) { releaseBuff( _pCompressBuff ) ; _pCompressBuff = NULL ; } _compressBuffLen = 0 ; if ( _pUncompressBuff ) { releaseBuff( _pUncompressBuff ) ; _pUncompressBuff = NULL ; } _uncompressBuffLen = 0 ; CATCH_MAP_IT it = _catchMap.begin() ; while ( it != _catchMap.end() ) { SDB_OSS_FREE( it->second ) ; _totalCatchSize -= it->first ; _totalMemSize -= it->first ; ++it ; } _catchMap.clear() ; ALLOC_MAP_IT itAlloc = _allocMap.begin() ; while ( itAlloc != _allocMap.end() ) { SDB_OSS_FREE( itAlloc->first ) ; _totalMemSize -= itAlloc->second ; ++itAlloc ; } _allocMap.clear() ; SDB_ASSERT( _totalCatchSize == 0 , "Catch size is error" ) ; SDB_ASSERT( _totalMemSize == 0, "Memory size is error" ) ; }
// PD_TRACE_DECLARE_FUNCTION ( SDB_PMDCBMGREP, "pmdCBMgrEntryPoint" ) INT32 pmdCBMgrEntryPoint ( pmdEDUCB *cb, void *pData ) { INT32 rc = SDB_OK ; PD_TRACE_ENTRY ( SDB_PMDCBMGREP ); _pmdObjBase *pObj = ( _pmdObjBase* )pData ; pmdEDUMgr *pEDUMgr = cb->getEDUMgr() ; pmdEDUEvent eventData; INT32 timeSpan = 0 ; INT32 maxMsgTime = pObj->getMaxProcMsgTime() ; INT32 maxEventTime = pObj->getMaxProcEventTime() ; INT32 *pMsgTimeSpan = maxMsgTime >= 0 ? &timeSpan : NULL ; INT32 *pEventTimeSpan = maxEventTime >= 0 ? &timeSpan : NULL ; pObj->attachCB( cb ) ; rc = pEDUMgr->activateEDU( cb->getID() ) ; if ( SDB_OK != rc ) { PD_LOG ( PDERROR, "Failed to active EDU" ) ; goto error ; } while ( !cb->isDisconnected() ) { if ( cb->waitEvent( eventData, OSS_ONE_SEC ) ) { if ( PMD_EDU_EVENT_TERM == eventData._eventType ) { PD_LOG ( PDDEBUG, "EDU[%lld, %s] is terminated", cb->getID(), getEDUName( cb->getType() ) ) ; } else if ( PMD_EDU_EVENT_MSG == eventData._eventType ) { pObj->dispatchMsg( (NET_HANDLE)eventData._userData, (MsgHeader*)(eventData._Data), pMsgTimeSpan ) ; if ( pMsgTimeSpan && timeSpan > maxMsgTime ) { MsgHeader *pMsg = (MsgHeader*)(eventData._Data) ; PD_LOG( PDWARNING, "[%s] Process msg[opCode:[%d]%d, " "requestID: %lld, TID: %d, Len: %d] over %d seconds", pObj->name(), IS_REPLY_TYPE(pMsg->opCode), GET_REQUEST_TYPE(pMsg->opCode), pMsg->requestID, pMsg->TID, pMsg->messageLength, timeSpan ) ; } } else { pObj->dispatchEvent ( &eventData, pEventTimeSpan ) ; if ( pEventTimeSpan && timeSpan > maxEventTime ) { PD_LOG( PDWARNING, "[%s] Process event[type:%d] over %d " "seconds", pObj->name(), eventData._eventType, timeSpan ) ; } } pmdEduEventRelase( eventData, cb ) ; eventData.reset () ; } } done: pObj->detachCB( cb ) ; PD_TRACE_EXITRC ( SDB_PMDCBMGREP, rc ); return rc ; error: goto done ; }