Exemple #1
0
        protected GossipServiceBase(IPublisher bus,
                                    IGossipSeedSource gossipSeedSource,
                                    VNodeInfo nodeInfo,
                                    TimeSpan gossipInterval,
                                    TimeSpan allowedTimeDifference,
                                    TimeSpan gossipTimeout,
                                    TimeSpan deadMemberRemovalPeriod,
                                    ITimeProvider timeProvider,
                                    Func <MemberInfo[], MemberInfo> getNodeToGossipTo = null)
        {
            Ensure.NotNull(bus, "bus");
            Ensure.NotNull(gossipSeedSource, "gossipSeedSource");
            Ensure.NotNull(nodeInfo, "nodeInfo");
            Ensure.NotNull(timeProvider, nameof(timeProvider));

            _bus                    = bus;
            _publishEnvelope        = new PublishEnvelope(bus);
            _gossipSeedSource       = gossipSeedSource;
            NodeInfo                = nodeInfo;
            GossipInterval          = gossipInterval;
            AllowedTimeDifference   = allowedTimeDifference;
            GossipTimeout           = gossipTimeout;
            DeadMemberRemovalPeriod = deadMemberRemovalPeriod;
            _state                  = GossipState.Startup;
            _timeProvider           = timeProvider;
            _getNodeToGossipTo      = getNodeToGossipTo ?? GetNodeToGossipTo;
        }
Exemple #2
0
 public void Handle(GossipMessage.RetrieveGossipSeedSources message)
 {
     _state = GossipState.RetrievingGossipSeeds;
     try {
         _gossipSeedSource.BeginGetHostEndpoints(OnGotGossipSeedSources, null);
     } catch (Exception ex) {
         Log.Error(ex, "Error while retrieving cluster members through DNS.");
         _bus.Publish(TimerMessage.Schedule.Create(DnsRetryTimeout, _publishEnvelope,
                                                   new GossipMessage.RetrieveGossipSeedSources()));
     }
 }
Exemple #3
0
        public void Handle(GossipMessage.GotGossipSeedSources message)
        {
            var now        = DateTime.UtcNow;
            var dnsCluster = new ClusterInfo(
                message.GossipSeeds.Select(x => MemberInfo.ForManager(Guid.Empty, now, true, x, x)).ToArray());

            var oldCluster = _cluster;

            _cluster = MergeClusters(_cluster, dnsCluster, null, x => x);
            LogClusterChange(oldCluster, _cluster, null);

            _state = GossipState.Working;
            Handle(new GossipMessage.Gossip(0)); // start gossiping
        }
Exemple #4
0
        protected GossipServiceBase(IPublisher bus,
                                    IGossipSeedSource gossipSeedSource,
                                    VNodeInfo nodeInfo)
        {
            Ensure.NotNull(bus, "bus");
            Ensure.NotNull(gossipSeedSource, "gossipSeedSource");
            Ensure.NotNull(nodeInfo, "nodeInfo");

            _bus              = bus;
            _publishEnvelope  = new PublishEnvelope(bus);
            _gossipSeedSource = gossipSeedSource;
            NodeInfo          = nodeInfo;

            _state = GossipState.Startup;
        }
Exemple #5
0
        public void Handle(GossipMessage.GotGossipSeedSources message)
        {
            var now        = _timeProvider.UtcNow;
            var dnsCluster = new ClusterInfo(
                message.GossipSeeds.Select(x => MemberInfo.ForManager(Guid.Empty, now, true, x, x)).ToArray());

            var oldCluster = _cluster;

            _cluster = MergeClusters(_cluster, dnsCluster, null, x => x, _timeProvider.UtcNow, NodeInfo, CurrentLeader,
                                     AllowedTimeDifference, DeadMemberRemovalPeriod);
            LogClusterChange(oldCluster, _cluster, null);

            _state = GossipState.Working;
            Handle(new GossipMessage.Gossip(0));
        }
        protected GossipServiceBase(IPublisher bus,
                                    IGossipSeedSource gossipSeedSource,
                                    VNodeInfo nodeInfo,
                                    TimeSpan gossipInterval,
                                    TimeSpan allowedTimeDifference)
        {
            Ensure.NotNull(bus, "bus");
            Ensure.NotNull(gossipSeedSource, "gossipSeedSource");
            Ensure.NotNull(nodeInfo, "nodeInfo");

            _bus                  = bus;
            _publishEnvelope      = new PublishEnvelope(bus);
            _gossipSeedSource     = gossipSeedSource;
            NodeInfo              = nodeInfo;
            GossipInterval        = gossipInterval;
            AllowedTimeDifference = allowedTimeDifference;
            _state                = GossipState.Startup;
        }
Exemple #7
0
 public Join(GossipState state, Member member)
 {
     State  = state;
     Member = member;
 }
Exemple #8
0
 private bool HasTimedOut(GossipState state) =>
 unchecked (Environment.TickCount - state.CreationTickCount) >= Configuration.AntiEntropyIdleTimeout;
Exemple #9
0
 public NewMember(GossipState state, Member member)
 {
     State  = state;
     Member = member;
 }
Exemple #10
0
 public RingRequest(ulong term, GossipState state, Member target)
 {
     Term   = term;
     State  = state;
     Target = target;
 }
Exemple #11
0
 public Ping(ulong term, GossipState state)
 {
     Term  = term;
     State = state;
 }
Exemple #12
0
 public Ack(ulong term, GossipState state)
 {
     Term  = term;
     State = state;
 }
Exemple #13
0
 private bool HasTimedOut(GossipState state) =>
 unchecked (TransactionalTickCount.Value - state.CreationTickCount) >= Configuration.AntiEntropyIdleTimeout;