Exemplo n.º 1
0
        private IReadWriteBindingHandle GetSingleServerReadWriteBinding(CancellationToken cancellationToken)
        {
            var selector = WritableServerSelector.Instance;
            var server   = _cluster.SelectServer(selector, cancellationToken);
            var binding  = new SingleServerReadWriteBinding(server, NoCoreSession.NewHandle());

            return(new ReadWriteBindingHandle(binding));
        }
Exemplo n.º 2
0
        private async Task <IReadWriteBindingHandle> GetSingleServerReadWriteBindingAsync(CancellationToken cancellationToken)
        {
            var selector = WritableServerSelector.Instance;
            var server   = await _cluster.SelectServerAsync(selector, cancellationToken).ConfigureAwait(false);

            var binding = new SingleServerReadWriteBinding(server, NoCoreSession.NewHandle());

            return(new ReadWriteBindingHandle(binding));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create a FailPoint and executes a configureFailPoint command on the selected server.
        /// </summary>
        /// <param name="server">The server.</param>
        /// <param name="session">The session.</param>
        /// <param name="command">The command.</param>
        /// <returns>A FailPoint containing the proper binding.</returns>
        public static FailPoint Configure(IServer server, ICoreSessionHandle session, BsonDocument command)
        {
            var binding   = new SingleServerReadWriteBinding(server, session.Fork());
            var failpoint = new FailPoint(server, binding, command);

            try
            {
                failpoint.Configure();
                return(failpoint);
            }
            catch
            {
                try { failpoint.Dispose(); } catch { }
                throw;
            }
        }
Exemplo n.º 4
0
        // public static methods
        /// <summary>
        /// Create a FailPoint and executes a configureFailPoint command on the selected server.
        /// </summary>
        /// <param name="cluster">The cluster.</param>
        /// <param name="session">The session.</param>
        /// <param name="name">The name.</param>
        /// <param name="args">The arguments for the FailPoint.</param>
        /// <returns>A FailPoint containing the proper binding.</returns>
        public static FailPoint Configure(ICluster cluster, ICoreSessionHandle session, string name, BsonDocument args)
        {
            var server    = GetWriteableServer(cluster);
            var binding   = new SingleServerReadWriteBinding(server, session.Fork());
            var failpoint = new FailPoint(server, binding, name, args);

            try
            {
                failpoint.Configure();
                return(failpoint);
            }
            catch
            {
                try { failpoint.Dispose(); } catch { }
                throw;
            }
        }