当前位置: 首页>>代码示例>>C#>>正文


C# ClientConfiguration.Initialize方法代码示例

本文整理汇总了C#中Couchbase.Configuration.Client.ClientConfiguration.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# ClientConfiguration.Initialize方法的具体用法?C# ClientConfiguration.Initialize怎么用?C# ClientConfiguration.Initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Couchbase.Configuration.Client.ClientConfiguration的用法示例。


在下文中一共展示了ClientConfiguration.Initialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: When_GetBaseViewUri_Is_Called_With_EncryptTraffic_True_Uri_Is_SSL_URI

        public void When_GetBaseViewUri_Is_Called_With_EncryptTraffic_True_Uri_Is_SSL_URI()
        {
            var configuration = new ClientConfiguration
            {
                UseSsl = true
            };
            configuration.Initialize();

            var json = File.ReadAllText(@"Data\\Configuration\\cb4-config-4-nodes.json");
            var config = JsonConvert.DeserializeObject<BucketConfig>(json);
            var nodes = config.GetNodes();

            var node = nodes.Find(x => x.Hostname.Equals("192.168.109.104"));

            var ioStrategy = new FakeIOStrategy(UriExtensions.GetEndPoint(node.Hostname + ":" + node.KeyValue),
                new FakeConnectionPool(), false);

            using (var server = new Server(ioStrategy,
                node,
                configuration,
                config,
                new FakeTranscoder()))
            {
                var uri = server.CachedViewBaseUri;
                Assert.AreEqual("https://192.168.109.104:18092/default", uri);
            }
        }
开发者ID:kendallb,项目名称:couchbase-net-client,代码行数:27,代码来源:ServerTests.cs

示例2: When_Observing_Key_During_RemoveAsync_Durability_Constraint_Is_Reached

        public async Task When_Observing_Key_During_RemoveAsync_Durability_Constraint_Is_Reached()
        {
            var configuration = new ClientConfiguration
            {
                Servers = new List<Uri>
                {
                    new Uri(ConfigurationManager.AppSettings["bootstrapUrl"])
                }
            };
            configuration.Initialize();

            var provider = new CarrierPublicationProvider(
                configuration,
                (pool) => new PooledIOService(pool),
                (config, endpoint) => new ConnectionPool<Connection>(config, endpoint),
                SaslFactory.GetFactory(),
                new DefaultConverter(),
                new DefaultTranscoder(new DefaultConverter()));

            var configInfo = provider.GetConfig("default");

            var clusterController = new Mock<IClusterController>();
            clusterController.Setup(x => x.Transcoder).Returns(new DefaultTranscoder());

            var pending = new ConcurrentDictionary<uint, IOperation>();

            var observer = new KeyObserver(pending, configInfo, clusterController.Object, 10, 500);
            using (var cts = new CancellationTokenSource(configuration.ObserveTimeout))
            {
                var constraintReached =
                    await observer.ObserveRemoveAsync("Test_Timeout_Remove_Async", 0, ReplicateTo.Zero, PersistTo.One, cts);
                Assert.IsTrue(constraintReached);
            }
        }
开发者ID:brantburnett,项目名称:couchbase-net-client,代码行数:34,代码来源:KeyObserverTests.cs

示例3: SetUp

        public void SetUp()
        {
            var configuration = new ClientConfiguration
            {
                UseSsl = true
            };
            configuration.Initialize();

            var json = File.ReadAllText(@"Data\\Configuration\\cb4-config-4-nodes.json");
            var config = JsonConvert.DeserializeObject<BucketConfig>(json);
            var nodes = config.GetNodes();

            var node = nodes.Find(x => x.Hostname.Equals("192.168.109.104"));

            var ioStrategy = new FakeIOStrategy(UriExtensions.GetEndPoint(node.Hostname + ":" + node.KeyValue),
                new FakeConnectionPool(), false);

            _configContext = new CouchbaseConfigContext(config,
                configuration,
                pool => ioStrategy,
                (c, e) => new FakeConnectionPool(),
                SaslFactory.GetFactory(),
                new DefaultTranscoder(new DefaultConverter()));

            _configContext.LoadConfig();
        }
开发者ID:NaveenKudupudi,项目名称:couchbase-net-client,代码行数:26,代码来源:CouchbaseConfigContext_MDS_Tests.cs

示例4: Test_Custom

        public void Test_Custom()
        {
            var config = new ClientConfiguration
            {
                PoolConfiguration = new PoolConfiguration
                {
                    MaxSize = 10,
                    MinSize = 10
                }
            };
            config.Initialize();

            Assert.AreEqual(1, config.BucketConfigs.Count);

            var bucketConfig = config.BucketConfigs.First().Value;

            IPAddress ipAddress;
            IPAddress.TryParse("127.0.0.1", out ipAddress);
            var endPoint = new IPEndPoint(ipAddress, bucketConfig.Port);
            Assert.AreEqual(endPoint, bucketConfig.GetEndPoint());

            Assert.IsEmpty(bucketConfig.Password);
            Assert.IsEmpty(bucketConfig.Username);
            Assert.AreEqual(11210, bucketConfig.Port);
            Assert.AreEqual("default", bucketConfig.BucketName);

            Assert.AreEqual(10, bucketConfig.PoolConfiguration.MaxSize);
            Assert.AreEqual(10, bucketConfig.PoolConfiguration.MinSize);
            Assert.AreEqual(2500, bucketConfig.PoolConfiguration.RecieveTimeout);
            Assert.AreEqual(2500, bucketConfig.PoolConfiguration.OperationTimeout);
            Assert.AreEqual(10000, bucketConfig.PoolConfiguration.ShutdownTimeout);
        }
开发者ID:WhallaLabs,项目名称:couchbase-net-client,代码行数:32,代码来源:ClientConfigurationTests.cs

示例5: When_Observing_Key_During_Remove_Durability_Constraint_Is_Reached

        public void When_Observing_Key_During_Remove_Durability_Constraint_Is_Reached()
        {
            var configuration = new ClientConfiguration
            {
                Servers = new List<Uri>
                {
                    new Uri(ConfigurationManager.AppSettings["bootstrapUrl"])
                }
            };
            configuration.Initialize();

            var provider = new CarrierPublicationProvider(
                configuration,
                (pool) => new DefaultIOStrategy(pool),
                (config, endpoint) => new ConnectionPool<EapConnection>(config, endpoint),
                SaslFactory.GetFactory3(),
                new AutoByteConverter(),
                new TypeSerializer(new AutoByteConverter()));

            var configInfo = provider.GetConfig("default");

            var observer = new KeyObserver(configInfo, 10, 500);
            var constraintReached = observer.ObserveRemove("Test_Timeout_Remove", 0, ReplicateTo.Zero, PersistTo.One);
            Assert.IsTrue(constraintReached);
        }
开发者ID:WhallaLabs,项目名称:couchbase-net-client,代码行数:25,代码来源:KeyObserverTests.cs

示例6: When_Observing_Key_During_Add_Durability_Constraint_Is_Reached

        public void When_Observing_Key_During_Add_Durability_Constraint_Is_Reached()
        {
            var configuration = new ClientConfiguration
            {
                Servers = new List<Uri>
                {
                    new Uri(ConfigurationManager.AppSettings["bootstrapUrl"])
                }
            };
            configuration.Initialize();

            var provider = new CarrierPublicationProvider(
                configuration,
                (pool) => new DefaultIOStrategy(pool),
                (config, endpoint) => new ConnectionPool<EapConnection>(config, endpoint),
                SaslFactory.GetFactory3(),
                new AutoByteConverter(),
                new TypeSerializer(new AutoByteConverter()));

            var configInfo = provider.GetConfig("default");

            ulong cas = 0;
            using (var cluster = new CouchbaseCluster(configuration))
            {
                using (var bucket = cluster.OpenBucket())
                {
                    bucket.Remove("Test_Timeout_Add");
                    bucket.Insert("Test_Timeout_Add", "");
                    cas = bucket.Upsert("Test_Timeout_Add", "").Cas;
                }
            }
            var observer = new KeyObserver(configInfo, 10, 500);
            var constraintReached = observer.ObserveAdd("Test_Timeout_Add", cas, ReplicateTo.One, PersistTo.One);
            Assert.IsTrue(constraintReached);
        }
开发者ID:WhallaLabs,项目名称:couchbase-net-client,代码行数:35,代码来源:KeyObserverTests.cs

示例7: Test_LoadConfig

        //[Test]
        public void Test_LoadConfig()
        {
            var clientConfig = new ClientConfiguration
            {
                Servers = new List<Uri>
                {
                    new Uri(ConfigurationManager.AppSettings["bootstrapUrl"])
                },
                PoolConfiguration = new PoolConfiguration
                {
                    MaxSize = 2,
                    MinSize = 1
                },
                UseSsl = false
            };
            clientConfig.Initialize();

            var bucketConfig =
                JsonConvert.DeserializeObject<BucketConfig>(
                    File.ReadAllText("Data\\Configuration\\config-revision-8934.json"));
            var configInfo = new CouchbaseConfigContext(bucketConfig,
                clientConfig,
                pool => new DefaultIOStrategy(pool),
                (config, endpoint) => new ConnectionPool<Connection>(config, endpoint),
                SaslFactory.GetFactory3(),
                new DefaultTranscoder(new DefaultConverter()));
            configInfo.LoadConfig();


            var servers = configInfo.GetServers();
            Assert.AreEqual(servers.Count(), bucketConfig.Nodes.Count());

            var vbuckets = configInfo.GetVBuckets();
            for (int i = 0; i < 1024; i++)
            {
                var actual = vbuckets[i].Primary;
                var expected = bucketConfig.VBucketServerMap.VBucketMap[i][0];
                Assert.AreEqual(expected, actual);
            }

            var bucketConfig2 =
                JsonConvert.DeserializeObject<BucketConfig>(
                    File.ReadAllText("Data\\Configuration\\config-revision-9958.json"));
            configInfo.LoadConfig(bucketConfig2);

            servers = configInfo.GetServers();
            Assert.AreEqual(servers.Count(), bucketConfig2.Nodes.Count());
            vbuckets = configInfo.GetVBuckets();
            for (int i = 0; i < 1024; i++)
            {
                var actual = vbuckets[i].Primary;
                var expected = bucketConfig2.VBucketServerMap.VBucketMap[i][0];
                Assert.AreEqual(expected, actual);
            }

            Log.Debug(m => m("CLEANUP!"));
            configInfo.Dispose();
        }
开发者ID:kendallb,项目名称:couchbase-net-client,代码行数:59,代码来源:CouchbaseConfigContextTests.cs

示例8: Test_KeySeqnoObserver

        public void Test_KeySeqnoObserver()
        {

            var configuration = new ClientConfiguration
            {
                Servers = new List<Uri>
                {
                    new Uri(ConfigurationManager.AppSettings["bootstrapUrl"])
                }
            };

            var key = "Test_KeySeqnoObserver";
            using (var cluster = new Cluster(configuration))
            {
                using (var bucket = cluster.OpenBucket())
                {
                    bucket.Remove(key);
                }
            }

            configuration.Initialize();

            var provider = new CarrierPublicationProvider(
                configuration,
                (pool) => new PooledIOService(pool),
                (config, endpoint) => new ConnectionPool<Connection>(config, endpoint),
                SaslFactory.GetFactory(),
                new DefaultConverter(),
                new DefaultTranscoder(new DefaultConverter(), new DefaultSerializer()));

            var configInfo = provider.GetConfig("default");

            var features = new List<short>();
            features.Add((short)ServerFeatures.MutationSeqno);

            var keyMapper = configInfo.GetKeyMapper();
            var mappedNode = keyMapper.MapKey(key);
            var node = mappedNode.LocatePrimary();

            foreach (var server in configInfo.Servers.Where(x=>x.IsDataNode))
            {
                var hello = new Hello("couchbase-net-sdk/2.1.4", features.ToArray(), provider.Transcoder, 0, 0);
                var result3 = server.Send(hello);
                Assert.IsTrue(result3.Success);
            }

            var result = node.Send(new Add<string>(key, "", (VBucket)mappedNode,
                new DefaultTranscoder(new DefaultConverter(), new DefaultSerializer()), 1000));

            var clusterController = new Mock<IClusterController>();
            clusterController.Setup(x => x.Transcoder).Returns(new DefaultTranscoder());

            var pending = new ConcurrentDictionary<uint, IOperation>();

            var keyObserver = new KeySeqnoObserver("thekey", pending, configInfo, clusterController.Object, 0, 1000);
            var durabilityReached = keyObserver.Observe(result.Token, ReplicateTo.Zero, PersistTo.One);
            Assert.IsTrue(durabilityReached);
        }
开发者ID:brantburnett,项目名称:couchbase-net-client,代码行数:58,代码来源:KeySeqnoObserverTests.cs

示例9: When_EnableTcpKeepAlives_Disabled_On_PoolConfiguration_Defaults_Are_Not_Used

        public void When_EnableTcpKeepAlives_Disabled_On_PoolConfiguration_Defaults_Are_Not_Used()
        {
            var clientConfig = new ClientConfiguration();
            clientConfig.PoolConfiguration.EnableTcpKeepAlives = false;

            clientConfig.Initialize();

            Assert.AreEqual(ClientConfiguration.Defaults.EnableTcpKeepAlives, clientConfig.EnableTcpKeepAlives);
            Assert.AreEqual(false, clientConfig.PoolConfiguration.EnableTcpKeepAlives);
        }
开发者ID:brantburnett,项目名称:couchbase-net-client,代码行数:10,代码来源:ClientConfigurationTests.cs

示例10: When_TcpKeepAliveTime_Set_On_PoolConfiguration_Defaults_Are_Not_Used

        public void When_TcpKeepAliveTime_Set_On_PoolConfiguration_Defaults_Are_Not_Used()
        {
            var clientConfig = new ClientConfiguration();
            clientConfig.PoolConfiguration.TcpKeepAliveTime = 1000;

            clientConfig.Initialize();

            Assert.AreEqual(ClientConfiguration.Defaults.TcpKeepAliveTime, clientConfig.TcpKeepAliveTime);
            Assert.AreEqual(1000, clientConfig.PoolConfiguration.TcpKeepAliveTime);
        }
开发者ID:brantburnett,项目名称:couchbase-net-client,代码行数:10,代码来源:ClientConfigurationTests.cs

示例11: When_TcpKeepAliveInterval_Set_On_ClientConfiguration_Defaults_Are_Not_Used

        public void When_TcpKeepAliveInterval_Set_On_ClientConfiguration_Defaults_Are_Not_Used()
        {
            var clientConfig = new ClientConfiguration
            {
                TcpKeepAliveInterval = 10
            };

            clientConfig.Initialize();

            Assert.AreEqual(10, clientConfig.TcpKeepAliveInterval);
            Assert.AreEqual(10, clientConfig.PoolConfiguration.TcpKeepAliveInterval);
        }
开发者ID:brantburnett,项目名称:couchbase-net-client,代码行数:12,代码来源:ClientConfigurationTests.cs

示例12: GetConfiguration

 /// <summary>
 /// Gets the connection using the value of the <c>bootstrapUrl</c> in the App.Config as the node to bootstrap from.
 /// </summary>
 /// <returns></returns>
 public static ClientConfiguration GetConfiguration()
 {
     var config = new ClientConfiguration
     {
         Servers = new List<Uri>
         {
             new Uri(ConfigurationManager.AppSettings["bootstrapUrl"])
         }
     };
     config.ConnectionPoolCreator = ConnectionPoolFactory.GetFactory<ConnectionPool<MultiplexingConnection>>();
     config.IOServiceCreator = IOServiceFactory.GetFactory<MultiplexingIOService>();
     config.Initialize();
     return config;
 }
开发者ID:orangeloop,项目名称:couchbase-net-client,代码行数:18,代码来源:ClientConfigUtil.cs

示例13: When_GetBaseViewUri_Is_Called_With_EncryptTraffic_True_Uri_Is_SSL_URI

        public void When_GetBaseViewUri_Is_Called_With_EncryptTraffic_True_Uri_Is_SSL_URI()
        {
            var configuration = new ClientConfiguration
            {
                UseSsl = true
            };
            configuration.Initialize();

            var connectionPool = new ConnectionPool<EapConnection>(new PoolConfiguration(), UriExtensions.GetEndPoint(Address));
            var ioStrategy = new DefaultIOStrategy(connectionPool);
            using (var server = new Server(ioStrategy, new Node(), configuration))
            {
                var uri = server.GetBaseViewUri("default");
                Assert.AreEqual("https://localhost:18092/default", uri);
            }
        }
开发者ID:WhallaLabs,项目名称:couchbase-net-client,代码行数:16,代码来源:ServerTests.cs

示例14: Test_Custom

        public void Test_Custom()
        {
            var config = new ClientConfiguration
            {
                DefaultOperationLifespan = 123,
                PoolConfiguration = new PoolConfiguration
                {
                    MaxSize = 10,
                    MinSize = 10,
                    SendTimeout = 12000,
                    MaxCloseAttempts = 6,
                    CloseAttemptInterval = 120
                },
                ViewRequestTimeout = 5000
            };
            config.Initialize();

            Assert.AreEqual(1, config.BucketConfigs.Count);

            var bucketConfig = config.BucketConfigs.First().Value;

            IPAddress ipAddress;
            IPAddress.TryParse("127.0.0.1", out ipAddress);
            var endPoint = new IPEndPoint(ipAddress, bucketConfig.Port);
            Assert.AreEqual(endPoint, bucketConfig.GetEndPoint());

            Assert.IsEmpty(bucketConfig.Password);
            Assert.IsEmpty(bucketConfig.Username);
            Assert.AreEqual(11210, bucketConfig.Port);
            Assert.AreEqual("default", bucketConfig.BucketName);

            Assert.AreEqual(10, bucketConfig.PoolConfiguration.MaxSize);
            Assert.AreEqual(10, bucketConfig.PoolConfiguration.MinSize);
#pragma warning disable 612
            Assert.AreEqual(2500, bucketConfig.PoolConfiguration.RecieveTimeout);
#pragma warning restore 612
#pragma warning disable 618
            Assert.AreEqual(2500, bucketConfig.PoolConfiguration.OperationTimeout);
#pragma warning restore 618
            Assert.AreEqual(10000, bucketConfig.PoolConfiguration.ShutdownTimeout);
            Assert.AreEqual(12000, bucketConfig.PoolConfiguration.SendTimeout);
            Assert.AreEqual(123, bucketConfig.DefaultOperationLifespan);
            Assert.AreEqual(120, bucketConfig.PoolConfiguration.CloseAttemptInterval);
            Assert.AreEqual(6, bucketConfig.PoolConfiguration.MaxCloseAttempts);
            Assert.AreEqual(5000, config.ViewRequestTimeout);
        }
开发者ID:brantburnett,项目名称:couchbase-net-client,代码行数:46,代码来源:ClientConfigurationTests.cs

示例15: Test_ClientConnection_With_Ssl

        public void Test_ClientConnection_With_Ssl()
        {
            var bootstrapUrl = ConfigurationManager.AppSettings["bootstrapUrl"];
            var config = new ClientConfiguration
            {
                UseSsl = true,
                Servers = new List<Uri>
            {
                new Uri(bootstrapUrl)
            }};
            config.Initialize();

            var cluster = new Cluster(config);
            using (var bucket = cluster.OpenBucket())
            {
                Assert.IsNotNull(bucket);
            }
        }
开发者ID:kendallb,项目名称:couchbase-net-client,代码行数:18,代码来源:SSLConnectionTests.cs


注:本文中的Couchbase.Configuration.Client.ClientConfiguration.Initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。