コード例 #1
0
        public void RoundRobinDeadNodeDetectionTest()
        {
            var locator = new RoundRobinLocator();

            locator.Initialize(_nodes);

            for (int i = 1; i < _nodes.Count; ++i)
            {
                (_nodes[i] as NodeMock).IsDead = true;
            }

            for (int i = 0; i < _nodes.Count; ++i)
            {
                Assert.IsNotEmpty(locator.Locate(i.ToString()), "RoundRobinLocator found no node, but at least 1 is alive");
                var chosenNode = locator.Locate(i.ToString()).First <IMemcacheNode>();
                Assert.IsFalse(chosenNode.IsDead, "RoundRobinLocator returned a dead node");
            }

            (_nodes[0] as NodeMock).IsDead = true;

            for (int i = 0; i < _nodes.Count; ++i)
            {
                CollectionAssert.IsEmpty(locator.Locate(i.ToString()), "RoundRobinLocator found a node when all are dead");
            }

            for (int i = 0; i < _nodes.Count; ++i)
            {
                (_nodes[i] as NodeMock).IsDead = false;
            }
        }
コード例 #2
0
        public void RoundRobinDeadNodeDetectionTest()
        {
            var locator = new RoundRobinLocator();

            locator.Initialize(_nodes);

            for (int i = 1; i < _nodes.Count; ++i)
            {
                (_nodes[i] as NodeMock).IsDead = true;
            }

            for (int i = 0; i < _nodes.Count; ++i)
            {
                var keyAsBytes = i.ToString().Select(c => (byte)c).ToArray();

                var locations = locator.Locate(new RequestKeyWrapper(keyAsBytes));
                Assert.IsNotEmpty(locations, "RoundRobinLocator found no node, but at least 1 is alive");

                var chosenNode = locations.First();
                Assert.IsFalse(chosenNode.IsDead, "RoundRobinLocator returned a dead node");
            }

            (_nodes[0] as NodeMock).IsDead = true;

            for (int i = 0; i < _nodes.Count; ++i)
            {
                var keyAsBytes = i.ToString().Select(c => (byte)c).ToArray();
                CollectionAssert.IsEmpty(locator.Locate(new RequestKeyWrapper(keyAsBytes)), "RoundRobinLocator found a node when all are dead");
            }

            foreach (var node in _nodes)
            {
                (node as NodeMock).IsDead = false;
            }
        }
コード例 #3
0
        public void RoundRobinTest()
        {
            var locator = new RoundRobinLocator();

            locator.Initialize(_nodes);

            var nodeSet = new HashSet <IMemcacheNode>();

            for (int i = 0; i < _nodes.Count; ++i)
            {
                Assert.IsNotEmpty(locator.Locate(i.ToString()), "RoundRobinLocator found no node");
                var chosenNode = locator.Locate(i.ToString()).First <IMemcacheNode>();
                Assert.IsNotNull(chosenNode, "RoundRobinLocator found no node");
                nodeSet.Add(chosenNode);
            }

            Assert.AreEqual(_nodes.Count, nodeSet.Count, "All nodes should have been chosen at least once");
        }
コード例 #4
0
        public void RoundRobinTest()
        {
            var locator = new RoundRobinLocator();

            locator.Initialize(_nodes);

            var nodeSet = new HashSet <IMemcacheNode>();

            for (int i = 0; i < _nodes.Count; ++i)
            {
                var key = i.ToString().Select(c => (byte)c).ToArray();

                var locations = locator.Locate(new RequestKeyWrapper(key));
                Assert.IsNotEmpty(locations, "RoundRobinLocator found no node");

                var chosenNode = locations.First <IMemcacheNode>();
                Assert.IsNotNull(chosenNode, "RoundRobinLocator found no node");

                nodeSet.Add(chosenNode);
            }

            Assert.AreEqual(_nodes.Count, nodeSet.Count, "All nodes should have been chosen at least once");
        }