SM_Dropbox_FileInfo SM_QDropbox::requestMetadataAndWait(QString file) { requestMetadata(file, true); SM_Dropbox_FileInfo fi(_tempJson.strContent(), this); return fi; }
void BatchWriteOp::buildBatchRequest( const TargetedWriteBatch& targetedBatch, BatchedCommandRequest* request ) const { request->setNS( _clientRequest->getNS() ); const vector<TargetedWrite*>& targetedWrites = targetedBatch.getWrites(); for ( vector<TargetedWrite*>::const_iterator it = targetedWrites.begin(); it != targetedWrites.end(); ++it ) { const WriteOpRef& writeOpRef = ( *it )->writeOpRef; BatchedCommandRequest::BatchType batchType = _clientRequest->getBatchType(); // NOTE: We copy the batch items themselves here from the client request // TODO: This could be inefficient, maybe we want to just reference in the future if ( batchType == BatchedCommandRequest::BatchType_Insert ) { BatchedInsertRequest* clientInsertRequest = _clientRequest->getInsertRequest(); BSONObj insertDoc = clientInsertRequest->getDocumentsAt( writeOpRef.first ); request->getInsertRequest()->addToDocuments( insertDoc ); } else if ( batchType == BatchedCommandRequest::BatchType_Update ) { BatchedUpdateRequest* clientUpdateRequest = _clientRequest->getUpdateRequest(); BatchedUpdateDocument* updateDoc = new BatchedUpdateDocument; clientUpdateRequest->getUpdatesAt( writeOpRef.first )->cloneTo( updateDoc ); request->getUpdateRequest()->addToUpdates( updateDoc ); } else { dassert( batchType == BatchedCommandRequest::BatchType_Delete ); BatchedDeleteRequest* clientDeleteRequest = _clientRequest->getDeleteRequest(); BatchedDeleteDocument* deleteDoc = new BatchedDeleteDocument; clientDeleteRequest->getDeletesAt( writeOpRef.first )->cloneTo( deleteDoc ); request->getDeleteRequest()->addToDeletes( deleteDoc ); } // TODO: We can add logic here to allow aborting individual ops //if ( NULL == response ) { // ->responses.erase( it++ ); // continue; //} } if ( _clientRequest->isWriteConcernSet() ) { if ( _clientRequest->isVerboseWC() ) { request->setWriteConcern( _clientRequest->getWriteConcern() ); } else { // Mongos needs to send to the shard with w > 0 so it will be able to // see the writeErrors. request->setWriteConcern( upgradeWriteConcern( _clientRequest->getWriteConcern() )); } } if ( !request->isOrderedSet() ) { request->setOrdered( _clientRequest->getOrdered() ); } auto_ptr<BatchedRequestMetadata> requestMetadata( new BatchedRequestMetadata() ); requestMetadata->setShardName( targetedBatch.getEndpoint().shardName ); requestMetadata->setShardVersion( targetedBatch.getEndpoint().shardVersion ); requestMetadata->setSession( 0 ); request->setMetadata( requestMetadata.release() ); }