public void Update(NotificationKind kind, Peer peer)
 {
     lock (_lock)
     {
         IPAddress endpoint = peer.RpcAddress;
         if (!_healthyEndpoints.Contains(endpoint) && !_bannedEndpoints.Contains(endpoint))
         {
             _healthyEndpoints.Add(endpoint);
         }
     }
 }
Beispiel #2
0
        /// <summary>
        ///     Adds a new range of tokens to the permitted token ring
        /// </summary>
        /// <param name="peer">IPAddress and token range of the discovered node</param>
        internal void AddOrUpdateNode(Peer peer)
        {
            foreach (BigInteger token in peer.Tokens)
            {
                //remove if updating
                _permittedTokenRing.Remove(token);
                _bannedTokenRing.Remove(token);

                _permittedTokenRing.Add(token, peer.RpcAddress);

                _tokenCache = _permittedTokenRing.Keys.ToList();
            }
        }
        private void Notify(IPAddress rpcAddress, IEnumerable<string> tokens)
        {
            if (null != OnTopologyUpdate)
            {
                Peer peer = new Peer
                    {
                            RpcAddress = rpcAddress,
                            Tokens = tokens.Select(BigInteger.Parse).ToArray()
                    };

                _logger.Info("Discovered peer {0}", rpcAddress);

                OnTopologyUpdate(NotificationKind.Update, peer);
            }
        }
        public void Update(NotificationKind kind, Peer peer)
        {
            lock (_lock)
            {
                bool updated = false;
                IPAddress endpoint = peer.RpcAddress;
                if (!_healthyEndpoints.Contains(endpoint) && !_bannedEndpoints.Contains(endpoint))
                {
                    _healthyEndpoints.Add(endpoint);
                    updated = true;
                }

                if (updated)
                {
                    _healthyEndpoints.Sort((a1, a2) => _snitch.CompareEndpoints(_clientAddress, a1, a2));
                }
            }
        }
        private void Notify(IPAddress rpcAddress, string datacenter, string rack, IEnumerable<string> tokens)
        {
            if (!Network.IsValidEndpoint(rpcAddress))
            {
                _logger.Warn("Discovered invalid endpoint {0}", rpcAddress);
                return;
            }

            if (null != OnTopologyUpdate)
            {
                Peer peer = new Peer
                    {
                            RpcAddress = rpcAddress,
                            Datacenter = datacenter,
                            Rack = rack,
                            Tokens = tokens.Select(BigInteger.Parse).ToArray()
                    };

                _logger.Info("Discovered peer {0}, {1}, {2}", rpcAddress, datacenter, rack);

                OnTopologyUpdate(NotificationKind.Update, peer);
            }
        }
 public void Update(NotificationKind kind, Peer peer)
 {
     lock (_lock)
     {
         IPAddress endpoint = peer.RpcAddress;
         switch (kind)
         {
             case NotificationKind.Add:
             case NotificationKind.Update:
                 if (!_healthyEndpoints.Contains(endpoint) && !_bannedEndpoints.Contains(endpoint))
                 {
                     _healthyEndpoints.Add(endpoint);
                 }
                 break;
             case NotificationKind.Remove:
                 if (_healthyEndpoints.Contains(endpoint))
                 {
                     _healthyEndpoints.Remove(endpoint);
                 }
                 break;
         }
     }
 }
Beispiel #7
0
 public void Update(NotificationKind kind, Peer peer)
 {
     throw new NotImplementedException();
 }