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


C# Server.CheckOnline方法代码示例

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


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

示例1: When_IOErrorThreshold_IsNot_Met_Within_IOErrorInterval_IsDead_Returns_False

        public void When_IOErrorThreshold_IsNot_Met_Within_IOErrorInterval_IsDead_Returns_False()
        {
            var json = File.ReadAllText(@"Data\\Configuration\\nodesext-cb-beta-4.json");
            var config = JsonConvert.DeserializeObject<BucketConfig>(json);
            var node = config.GetNodes().First();

            var endPoint = UriExtensions.GetEndPoint(_address);
            var configuration = new ClientConfiguration
            {
                IOErrorThreshold = 10,
                IOErrorCheckInterval = 10
            };
            var connectionPool = new FakeConnectionPool();
            var ioStrategy = new FakeIOStrategy(endPoint, connectionPool, false);
            var server = new Server(ioStrategy,
                node,
                configuration,
                config,
                new FakeTranscoder());

            Assert.IsFalse(server.IsDown);

            var stopWatch = new Stopwatch();
            stopWatch.Start();
            for (int i = 0; i < 11; i++)
            {
                server.CheckOnline(true);
                Console.WriteLine("{0}=>{1}", server.IsDown, server.IOErrorCount);
            }
            Console.WriteLine("Time elapsed {0}", stopWatch.ElapsedMilliseconds);
            stopWatch.Restart();

            Assert.IsFalse(server.IsDown);
            Assert.AreEqual(0, server.IOErrorCount);
        }
开发者ID:kendallb,项目名称:couchbase-net-client,代码行数:35,代码来源:ServerTests.cs

示例2: When_IOErrorThreshold_IsNot_Met_By_IOErrorInterval_NodeUnavailableException_Is_Thrown

        public void When_IOErrorThreshold_IsNot_Met_By_IOErrorInterval_NodeUnavailableException_Is_Thrown()
        {
            var json = File.ReadAllText(@"Data\\Configuration\\nodesext-cb-beta-4.json");
            var config = JsonConvert.DeserializeObject<BucketConfig>(json);
            var node = config.GetNodes().First();

            var endPoint = UriExtensions.GetEndPoint(_address);
            var configuration = new ClientConfiguration
            {
                IOErrorThreshold = 10,
                IOErrorCheckInterval = 100
            };
            var connectionPool = new FakeConnectionPool();
            var ioStrategy = new FakeIOStrategy(endPoint, connectionPool, false);
            var server = new Server(ioStrategy,
                node,
                configuration,
                config,
                new FakeTranscoder());

            Assert.IsFalse(server.IsDown);

            var stopWatch = new Stopwatch();
            stopWatch.Start();
            for (int i = 0; i < 11; i++)
            {
                server.CheckOnline(true);
                Console.WriteLine("{0}=>{1}", server.IsDown, server.IOErrorCount);
                Thread.Sleep(10);
            }
            // ReSharper disable once ThrowingSystemException
            Assert.Throws<NodeUnavailableException>(() =>
            {
                var operation = new FakeOperation(new DefaultTranscoder());
                server.Send(operation);
                throw operation.Exception;
            });
        }
开发者ID:kendallb,项目名称:couchbase-net-client,代码行数:38,代码来源:ServerTests.cs

示例3: When_IOErrorThreshold_Is_Met_By_IOErrorInterval_IsDead_Returns_True

        public void When_IOErrorThreshold_Is_Met_By_IOErrorInterval_IsDead_Returns_True()
        {
            var json = ResourceHelper.ReadResource(@"Data\Configuration\nodesext-cb-beta-4.json");
            var config = JsonConvert.DeserializeObject<BucketConfig>(json);
            var node = config.GetNodes().First();

            var endPoint = UriExtensions.GetEndPoint(_address);
            var configuration = new ClientConfiguration
            {
                IOErrorThreshold = 10,
                IOErrorCheckInterval = 100
            };
            var connectionPool = new FakeConnectionPool();
            var ioService = new FakeIOService(endPoint, connectionPool, false);
            var server = new Server(ioService,
                node,
                configuration,
                config,
                new FakeTranscoder());

            Assert.IsFalse(server.IsDown);

            var stopWatch = new Stopwatch();
            stopWatch.Start();
            for (int i = 0; i < 11; i++)
            {
                server.CheckOnline(true);
                Console.WriteLine("{0}=>{1}", server.IsDown, server.IOErrorCount);
                Thread.Sleep(10);
            }
            Console.WriteLine(stopWatch.ElapsedMilliseconds);
            Assert.IsTrue(server.IsDown);
            Assert.AreEqual(0, server.IOErrorCount);
        }
开发者ID:brantburnett,项目名称:couchbase-net-client,代码行数:34,代码来源:ServerTests.cs


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