private BulkWriteOperationResult ExecuteBatches(RetryableWriteContext context, CancellationToken cancellationToken)
        {
            var helper = new BatchHelper(_requests, _writeConcern, _isOrdered);

            foreach (var batch in helper.GetBatches())
            {
                batch.Result = ExecuteBatch(context, batch, cancellationToken);
            }
            return(helper.CreateFinalResultOrThrow(context.Channel));
        }
        private async Task <BulkWriteOperationResult> ExecuteBatchesAsync(RetryableWriteContext context, CancellationToken cancellationToken)
        {
            var helper = new BatchHelper(_requests, _writeConcern, _isOrdered);

            foreach (var batch in helper.GetBatches())
            {
                batch.Result = await ExecuteBatchAsync(context, batch, cancellationToken).ConfigureAwait(false);
            }
            return(helper.CreateFinalResultOrThrow(context.Channel));
        }
Ejemplo n.º 3
0
        // public methods
        public BulkWriteOperationResult Execute(RetryableWriteContext context, CancellationToken cancellationToken)
        {
            var helper = new BatchHelper(this, context.Channel);

            foreach (var batch in helper.GetBatches())
            {
                batch.Result = EmulateSingleRequest(context.Channel, batch.Request, batch.OriginalIndex, cancellationToken);
            }
            return(helper.GetFinalResultOrThrow());
        }
Ejemplo n.º 4
0
        public async Task <BulkWriteOperationResult> ExecuteAsync(RetryableWriteContext context, CancellationToken cancellationToken)
        {
            var helper = new BatchHelper(this, context.Channel);

            foreach (var batch in helper.GetBatches())
            {
                batch.Result = await EmulateSingleRequestAsync(context.Channel, batch.Request, batch.OriginalIndex, cancellationToken).ConfigureAwait(false);
            }
            return(helper.GetFinalResultOrThrow());
        }
 /// <inheritdoc/>
 public async Task <BulkWriteOperationResult> ExecuteAsync(IWriteBinding binding, CancellationToken cancellationToken)
 {
     using (EventContext.BeginOperation())
         using (var channelSource = await binding.GetWriteChannelSourceAsync(cancellationToken).ConfigureAwait(false))
             using (var channel = await channelSource.GetChannelAsync(cancellationToken).ConfigureAwait(false))
             {
                 var helper = new BatchHelper(this, channel);
                 foreach (var batch in helper.GetBatches())
                 {
                     batch.Result = await ExecuteBatchAsync(channel, channelSource.Session, batch.Run, batch.IsLast, cancellationToken).ConfigureAwait(false);
                 }
                 return(helper.GetFinalResultOrThrow());
             }
 }
 // public methods
 /// <inheritdoc/>
 public BulkWriteOperationResult Execute(IWriteBinding binding, CancellationToken cancellationToken)
 {
     using (EventContext.BeginOperation())
         using (var channelSource = binding.GetWriteChannelSource(cancellationToken))
             using (var channel = channelSource.GetChannel(cancellationToken))
             {
                 var helper = new BatchHelper(this, channel);
                 foreach (var batch in helper.GetBatches())
                 {
                     batch.Result = ExecuteBatch(channel, channelSource.Session, batch.Run, batch.IsLast, cancellationToken);
                 }
                 return(helper.GetFinalResultOrThrow());
             }
 }
Ejemplo n.º 7
0
 /// <inheritdoc/>
 public async Task <BulkWriteOperationResult> ExecuteAsync(IWriteBinding binding, CancellationToken cancellationToken)
 {
     using (EventContext.BeginOperation())
         using (var context = await RetryableWriteContext.CreateAsync(binding, _retryRequested, cancellationToken).ConfigureAwait(false))
         {
             context.DisableRetriesIfAnyWriteRequestIsNotRetryable(_requests);
             var helper = new BatchHelper(_requests, _isOrdered, _writeConcern);
             foreach (var batch in helper.GetBatches())
             {
                 batch.Result = await ExecuteBatchAsync(context, batch, cancellationToken).ConfigureAwait(false);
             }
             return(helper.GetFinalResultOrThrow(context.Channel.ConnectionDescription.ConnectionId));
         }
 }
 // public methods
 /// <inheritdoc/>
 public BulkWriteOperationResult Execute(IWriteBinding binding, CancellationToken cancellationToken)
 {
     using (EventContext.BeginOperation())
         using (var context = RetryableWriteContext.Create(binding, _retryRequested, cancellationToken))
         {
             EnsureHintIsSupportedIfAnyRequestHasHint();
             context.DisableRetriesIfAnyWriteRequestIsNotRetryable(_requests);
             var helper = new BatchHelper(_requests, _isOrdered, _writeConcern);
             foreach (var batch in helper.GetBatches())
             {
                 batch.Result = ExecuteBatch(context, batch, cancellationToken);
             }
             return(helper.GetFinalResultOrThrow(context.Channel.ConnectionDescription.ConnectionId));
         }
 }
Ejemplo n.º 9
0
        private async Task <IEnumerable <WriteConcernResult> > InsertBatchesAsync(IChannelHandle channel, CancellationToken cancellationToken)
        {
            var helper = new BatchHelper(_documentSource, _writeConcern, _continueOnError);

            foreach (var batch in helper.GetBatches())
            {
                try
                {
                    batch.Result = await ExecuteProtocolAsync(channel, batch, cancellationToken).ConfigureAwait(false);
                }
                catch (MongoWriteConcernException ex)
                {
                    batch.Result = helper.HandleException(ex);
                    if (!_continueOnError)
                    {
                        return(null);
                    }
                }
            }

            return(helper.CreateFinalResultOrThrow());
        }
 public async Task<BulkWriteOperationResult> ExecuteAsync(IChannelHandle channel, CancellationToken cancellationToken)
 {
     var helper = new BatchHelper(this, channel);
     foreach (var batch in helper.GetBatches())
     {
         batch.Result = await EmulateSingleRequestAsync(channel, batch.Request, batch.OriginalIndex, cancellationToken).ConfigureAwait(false);
     }
     return helper.GetFinalResultOrThrow();
 }
 // public methods
 public BulkWriteOperationResult Execute(IChannelHandle channel, CancellationToken cancellationToken)
 {
     var helper = new BatchHelper(this, channel);
     foreach (var batch in helper.GetBatches())
     {
         batch.Result = EmulateSingleRequest(channel, batch.Request, batch.OriginalIndex, cancellationToken);
     }
     return helper.GetFinalResultOrThrow();
 }