Example #1
0
        public void Update(NotificationKind kind, Peer peer)
        {
            lock (_lock)
            {
                IPAddress endpoint = peer.RpcAddress;
                switch (kind)
                {
                case NotificationKind.Add:
                    if (!_healthyEndpoints.Contains(endpoint))
                    {
                        _healthyEndpoints.Add(endpoint);
                        _ring.AddOrUpdateNode(peer);
                    }
                    break;

                case NotificationKind.Update:
                    _ring.AddOrUpdateNode(peer);
                    break;

                case NotificationKind.Remove:
                    if (_healthyEndpoints.Contains(endpoint))
                    {
                        _healthyEndpoints.Remove(endpoint);
                        _ring.RemoveNode(endpoint);
                    }
                    break;
                }
            }
        }
Example #2
0
        public void Update(NotificationKind kind, Peer peer)
        {
            var       newHealthy = new HashSet <IPAddress>(_healthyEndpoints);
            IPAddress endpoint   = peer.RpcAddress;

            switch (kind)
            {
            case NotificationKind.Add:
                if (!newHealthy.Contains(endpoint))
                {
                    newHealthy.Add(endpoint);
                    _healthyEndpoints = newHealthy.ToArray();
                    lock (_ring)
                    {
                        _ring.AddOrUpdateNode(peer);
                    }
                }
                break;

            case NotificationKind.Update:
                lock (_ring)
                {
                    _ring.AddOrUpdateNode(peer);
                }
                break;

            case NotificationKind.Remove:
                if (newHealthy.Contains(endpoint))
                {
                    newHealthy.Remove(endpoint);
                    _healthyEndpoints = newHealthy.ToArray();
                    lock (_ring)
                    {
                        _ring.RemoveNode(endpoint);
                    }
                }
                break;
            }
        }