Esempio n. 1
0
        private void NodeFail(IMemcachedNode node)
        {
            _log.LogDebug("Node {EndPoint} is dead.", node.EndPoint);

            // the timer is stopped until we encounter the first dead server
            // when we have one, we trigger it and it will run after DeadTimeout has elapsed
            lock (_deadSync)
            {
                if (_isDisposed)
                {
                    _log.LogWarning("Got a node fail but the pool is already disposed. Ignoring.");

                    return;
                }

                // bubble up the fail event to the client
                var fail = NodeFailed;
                if (fail != null)
                {
                    fail(node);
                }

                // re-initialize the locator
                var newLocator = _configuration.CreateNodeLocator();
                newLocator.Initialize(_allNodes.Where(n => n.IsAlive).ToArray());
                Interlocked.Exchange(ref NodeLocator, newLocator);

                // the timer is stopped until we encounter the first dead server
                // when we have one, we trigger it and it will run after DeadTimeout has elapsed
                if (!_isTimerActive)
                {
                    _log.LogDebug("Starting the recovery timer.");

                    if (_resurrectTimer == null)
                    {
                        _resurrectTimer = new Timer(RezCallback, null, _deadTimeoutMsec, Timeout.Infinite);
                    }
                    else
                    {
                        _resurrectTimer.Change(_deadTimeoutMsec, Timeout.Infinite);
                    }

                    _isTimerActive = true;

                    _log.LogDebug("Timer started.");
                }
            }
        }
Esempio n. 2
0
 public void Start()
 {
     nodeLocator = configuration.CreateNodeLocator();
     nodes       = new Dictionary <string, IMemcachedNode>();
     nodeLocator.Initialize(new List <IMemcachedNode>());
     Poll(null); // seed it once before returning from Start()
     pollingTimer = new Timer(Poll, null, pollingInterval, pollingInterval);
 }
        private static void ValidateConfig(IMemcachedClientConfiguration config)
        {
            Assert.IsNotNull(config);

            Assert.IsInstanceOf(typeof(TestKeyTransformer), config.CreateKeyTransformer());
            Assert.IsInstanceOf(typeof(TestLocator), config.CreateNodeLocator());
            Assert.IsInstanceOf(typeof(TestTranscoder), config.CreateTranscoder());
        }
 public void TestVBucketConfig()
 {
     IMemcachedClientConfiguration config = ConfigurationManager.GetSection("test/vbucket") as IMemcachedClientConfiguration;
     var loc = config.CreateNodeLocator();
 }