示例#1
0
        public void FailedConnectionDelayTest()
        {
            var isConnDelayed = _nodeStats.IsConnectionDelayed();

            Assert.IsFalse(isConnDelayed.Result);

            _nodeStats.AddNodeStatsEvent(NodeStatsEventType.ConnectionFailed);
            isConnDelayed = _nodeStats.IsConnectionDelayed();
            Assert.IsTrue(isConnDelayed.Result);
            Assert.AreEqual(NodeStatsEventType.ConnectionFailed, isConnDelayed.DelayReason);
            var task = Task.Delay(100);

            task.Wait();
            isConnDelayed = _nodeStats.IsConnectionDelayed();
            Assert.IsFalse(isConnDelayed.Result);
        }
示例#2
0
        public async Task FailedConnectionDelayTest()
        {
            _nodeStats = new NodeStatsLight(_node);

            var isConnDelayed = _nodeStats.IsConnectionDelayed();

            Assert.IsFalse(isConnDelayed.Result, "before failure");

            _nodeStats.AddNodeStatsEvent(NodeStatsEventType.ConnectionFailed);
            isConnDelayed = _nodeStats.IsConnectionDelayed();
            Assert.IsTrue(isConnDelayed.Result, "just after failure");
            Assert.AreEqual(NodeStatsEventType.ConnectionFailed, isConnDelayed.DelayReason);
            await Task.Delay(125);

            isConnDelayed = _nodeStats.IsConnectionDelayed();
            Assert.IsFalse(isConnDelayed.Result, "125ms after failure");
        }
示例#3
0
        public void FailedConnectionDelayTest(bool useLight)
        {
            _nodeStats = useLight ? new NodeStatsLight(_node, _config) : (INodeStats) new NodeStats(_node, _config);

            var isConnDelayed = _nodeStats.IsConnectionDelayed();

            Assert.IsFalse(isConnDelayed.Result, "before failure");

            _nodeStats.AddNodeStatsEvent(NodeStatsEventType.ConnectionFailed);
            isConnDelayed = _nodeStats.IsConnectionDelayed();
            Assert.IsTrue(isConnDelayed.Result, "just after failure");
            Assert.AreEqual(NodeStatsEventType.ConnectionFailed, isConnDelayed.DelayReason);
            var task = Task.Delay(125);

            task.Wait();
            isConnDelayed = _nodeStats.IsConnectionDelayed();
            Assert.IsFalse(isConnDelayed.Result, "125ms after failure");
        }
示例#4
0
        public void ReportEvent(Node node, NodeStatsEventType eventType)
        {
            INodeStats stats = GetOrAdd(node);

            stats.AddNodeStatsEvent(eventType);
        }