Exemplo n.º 1
0
        public void Handle(GossipMessage.Gossip message)
        {
            if (_state != GossipState.Working)
            {
                return;
            }

            var node = _getNodeToGossipTo(_cluster.Members);

            if (node != null)
            {
                _cluster = UpdateCluster(_cluster, x => x.InstanceId == _memberInfo.InstanceId ? GetUpdatedMe(x) : x,
                                         _timeProvider, DeadMemberRemovalPeriod);
                _bus.Publish(new GrpcMessage.SendOverGrpc(node.HttpEndPoint,
                                                          new GossipMessage.SendGossip(_cluster, _memberInfo.HttpEndPoint),
                                                          _timeProvider.LocalTime.Add(GossipTimeout),
                                                          _timeProvider.LocalTime.Add(GossipInterval)));
            }

            var interval    = message.GossipRound < GossipRoundStartupThreshold ? GossipStartupInterval : GossipInterval;
            var gossipRound = Math.Min(int.MaxValue - 1, node == null ? message.GossipRound : message.GossipRound + 1);

            _bus.Publish(
                TimerMessage.Schedule.Create(interval, _publishEnvelope, new GossipMessage.Gossip(gossipRound)));
        }
Exemplo n.º 2
0
        public void Handle(GossipMessage.Gossip message)
        {
            if (_state != GossipState.Working)
            {
                return;
            }

            var node = GetNodeToGossipTo(_cluster.Members);

            if (node != null)
            {
                _cluster = UpdateCluster(_cluster, x => x.InstanceId == NodeInfo.InstanceId ? GetUpdatedMe(x) : x);
                _bus.Publish(new HttpMessage.SendOverHttp(node.InternalHttpEndPoint, new GossipMessage.SendGossip(_cluster, NodeInfo.InternalHttp)));
            }

            var interval    = message.GossipRound < 20 ? GossipStartupInterval : GossipInterval;
            var gossipRound = Math.Min(2000000000, node == null ? message.GossipRound : message.GossipRound + 1);

            _bus.Publish(TimerMessage.Schedule.Create(interval, _publishEnvelope, new GossipMessage.Gossip(gossipRound)));
        }