Esempio n. 1
0
        private void Initialize(CancellationToken cancellationToken)
        {
            _channelSource = _binding.GetReadChannelSource(cancellationToken);

            try
            {
                _channel = _channelSource.GetChannel(cancellationToken);
            }
            catch (Exception ex) when(RetryableReadOperationExecutor.ShouldConnectionAcquireBeRetried(this, ex))
            {
                ReplaceChannelSource(_binding.GetReadChannelSource(cancellationToken));
                ReplaceChannel(_channelSource.GetChannel(cancellationToken));
            }
        }
Esempio n. 2
0
        // private methods
        private void Initialize(CancellationToken cancellationToken)
        {
            _channelSource = _binding.GetWriteChannelSource(cancellationToken);
            var serverDescription = _channelSource.ServerDescription;

            try
            {
                _channel = _channelSource.GetChannel(cancellationToken);
            }
            catch (Exception ex) when(RetryableWriteOperationExecutor.ShouldConnectionAcquireBeRetried(this, serverDescription, ex))
            {
                ReplaceChannelSource(_binding.GetWriteChannelSource(cancellationToken));
                ReplaceChannel(_channelSource.GetChannel(cancellationToken));
            }
        }
Esempio n. 3
0
        // private methods
        private void Initialize(CancellationToken cancellationToken)
        {
            _channelSource = _binding.GetWriteChannelSource(cancellationToken);
            var serverDescription = _channelSource.ServerDescription;

            try
            {
                _channel = _channelSource.GetChannel(cancellationToken);
            }
            catch (MongoConnectionPoolPausedException)
            {
                if (RetryableWriteOperationExecutor.ShouldConnectionAcquireBeRetried(this, serverDescription))
                {
                    ReplaceChannelSource(_binding.GetWriteChannelSource(cancellationToken));
                    ReplaceChannel(_channelSource.GetChannel(cancellationToken));
                }
                else
                {
                    throw;
                }
            }
        }
Esempio n. 4
0
        internal static IChannelSourceHandle CreateGetMoreChannelSource(IChannelSourceHandle channelSource, long cursorId)
        {
            IChannelSource effectiveChannelSource;

            if (IsInLoadBalancedMode(channelSource.ServerDescription) && cursorId != 0)
            {
                var getMoreChannel = channelSource.GetChannel(CancellationToken.None); // no need for cancellation token since we already have channel in the source
                var getMoreSession = channelSource.Session.Fork();

                effectiveChannelSource = new ChannelChannelSource(
                    channelSource.Server,
                    getMoreChannel,
                    getMoreSession);
            }
            else
            {
                effectiveChannelSource = new ServerChannelSource(channelSource.Server, channelSource.Session.Fork());
            }

            return(new ChannelSourceHandle(effectiveChannelSource));
        }
 // private methods
 private void Initialize(CancellationToken cancellationToken)
 {
     _channelSource = _binding.GetWriteChannelSource(cancellationToken);
     _channel       = _channelSource.GetChannel(cancellationToken);
 }