Ejemplo n.º 1
0
   _ciHeader() : _mainVersion( CI_MAIN_VERSION ),
                 _subVersion( CI_SUB_VERSION ),
                 _loop( CI_INVALID_LOOP )
   {
      ossMemset( _action,      0, CI_ACTION_SIZE ) ;
      ossMemset( _eyeCatcher,  0, CI_EYECATCHER_SIZE ) ;
      ossMemset( _coordAddr,   0, CI_HOSTNAME_SIZE + 1 ) ;
      ossMemset( _serviceName, 0, CI_SERVICENAME_SIZE + 1 ) ;
      ossMemset( _groupName,   0, CI_GROUPNAME_SIZE + 1 ) ;
      ossMemset( _csName,      0, CI_CS_NAME_SIZE + 1 ) ;
      ossMemset( _clName,      0, CI_CL_NAME_SIZE + 1 ) ;
      ossMemset( _filepath,    0, OSS_MAX_PATHSIZE + 1 ) ;
      ossMemset( _outfile,     0, OSS_MAX_PATHSIZE + 1 ) ;
      ossMemset( _view,        0, CI_VIEWOPTION_SIZE + 1 ) ;

      ossMemcpy( _eyeCatcher, CI_HEADER_EYECATCHER, CI_EYECATCHER_SIZE ) ;
   }
Ejemplo n.º 2
0
INT32 ossIP2Str( UINT32 ip, CHAR * pStr, INT32 nameLen )
{
   struct sockaddr_in sockAddr ;
   ossMemset( &sockAddr, 0, sizeof(sockAddr) ) ;
   sockAddr.sin_family = AF_INET ;
   sockAddr.sin_addr.s_addr = htonl ( ip ) ;
   sockAddr.sin_port = htons ( 0 ) ;
   return ossGetAddrInfo( &sockAddr, pStr, nameLen, NULL ) ;
}
Ejemplo n.º 3
0
// PD_TRACE_DECLARE_FUNCTION ( SDB__OSSSK__OSSSK2, "_ossSocket::_ossSocket" )
_ossSocket::_ossSocket ( const CHAR *pHostname, UINT32 port,
                         INT32 timeoutMilli )
{
   PD_TRACE_ENTRY ( SDB__OSSSK__OSSSK2 );
   struct hostent *hp ;
   _init = FALSE ;
   _closeWhenDestruct = TRUE;
   _timeout = timeoutMilli ;
   _fd = SOCKET_INVALIDSOCKET ;
   ossMemset ( &_sockAddress, 0, sizeof(sockaddr_in) ) ;
   ossMemset ( &_peerAddress, 0, sizeof(sockaddr_in) ) ;
   _peerAddressLen = sizeof (_peerAddress) ;

   ossInitSocket() ;

   _sockAddress.sin_family = AF_INET ;
#if defined (_WINDOWS)
   if ( (hp = gethostbyname ( pHostname )))
#elif defined (_LINUX)
   struct hostent hent ;
   struct hostent *retval = NULL ;
   INT32 error            = 0 ;
   CHAR hbuf[8192]        = {0} ;
   hp                     = &hent ;

   if ( (0 == gethostbyname_r ( pHostname, &hent, hbuf, sizeof(hbuf),
                                &retval, &error )) &&
         NULL != retval )
#endif
   {
      UINT32 *pAddr = (UINT32 *)hp->h_addr_list[0] ;
      if ( pAddr )
      {
         _sockAddress.sin_addr.s_addr = *pAddr ;
      }
   }
   else
   {
      _sockAddress.sin_addr.s_addr = inet_addr ( pHostname ) ;
   }
   _sockAddress.sin_port = htons ( port ) ;
   _addressLen = sizeof ( _sockAddress ) ;
   PD_TRACE_EXIT ( SDB__OSSSK__OSSSK2 );
}
Ejemplo n.º 4
0
   /*
      _SDB_KRCB implement
   */
   _SDB_KRCB::_SDB_KRCB ()
   :_mainEDU( &_eduMgr, EDU_TYPE_MAIN )
   {
      ossMemset( _hostName, 0, sizeof( _hostName ) ) ;
      ossMemset( _groupName, 0, sizeof( _groupName ) ) ;

      _exitCode = SDB_OK ;
      _businessOK = TRUE ;
      _restart = FALSE ;
      _isRestore = FALSE ;

      _flowControl = FALSE ;

      _dbMode = 0 ;

      for ( INT32 i = 0 ; i < SDB_CB_MAX ; ++i )
      {
         _arrayCBs[ i ] = NULL ;
         _arrayCBs[ i ] = NULL ;
      }
      _init             = FALSE ;
      _isActive         = FALSE ;

      /* <-- internal status, can't be modified by config file --> */
      _dbStatus = SDB_DB_NORMAL ;
      /* <-- external status, can be changed by modifying config file --> */

      // standalone role by default, user may overwrite this setting
      _role = SDB_ROLE_STANDALONE ;

      setGroupName ( "" );
      // monitor switch initialization, no latch needed
      // for better performance these monitor swtich should be turned off
      // here, turn it on for testing

#if defined ( SDB_ENGINE )
      _monCfgCB.timestampON = TRUE ;
      _monDBCB.recordActivateTimestamp () ;
#endif // SDB_ENGINE

      // register config handler to option mgr
      _optioncb.setConfigHandler( this ) ;
   }
Ejemplo n.º 5
0
// PD_TRACE_DECLARE_FUNCTION ( SDB__OSSSK__OSSSK, "_ossSocket::_ossSocket" )
_ossSocket::_ossSocket ( UINT32 port, INT32 timeoutMilli )
{
   PD_TRACE_ENTRY ( SDB__OSSSK__OSSSK );
   _init = FALSE ;
   _fd = SOCKET_INVALIDSOCKET ;
   _timeout = timeoutMilli ;
   _closeWhenDestruct = TRUE ;
   ossMemset ( &_sockAddress, 0, sizeof(sockaddr_in) ) ;
   ossMemset ( &_peerAddress, 0, sizeof(sockaddr_in) ) ;
   _peerAddressLen = sizeof (_peerAddress) ;

   ossInitSocket() ;

   _sockAddress.sin_family = AF_INET ;
   _sockAddress.sin_addr.s_addr = htonl ( INADDR_ANY ) ;
   _sockAddress.sin_port = htons ( port ) ;
   _addressLen = sizeof ( _sockAddress ) ;
   PD_TRACE_EXIT ( SDB__OSSSK__OSSSK );
}
Ejemplo n.º 6
0
 _restSessionInfo()
 :_inNum( 0 )
 {
    _attr._sessionID     = 0 ;
    _attr._loginTime     = (UINT64)time(NULL) ;
    ossMemset( _attr._userName, 0, sizeof( _attr._userName ) ) ;
    _activeTime          = _attr._loginTime ;
    _timeoutCounter      = 0 ;
    _authOK              = FALSE ;
    _isLock              = FALSE ;
 }
Ejemplo n.º 7
0
   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 ;
   }
Ejemplo n.º 8
0
      _dpsLogHeader ()
      {
         ossMemcpy( _eyeCatcher, DPS_LOG_HEADER_EYECATCHER, 
                    DPS_LOG_HEADER_EYECATCHER_LEN) ;
         _logID      = DPS_INVALID_LOG_FILE_ID ;
         _version    = DPS_LOG_FILE_VERSION1 ;
         _fileSize   = 0 ;
         _fileNum    = 0 ;
         ossMemset(_padding, 0, sizeof(_padding) ) ;

         SDB_ASSERT( sizeof(_dpsLogHeader) == DPS_LOG_HEAD_LEN,
                     "Log file header size must be 64K" ) ;
      }
Ejemplo n.º 9
0
_ossModuleHandle::_ossModuleHandle ( const CHAR *pModuleName,
                                     const CHAR *pLibraryPath,
                                     UINT32 dlOpenMode ) :
_isInitialized(FALSE),
_moduleHandle(OSS_MINVALIDHANDLE),
_flags(dlOpenMode)
{
   ossStrncpy ( _moduleName, pModuleName, sizeof(_moduleName) ) ;
   if ( pLibraryPath )
      ossStrncpy ( _libPath, pLibraryPath, sizeof(_libPath) ) ;
   else
      ossMemset ( _libPath, 0, sizeof(_libPath) ) ;
}
Ejemplo n.º 10
0
   // PD_TRACE_DECLARE_FUNCTION ( SDB___PMDEDUCB_DUMPINFO2, "_pmdEDUCB::dumpInfo" )
   void _pmdEDUCB::dumpInfo ( monEDUFull &full )
   {
      PD_TRACE_ENTRY ( SDB___PMDEDUCB_DUMPINFO2 );
      ossScopedLock _lock ( &_mutex, SHARED ) ;
      ossMemset ( &full._eduStatus, 0, MON_EDU_STATUS_SZ ) ;
      ossMemset ( &full._eduType, 0, MON_EDU_TYPE_SZ ) ;
      ossMemset ( &full._eduName, 0, MON_EDU_NAME_SZ ) ;
      full._eduID = _eduID ;
      full._tid = _tid ;
      full._processEventCount = _processEventCount ;
      full._queueSize = _queue.size() ;
      ossStrncpy ( full._eduStatus, getEDUStatusDesp(_status),
                   MON_EDU_STATUS_SZ ) ;
      ossStrncpy ( full._eduType, getEDUName (_eduType), MON_EDU_TYPE_SZ ) ;
      ossStrncpy ( full._eduName, _Name, MON_EDU_NAME_SZ ) ;

      full._monApplCB = _monApplCB ;
      full._threadHdl = _threadHdl ;

      full._eduContextList = _contextList ;
      PD_TRACE_EXIT ( SDB___PMDEDUCB_DUMPINFO2 );
   }
Ejemplo n.º 11
0
   /*
      _pmdEDUCB implement
   */
   _pmdEDUCB::_pmdEDUCB( _pmdEDUMgr *mgr, EDU_TYPES type )
   : _tid( 0 ),
   _processEventCount( 0 ),
   _eduMgr( mgr ),
   _eduType( type ),
   _ctrlFlag( 0 ),
   _writingDB( FALSE ),
   _writingTime( 0 ),
   _threadHdl( 0 ),
#if defined (_LINUX)
   _threadID( 0 ),
#endif
   _pClientSock( NULL )
   {
      _Name[0]          = 0 ;
      _pSession         = NULL ;
      _pCompressBuff    = NULL ;
      _compressBuffLen  = 0 ;
      _pUncompressBuff  = NULL ;
      _uncompressBuffLen= 0 ;
      _totalCatchSize   = 0 ;
      _totalMemSize     = 0 ;
      _isDoRollback     = FALSE ;

#if defined ( SDB_ENGINE )
      _pCoordSession    = NULL ;
      _beginLsn         = 0 ;
      _endLsn           = 0 ;
      _lsnNumber        = 0 ;
      _relatedTransLSN  = DPS_INVALID_LSN_OFFSET ;
      _curTransLSN      = DPS_INVALID_LSN_OFFSET ;
      _curTransID       = DPS_INVALID_TRANS_ID ;
      _pTransNodeMap    = NULL ;
      _transRC          = SDB_OK ;

      _alignedMem       = NULL ;
      _alignedMemSize   = 0 ;

      _curRequestID     = 1 ;
      _dmsLockLevel     = 0 ;

      _monCfgCB = *( (monConfigCB*)(pmdGetKRCB()->getMonCB()) ) ;
#endif // SDB_ENGINE

      _pErrorBuff = (CHAR *)SDB_OSS_MALLOC( EDU_ERROR_BUFF_SIZE + 1 ) ;
      if ( _pErrorBuff )
      {
         ossMemset( _pErrorBuff, 0, EDU_ERROR_BUFF_SIZE + 1 ) ;
      }
   }
Ejemplo n.º 12
0
 // PD_TRACE_DECLARE_FUNCTION ( SDB__DMSROUNIT_EXPEXT, "_dmsReorgUnit::exportExtent" )
 INT32 _dmsReorgUnit::exportExtent ( CHAR *pBuffer )
 {
    INT32 rc = SDB_OK ;
    PD_TRACE_ENTRY ( SDB__DMSROUNIT_EXPEXT );
    dmsExtent *extent = (dmsExtent*)pBuffer ;
    ossMemset ( pBuffer, 0, sizeof(dmsExtent) ) ;
    INT32 restSize = sizeof(dmsExtent) ;
    INT64 readSize = 0 ;
    INT32 bufSize = restSize ;
    while ( restSize > 0 )
    {
       rc = ossRead ( &_file, &pBuffer[bufSize-restSize], restSize, &readSize ) ;
       if ( rc && SDB_INTERRUPT != rc )
       {
          PD_LOG ( PDERROR, "Failed to read header from file: %s, rc = %d",
                   _fileName, rc ) ;
          goto error ;
       }
       restSize -= (INT32)readSize ;
       rc = SDB_OK ;
    }
    if ( DMS_EXTENT_EYECATCHER0 != extent->_eyeCatcher[0] ||
         DMS_EXTENT_EYECATCHER1 != extent->_eyeCatcher[1] )
    {
       PD_LOG ( PDERROR, "Invalid eye catcher" ) ;
       rc = SDB_SYS ;
       goto error ;
    }
    restSize = extent->_blockSize * _pageSize - sizeof(dmsExtent) ;
    readSize = 0 ;
    bufSize = restSize ;
    while ( restSize > 0 )
    {
       rc = ossRead ( &_file, &pBuffer[sizeof(dmsExtent)+bufSize-restSize],
                      restSize, &readSize ) ;
       if ( rc && SDB_INTERRUPT != rc )
       {
          PD_LOG ( PDERROR, "Failed to read header from file: %s, rc = %d",
                   _fileName, rc ) ;
          goto error ;
       }
       restSize -= (INT32)readSize ;
       rc = SDB_OK ;
    }
 done :
    PD_TRACE_EXITRC ( SDB__DMSROUNIT_EXPEXT, rc );
    return rc ;
 error :
    goto done ;
 }
Ejemplo n.º 13
0
   void _replaceCharsWithSpace( CHAR *pBuff, const CHAR *c )
   {
      CHAR *pos = NULL ;

      while( TRUE )
      {
         pos = ossStrstr( pBuff, c ) ;
         if ( NULL == pos )
         {
            break ;
         }
         ossMemset( pos, ' ', ossStrlen(c) ) ;
      }
   }
Ejemplo n.º 14
0
void ossSprintVersion( const CHAR *prompt, CHAR *pBuff, UINT32 len,
                       BOOLEAN multiLine )
{
   if ( 0 == len )
   {
      return ;
   }
   ossMemset( pBuff, 0, len ) ;

#ifdef SDB_ENGINE_FIXVERSION_CURRENT
   if ( multiLine )
   {
      ossSnprintf( pBuff, len - 1, "%s: %d.%d.%d%sRelease: %d%s%s%s",
                   prompt, SDB_ENGINE_VERISON_CURRENT,
                   SDB_ENGINE_SUBVERSION_CURRENT,
                   SDB_ENGINE_FIXVERSION_CURRENT,
                   OSS_NEWLINE, SDB_ENGINE_RELEASE_CURRENT,
                   OSS_NEWLINE, SDB_ENGINE_BUILD_TIME,
                   OSS_NEWLINE ) ;
   }
   else
   {
      ossSnprintf( pBuff, len - 1, "%s: %d.%d.%d, Release: %d, Build: %s",
                   prompt, SDB_ENGINE_VERISON_CURRENT,
                   SDB_ENGINE_SUBVERSION_CURRENT,
                   SDB_ENGINE_FIXVERSION_CURRENT,
                   SDB_ENGINE_RELEASE_CURRENT,
                   SDB_ENGINE_BUILD_TIME ) ;
   }
#else
   if ( multiLine )
   {
      ossSnprintf( pBuff, len - 1, "%s: %d.%d%sRelease: %d%s%s%s",
                   prompt, SDB_ENGINE_VERISON_CURRENT,
                   SDB_ENGINE_SUBVERSION_CURRENT,
                   OSS_NEWLINE, SDB_ENGINE_RELEASE_CURRENT,
                   OSS_NEWLINE, SDB_ENGINE_BUILD_TIME,
                   OSS_NEWLINE ) ;
   }
   else
   {
      ossSnprintf( pBuff, len - 1, "%s: %d.%d, Release: %d, Build: %s",
                   prompt, SDB_ENGINE_VERISON_CURRENT,
                   SDB_ENGINE_SUBVERSION_CURRENT,
                   SDB_ENGINE_RELEASE_CURRENT,
                   SDB_ENGINE_BUILD_TIME ) ;
   }
#endif //SDB_ENGINE_FIXVERSION_CURRENT
}
Ejemplo n.º 15
0
static UINT64 ossMemTraceDump ( void *p, ossPrimitiveFileOp &trapFile )
{
    CHAR lineBuffer [ OSSMEMTRACEDUMPBUFSZ + 1 ] = {0} ;
    CHAR *pAddr = (CHAR*)p ;
    ossMemset ( lineBuffer, 0, sizeof(lineBuffer) ) ;
    ossSnprintf ( lineBuffer, sizeof(lineBuffer),
                  " Address: %p\n", pAddr ) ;
    trapFile.Write ( lineBuffer ) ;
    ossMemset ( lineBuffer, 0, sizeof(lineBuffer) ) ;
    ossSnprintf ( lineBuffer, sizeof(lineBuffer),
                  " Freed: %s, Size: %lld, DebugSize: %d\n",
                  (*(UINT32*)(pAddr+OSS_MEM_HEAD_FREEDOFFSET))==0?"false":"true",
                  (*(UINT64*)(pAddr+OSS_MEM_HEAD_SIZEOFFSET)),
                  (*(UINT32*)(pAddr+OSS_MEM_HEAD_DEBUGOFFSET)) ) ;
    trapFile.Write ( lineBuffer ) ;
    ossMemset ( lineBuffer, 0, sizeof(lineBuffer) ) ;
    ossSnprintf ( lineBuffer, sizeof(lineBuffer),
                  " File: 0x%x, Line: %d\n",
                  (*(UINT32*)(pAddr+OSS_MEM_HEAD_FILEOFFSET)),
                  (*(UINT32*)(pAddr+OSS_MEM_HEAD_LINEOFFSET)) ) ;
    trapFile.Write ( lineBuffer ) ;
    trapFile.Write ( "\n" ) ;
    return (*(UINT64*)(pAddr+OSS_MEM_HEAD_SIZEOFFSET)) ;
}
Ejemplo n.º 16
0
   iPmdDMNChildProc::iPmdDMNChildProc()
   {
      _deadTime = PMDDMN_SHMSTAT_EXPRIRED_TIMES - 1 ;
      _procInfo = NULL;
      _pid = OSS_INVALID_PID;
      ossMemset( _execName, 0, sizeof( _execName) );
#if defined (_LINUX)
      _shmMid = -1;
      _shmKey = PMDDMN_SHMKEY_DEFAULT;
#elif defined (_WINDOWS)
      _shmMid = NULL;
      _shmKey = NULL;
#endif
      _syncEvent.signalAll() ;
   }
Ejemplo n.º 17
0
      INT32 init(INT32 capacity)
      {
         SDB_ASSERT(NULL == _array, "already inited");
         SDB_ASSERT(capacity > 0, "capacity must be greater than 0");

         _array = (bson**)SDB_OSS_MALLOC(sizeof(bson*) * capacity);
         if (NULL == _array)
         {
            return SDB_OOM;
         }
         ossMemset(_array, 0, sizeof(bson*) * capacity);
         _capacity = capacity;

         return SDB_OK;
      }
Ejemplo n.º 18
0
 // PD_TRACE_DECLARE_FUNCTION ( SDB__DMSROUNIT_GETNXTEXTSIZE, "_dmsReorgUnit::getNextExtentSize" )
 INT32 _dmsReorgUnit::getNextExtentSize ( SINT32 &size )
 {
    INT32 rc = SDB_OK ;
    PD_TRACE_ENTRY ( SDB__DMSROUNIT_GETNXTEXTSIZE );
    CHAR buffer [ sizeof(dmsExtent) ] ;
    dmsExtent *extent = (dmsExtent*)buffer ;
    ossMemset ( buffer, 0, sizeof(buffer) ) ;
    INT32 restSize = sizeof(buffer) ;
    INT64 readSize = 0 ;
    INT32 bufSize = restSize ;
    while ( restSize > 0 )
    {
       rc = ossRead ( &_file, &buffer[bufSize-restSize], restSize,
                      &readSize ) ;
       if ( rc && SDB_INTERRUPT != rc )
       {
          if ( SDB_EOF != rc )
          {
             PD_LOG ( PDERROR, "Failed to read header from file: %s, rc = %d",
                      _fileName, rc ) ;
          }
          goto error ;
       }
       restSize -= (INT32)readSize ;
       rc = SDB_OK ;
    }
    if ( DMS_EXTENT_EYECATCHER0 != extent->_eyeCatcher[0] ||
         DMS_EXTENT_EYECATCHER1 != extent->_eyeCatcher[1] )
    {
       PD_LOG ( PDERROR, "Invalid eye catcher" ) ;
       rc = SDB_SYS ;
       goto error ;
    }
    size = extent->_blockSize * _pageSize ;
    rc = ossSeek ( &_file, (INT64)(0-sizeof(dmsExtent)), OSS_SEEK_CUR ) ;
    if ( rc )
    {
       PD_LOG ( PDERROR, "Failed to seek back %d bytes offset, rc = %d",
                sizeof(dmsExtent) ) ;
       goto error ;
    }
 done :
    PD_TRACE_EXITRC ( SDB__DMSROUNIT_GETNXTEXTSIZE, rc );
    return rc ;
 error :
    size = 0 ;
    goto done ;
 }
Ejemplo n.º 19
0
INT32 _appendObj( CHAR delChar, bson_iterator *pIt,
                  CHAR **ppCSVBuf, INT32 *pCSVSize )
{
   INT32 rc = SDB_OK ;
   INT32 size    = 0 ;
   INT32 objSize = 0 ;
   CHAR *pBuffer = NULL ;
   CHAR *pTempBuf = NULL ;

   size = bson_sprint_length_iterator ( pIt ) ;

   if ( ppCSVBuf && size > (*pCSVSize) )
   {
      rc = SDB_OOM ;
      goto error ;
   }

   pBuffer = (CHAR *)SDB_OSS_MALLOC( size ) ;
   if ( !pBuffer )
   {
      rc = SDB_OOM ;
      goto error ;
   }
   pTempBuf = pBuffer ;
   ossMemset( pTempBuf, 0, size ) ;

   objSize = size ;
   if( !bson_sprint_iterator ( &pTempBuf,
                               &size,
                               pIt, '"' ) )
   {
      rc = SDB_OOM ;
      goto error ;
   }
   objSize -= size ;
   rc = _appendString( delChar, pBuffer, objSize,
                       ppCSVBuf, pCSVSize ) ;
   if ( rc )
   {
      goto error ;
   }
done:
   SAFE_OSS_FREE( pBuffer ) ;
   return rc ;
error:
   goto done ;
}
Ejemplo n.º 20
0
   // PD_TRACE_DECLARE_FUNCTION ( SDB__DMSSU_DUMPINFO1, "_dmsStorageUnit::dumpInfo" )
   void _dmsStorageUnit::dumpInfo ( set<_monCollection> &collectionList,
                                    BOOLEAN sys )
   {
      dmsMB *mb = NULL ;
      dmsMBStatInfo *mbStat = NULL ;

      PD_TRACE_ENTRY ( SDB__DMSSU_DUMPINFO1 ) ;
      _pDataSu->_metadataLatch.get_shared() ;

      dmsStorageData::COLNAME_MAP_IT it = _pDataSu->_collectionNameMap.begin() ;
      while ( it != _pDataSu->_collectionNameMap.end() )
      {
         monCollection collection ;
         if ( !sys && dmsIsSysCLName( it->first ) )
         {
            ++it ;
            continue ;
         }

         mb = &_pDataSu->_dmsMME->_mbList[it->second] ;
         mbStat = &_pDataSu->_mbStatInfo[it->second] ;

         ossMemset ( collection._name, 0, sizeof(collection._name) ) ;
         ossStrncpy ( collection._name, CSName(), DMS_SU_NAME_SZ ) ;
         ossStrncat ( collection._name, ".", 1 ) ;
         ossStrncat ( collection._name, mb->_collectionName,
                      DMS_COLLECTION_NAME_SZ ) ;
         collection.addDetails ( CSSequence(),
                                 mb->_numIndexes,
                                 mb->_blockID,
                                 mb->_flag,
                                 mb->_logicalID,
                                 mbStat->_totalRecords,
                                 mbStat->_totalDataPages,
                                 mbStat->_totalIndexPages,
                                 mbStat->_totalLobPages,
                                 mbStat->_totalDataFreeSpace,
                                 mbStat->_totalIndexFreeSpace ) ;
         collectionList.insert ( collection ) ;

         ++it ;
      }

      _pDataSu->_metadataLatch.release_shared() ;
      PD_TRACE_EXIT ( SDB__DMSSU_DUMPINFO1 ) ;
   }
Ejemplo n.º 21
0
 _monCollectionSpace ()
 {
    ossMemset ( _name, 0, sizeof(_name)) ;
    _collections.clear() ;
    _pageSize = 0 ;
    _clNum    = 0 ;
    _totalRecordNum = 0 ;
    _totalSize = 0 ;
    _freeSize  = 0 ;
    _lobPageSize = 0 ;
    _totalDataSize = 0 ;
    _totalIndexSize = 0 ;
    _totalLobSize = 0 ;
    _freeDataSize = 0 ;
    _freeIndexSize = 0 ;
    _freeLobSize = 0 ;
 }
Ejemplo n.º 22
0
   const CHAR* utilAscTime( time_t tTime, CHAR * pBuff, UINT32 size )
   {
      struct tm localTm ;
      ossLocalTime( tTime, localTm ) ;

      ossMemset( pBuff, 0, size ) ;
      ossSnprintf( pBuff, size-1,
                   "%04d-%02d-%02d-%02d:%02d:%02d",
                   localTm.tm_year+1900,            // 1) Year (UINT32)
                   localTm.tm_mon+1,                // 2) Month (UINT32)
                   localTm.tm_mday,                 // 3) Day (UINT32)
                   localTm.tm_hour,                 // 4) Hour (UINT32)
                   localTm.tm_min,                  // 5) Minute (UINT32)
                   localTm.tm_sec                   // 6) Second (UINT32)
                  ) ;
      pBuff[ size - 1 ] = 0 ;
      return pBuff ;
   }
Ejemplo n.º 23
0
   INT32 _pmdCoordProcessor::processMsg( MsgHeader *msg,
                                         rtnContextBuf &contextBuff,
                                         INT64 &contextID,
                                         BOOLEAN &needReply )
   {
      INT32 rc = SDB_OK ;
      ossMemset( &_replyHeader, 0, sizeof( _replyHeader ) ) ;
      _replyHeader.header.messageLength = sizeof( MsgOpReply ) ;
      _replyHeader.header.opCode        = MAKE_REPLY_TYPE( msg->opCode ) ;
      _replyHeader.header.requestID     = msg->requestID ;
      _replyHeader.header.routeID.value = pmdGetNodeID().value ;
      _replyHeader.header.TID           = msg->TID ;
      _replyHeader.contextID            = -1 ;
      _replyHeader.flags                = SDB_OK ;
      _replyHeader.numReturned          = 0 ;
      _replyHeader.startFrom            = 0 ;

      rc = _processCoordMsg( msg, _replyHeader, contextBuff ) ;
      if ( SDB_COORD_UNKNOWN_OP_REQ == rc )
      {
         contextBuff.release() ;
         rc = _pmdDataProcessor::processMsg( msg, contextBuff,
                                             contextID, needReply ) ;
      }
      else if ( SDB_OK == rc )
      {
         contextID = _replyHeader.contextID ;
      }

      if ( rc )
      {
         if ( SDB_APP_INTERRUPT == rc )
         {
            PD_LOG ( PDINFO, "Agent is interrupt" ) ;
         }
         else if ( SDB_DMS_EOC != rc )
         {
            PD_LOG ( PDERROR, "Error processing Agent request, rc=%d", rc ) ;
         }
      }

      return rc ;
   }
Ejemplo n.º 24
0
void ossGetSimpleVersion( CHAR *pBuff, UINT32 bufLen )
{
   if ( NULL == pBuff || 0 == bufLen )
   {
      return ;
   }
   ossMemset( pBuff, 0, bufLen ) ;

#ifdef SDB_ENGINE_FIXVERSION_CURRENT
   ossSnprintf( pBuff, bufLen - 1, "%d.%d.%d",
                SDB_ENGINE_VERISON_CURRENT,
                SDB_ENGINE_SUBVERSION_CURRENT,
                SDB_ENGINE_FIXVERSION_CURRENT ) ;
#else
   ossSnprintf( pBuff, bufLen - 1, "%d.%d",
                SDB_ENGINE_VERISON_CURRENT,
                SDB_ENGINE_SUBVERSION_CURRENT ) ;
#endif
}
Ejemplo n.º 25
0
   INT32 _sptClassMetaInfo::_getContents( const CHAR *pFileBuff,
                                          const CHAR *pMark1,
                                          const CHAR*pMark2,
                                          CHAR **ppBuff,
                                          INT32 *pBuffSize )
   {
      INT32 rc = SDB_OK ;
      stringstream ss ;
      INT32 buffSize = 0 ;
      CHAR *pBuff = NULL ;
      CHAR *begin = NULL ;
      CHAR *end = NULL ;

      begin = ossStrstr( (CHAR *)pFileBuff, (CHAR *)pMark1 ) ;
      end = ossStrstr( (CHAR *)pFileBuff, (CHAR *)pMark2 ) ;
      if ( NULL == begin || NULL == end )
      {
         rc = SDB_INVALIDARG ;
         ss << "Failed to get [" << pMark1 << "], or [" 
            << pMark2 << "], rc = " << rc << ERROR_END ;
         goto error ;
      }
      buffSize = end - begin ;
      pBuff = (CHAR *)SDB_OSS_MALLOC( buffSize + 1 ) ;
      if ( NULL == pBuff )
      {
         rc = SDB_OOM ;
         ss << "Failed to alloc [" << buffSize << "] bytes, rc = " 
            << rc << ERROR_END ;
         goto error ;
      }
      ossMemset( pBuff, 0, buffSize ) ;
      ossMemcpy( pBuff, begin, buffSize ) ;
      pBuff[buffSize] = '\0' ;
      *ppBuff = pBuff ;
      *pBuffSize = buffSize + 1 ;
      
   done:
      return rc ;
   error:
      PRINT_ERROR ;
      goto done ;
   }
Ejemplo n.º 26
0
   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 ;
   }
Ejemplo n.º 27
0
   INT32 iPmdDMNChildProc::init( ossSHMKey shmKey )
   {
      INT32 rc = SDB_OK;
      UINT32 len = 0;
#if defined (_WINDOWS)
      UINT32 keyLen = 0;
#endif
      ossMemset( _execName, 0, sizeof( _execName) );
      rc = ossGetEWD( _execName, OSS_MAX_PATHSIZE );
      PD_RC_CHECK( rc, PDERROR,
                  "failed to get working directory(rc=%d)",
                  rc );
      len = ossStrlen( _execName );
      len = len + 1 + ossStrlen( getProgramName() );
#if defined (_WINDOWS)
      len += ossStrlen(".exe");
      keyLen = ossStrlen( shmKey );
      SAFE_OSS_FREE( _shmKey );
      _shmKey = (CHAR *)SDB_OSS_MALLOC( keyLen + 1 );
      if ( _shmKey )
      {
         ossStrcpy( _shmKey, shmKey );
      }
#elif defined ( _LINUX )
      _shmKey = shmKey;
#endif
      PD_CHECK( len <= OSS_MAX_PATHSIZE, SDB_INVALIDARG, error, PDERROR,
               "length of working directory is longer than expected!" );
      ossStrncat( _execName, OSS_FILE_SEP, 1 );
      ossStrncat( _execName, getProgramName(),
                  ossStrlen( getProgramName() ) );
#if defined (_WINDOWS)
      ossStrncat( _execName, ".exe", ossStrlen(".exe") );
#endif
   done:
      return rc;
   error:
      goto done;
   }
Ejemplo n.º 28
0
   INT32 utilSplitStr( const string & input,
                       vector < string > & listServices,
                       const string & seperators )
   {
      INT32 rc = SDB_OK ;
      CHAR *cstr = NULL ;
      CHAR *p = NULL ;
      CHAR *pContext = NULL ;
      INT32 bufSize = input.size() ;

      cstr = (CHAR*)SDB_OSS_MALLOC ( bufSize + 1 ) ;
      if ( !cstr )
      {
         std::cout << "Alloc memory(" << bufSize + 1 << ") failed"
                   << std::endl ;
         rc = SDB_OOM ;
         goto error ;
      }
      ossMemset ( cstr, 0, bufSize + 1 ) ;
      ossStrncpy ( cstr, input.c_str(), bufSize ) ;

      p = ossStrtok ( cstr, seperators.c_str(), &pContext ) ;
      while ( p )
      {
         string ts ( p ) ;
         listServices.push_back ( ts ) ;
         p = ossStrtok ( NULL, seperators.c_str(), &pContext ) ;
      }

   done :
      if ( cstr )
      {
         SDB_OSS_FREE ( cstr ) ;
      }
      return rc ;
   error :
      goto done ;
   }
Ejemplo n.º 29
0
   INT32 _utilESBulkBuilder::init( UINT32 bufferSize )
   {
      INT32 rc = SDB_OK ;

      if ( 0 == bufferSize || bufferSize > UTIL_ESBULK_MAX_SIZE )
      {
         rc = SDB_INVALIDARG ;
         PD_LOG( PDERROR, "Buffer size[ %u ] is invalid", bufferSize ) ;
         goto error ;
      }

      if ( _buffer )
      {
         SDB_ASSERT( _capacity, "_capacity is 0" ) ;
         rc = SDB_INVALIDARG ;
         PD_LOG( PDERROR, "Bulk builder has been initialized already" ) ;
         goto error ;
      }

      _buffer = (CHAR *)SDB_OSS_MALLOC( bufferSize ) ;
      if ( !_buffer )
      {
         rc = SDB_OOM ;
         PD_LOG( PDERROR, "Allocate memory for bulk buffer failed, requested "
                 "size[ %d ]", bufferSize ) ;
         goto error ;
      }

      ossMemset( _buffer, 0, bufferSize ) ;
      _capacity = bufferSize ;

   done:
      return rc ;
   error:
      SAFE_OSS_FREE( _buffer ) ;
      goto done ;
   }
Ejemplo n.º 30
0
   INT32 utilBuildFullPath( const CHAR *path, const CHAR *name,
                            UINT32 fullSize, CHAR *full )
   {
      INT32 rc = SDB_OK ;
      if ( ossStrlen( path ) + ossStrlen( name )
           + 2 > fullSize )
      {
         rc = SDB_INVALIDARG ;
         goto error ;
      }
      ossMemset( full, 0, fullSize );
      ossStrcpy( full, path ) ;
      if ( '\0' != path[0] &&
           0 != ossStrcmp(&path[ossStrlen(path)-1], OSS_FILE_SEP ) )
      {
         ossStrncat( full, OSS_FILE_SEP, 1 ) ;
      }
      ossStrncat( full, name, ossStrlen( name ) ) ;

   done:
      return rc ;
   error:
      goto done ;
   }