Esempio n. 1
0
   INT32 _pmdDataProcessor::_onRemoveLobMsg( MsgHeader *msg, SDB_DPSCB *dpsCB )
   {
      INT32 rc = SDB_OK ;
      BSONObj meta ;
      const MsgOpLob *header = NULL ;
      rc = msgExtractRemoveLobRequest( ( const CHAR * )msg, &header,
                                        meta ) ;
      if ( SDB_OK != rc )
      {
         PD_LOG( PDERROR, "failed to extract remove msg:%d", rc ) ;
         goto error ;
      }

      rc = rtnRemoveLob( meta, header->w, eduCB(), dpsCB ) ;
      if ( SDB_OK != rc )
      {
         PD_LOG( PDERROR, "failed to remove lob:%d", rc ) ;
         goto error ;
      }
   done:
      return rc ;
   error:
      goto done ;
   }
Esempio n. 2
0
   // PD_TRACE_DECLARE_FUNCTION ( SDB_RTNCOORDREMOVELOB_EXECUTE, "rtnCoordRemoveLob::execute" )
   INT32 rtnCoordRemoveLob::execute( CHAR *pReceiveBuffer, SINT32 packSize,
                                     CHAR **ppResultBuffer, pmdEDUCB *cb,
                                     MsgOpReply &replyHeader,
                                     BSONObj** ppErrorObj )
   {
      INT32 rc = SDB_OK ;
      PD_TRACE_ENTRY( SDB_RTNCOORDREMOVELOB_EXECUTE ) ;
      const MsgOpLob *header = NULL ;
      const MsgHeader *baseHeader = ( const MsgHeader * )pReceiveBuffer ;
      BSONObj obj ;
      BSONElement ele ;
      const CHAR *fullName = NULL ;
      _rtnCoordLobStream stream ;

      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 = msgExtractRemoveLobRequest( pReceiveBuffer, &header,
                                       obj ) ;
      if ( SDB_OK != rc )
      {
         PD_LOG( PDERROR, "failed to extract remove msg:%d", rc ) ;
         goto error ;
      }

      ele = obj.getField( FIELD_NAME_COLLECTION ) ;
      if ( String != ele.type() )
      {
         PD_LOG( PDERROR, "invalid type of field \"collection\":%s",
                 obj.toString( FALSE, TRUE ).c_str() ) ;
         rc = SDB_SYS ;
         goto error ;
      }
      fullName = ele.valuestr() ;

      ele = obj.getField( FIELD_NAME_LOB_OID ) ;
      if ( jstOID != ele.type() )
      {
         PD_LOG( PDERROR, "invalid type of field \"oid\":%s",
                 obj.toString( FALSE, TRUE ).c_str() ) ;
         rc = SDB_SYS ;
         goto error ;
      }

      rc = stream.open( fullName,
                        ele.__oid(), SDB_LOB_MODE_REMOVE,
                        cb ) ;
      if ( SDB_OK != rc )
      {
         PD_LOG( PDERROR, "failed to remove lob:%s, rc:%d",
                 ele.__oid().str().c_str(), rc ) ;
         goto error ;
      }
      else
      {
      }

      rc = stream.truncate( 0, cb ) ;
      if ( SDB_OK != rc )
      {
         PD_LOG( PDERROR, "faield to truncate lob:%d", rc ) ;
         goto error ;
      }

   done:
      {
      INT32 rcTmp = SDB_OK ;
      rcTmp = stream.close( cb ) ;
      if ( SDB_OK != rcTmp )
      {
         PD_LOG( PDERROR, "failed to remove lob:%d", rcTmp ) ;
         rc = rc == SDB_OK ? rcTmp : rc ;
         replyHeader.flags = rc ; 
      }
      }
      PD_TRACE_EXITRC( SDB_RTNCOORDREMOVELOB_EXECUTE, rc ) ;
      return rc ;
   error:
      replyHeader.flags = rc ; 
      goto done ;
   }