예제 #1
0
        public void NodesPassedTest()
        {
            var builder = new BobClusterBuilder <ulong>();

            builder.WithAdditionalNode(new BobConnectionParameters("127.0.0.1"));
            builder.WithAdditionalNode("127.0.0.2");
            builder.WithAdditionalNodes(new string[] { "127.0.0.3", "127.0.0.4" });
            builder.WithAdditionalNodes(new BobConnectionParameters[] { new BobConnectionParameters("127.0.0.5"), new BobConnectionParameters("127.0.0.6") });

            using (var clusterClient = builder.Build())
            {
                Assert.Equal(6, clusterClient.ClientConnectionParameters.Count());
                var hosts         = clusterClient.ClientConnectionParameters.Select(o => o.Host).ToList();
                var expectedHosts = new string[] { "127.0.0.1", "127.0.0.2", "127.0.0.3", "127.0.0.4", "127.0.0.5", "127.0.0.6" };
                Assert.Equal(expectedHosts, hosts);
            }
        }
예제 #2
0
        public void NodesParametersPassedTest()
        {
            var builder = new BobClusterBuilder <ulong>("127.0.0.1", "127.0.0.2");

            builder.WithOperationTimeout(TimeSpan.FromSeconds(22))
            .WithConnectionTimeout(TimeSpan.FromSeconds(33))
            .WithAuthenticationData("user", "pass");

            using (var clusterClient = builder.Build())
            {
                Assert.All(clusterClient.ClientConnectionParameters, val =>
                {
                    Assert.Equal(TimeSpan.FromSeconds(22), val.OperationTimeout);
                    Assert.Equal(TimeSpan.FromSeconds(33), val.ConnectionTimeout);
                    Assert.Equal("user", val.User);
                    Assert.Equal("pass", val.Password);
                });
            }
        }
예제 #3
0
 /// <summary>
 /// Specifies that <see cref="SequentialWorkingNodeSelectionPolicy"/> should be used for node selection on Cluster
 /// </summary>
 /// <typeparam name="TKey">Type of the Key for Cluster</typeparam>
 /// <param name="clusterBuilder">Cluster builder</param>
 /// <param name="maxSequentialErrorCount">Max number of sequential errors to mark node as not-working</param>
 /// <param name="recoveryTimeoutMs">Time after that the not-working node can be used again (need to detect node recovery)</param>
 /// <returns>The reference to the current builder instatnce</returns>
 public static BobClusterBuilder <TKey> WithSequentialWorkingNodeSelectionPolicy <TKey>(this BobClusterBuilder <TKey> clusterBuilder, int maxSequentialErrorCount = SequentialWorkingNodeSelectionPolicy.DefaultMaxSequentialErrorCount, int recoveryTimeoutMs = SequentialWorkingNodeSelectionPolicy.DefaultRecoveryTimeoutMs)
 {
     return(clusterBuilder.WithNodeSelectionPolicy(SequentialWorkingNodeSelectionPolicy.CreateFactory(maxSequentialErrorCount, recoveryTimeoutMs)));
 }
예제 #4
0
 /// <summary>
 /// Specifies that <see cref="FirstWorkingNodeSelectionPolicy"/> should be used for node selection on Cluster
 /// </summary>
 /// <typeparam name="TKey">Type of the Key for Cluster</typeparam>
 /// <param name="clusterBuilder">Cluster builder</param>
 /// <returns>The reference to the current builder instatnce</returns>
 public static BobClusterBuilder <TKey> WithFirstWorkingNodeSelectionPolicy <TKey>(this BobClusterBuilder <TKey> clusterBuilder)
 {
     return(clusterBuilder.WithNodeSelectionPolicy(FirstWorkingNodeSelectionPolicy.Factory));
 }
예제 #5
0
 /// <summary>
 /// Specifies that <see cref="SequentialNodeSelectionPolicy"/> should be used for node selection on Cluster
 /// </summary>
 /// <typeparam name="TKey">Type of the Key for Cluster</typeparam>
 /// <param name="clusterBuilder">Cluster builder</param>
 /// <returns>The reference to the current builder instatnce</returns>
 public static BobClusterBuilder <TKey> WithSequentialNodeSelectionPolicy <TKey>(this BobClusterBuilder <TKey> clusterBuilder)
 {
     return(clusterBuilder.WithNodeSelectionPolicy(SequentialNodeSelectionPolicy.Factory));
 }