Immutable data structure that holds the reachability status of subject nodes as seen from observer nodes. Failure detector for the subject nodes exist on the observer nodes. Changes (reachable, unreachable, terminated) are only performed by observer nodes to its own records. Each change bumps the version number of the record, and thereby it is always possible to determine which record is newest merging two instances. Aggregated status of a subject node is defined as (in this order): - Terminated if any observer node considers it as Terminated - Unreachable if any observer node considers it as Unreachable - Reachable otherwise, i.e. no observer node considers it as Unreachable
Exemplo n.º 1
0
        public ClusterReadView(Cluster cluster)
        {
            _cluster = cluster;
            _state = new ClusterEvent.CurrentClusterState();
            _reachability = Reachability.Empty;
            _latestStats = new ClusterEvent.CurrentInternalStats(new GossipStats(), new VectorClockStats());
            _selfAddress = cluster.SelfAddress;

            _eventBusListener =
                cluster.System.SystemActorOf(
                    Props.Create(() => new EventBusListener(cluster, this))
                        .WithDispatcher(cluster.Settings.UseDispatcher)
                        .WithDeploy(Deploy.Local), "clusterEventBusListener");
        }
Exemplo n.º 2
0
 public ReachabilityChanged(Reachability reachability)
 {
     _reachability = reachability;
 }
Exemplo n.º 3
0
        public Reachability Merge(IEnumerable<UniqueAddress> allowed, Reachability other)
        {
            var recordBuilder = ImmutableList.CreateBuilder<Record>();
            //TODO: Size hint somehow?
            var newVersions = _versions;
            foreach (var observer in allowed)
            {
                var observerVersion1 = CurrentVersion(observer);
                var observerVersion2 = other.CurrentVersion(observer);

                var rows1 = ObserverRows(observer);
                var rows2 = other.ObserverRows(observer);

                if (rows1 != null && rows2 != null)
                {
                    var rows = observerVersion1 > observerVersion2 ? rows1 : rows2;
                    foreach(var record in rows.Values.Where(r => allowed.Contains(r.Subject)))
                        recordBuilder.Add(record);
                }
                if (rows1 != null && rows2 == null)
                {
                    if(observerVersion1 > observerVersion2)
                        foreach (var record in rows1.Values.Where(r => allowed.Contains(r.Subject)))
                            recordBuilder.Add(record);
                }
                if (rows1 == null && rows2 != null)
                {
                    if (observerVersion2 > observerVersion1)
                        foreach (var record in rows2.Values.Where(r => allowed.Contains(r.Subject)))
                           recordBuilder.Add(record);
                }

                if (observerVersion2 > observerVersion1)
                    newVersions = newVersions.SetItem(observer, observerVersion2);
            }

            newVersions = ImmutableDictionary.CreateRange(newVersions.Where(p => allowed.Contains(p.Key)));

            return new Reachability(recordBuilder.ToImmutable(), newVersions);
        }
Exemplo n.º 4
0
 public ReachabilityChanged(Reachability reachability)
 {
     _reachability = reachability;
 }
Exemplo n.º 5
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="seen">TBD</param>
 /// <param name="reachability">TBD</param>
 /// <returns>TBD</returns>
 public GossipOverview Copy(ImmutableHashSet <UniqueAddress> seen = null, Reachability reachability = null)
 {
     return(new GossipOverview(seen ?? _seen, reachability ?? _reachability));
 }
Exemplo n.º 6
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="seen">TBD</param>
 /// <param name="reachability">TBD</param>
 public GossipOverview(ImmutableHashSet <UniqueAddress> seen, Reachability reachability)
 {
     _seen         = seen;
     _reachability = reachability;
 }
Exemplo n.º 7
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="reachability">TBD</param>
 public GossipOverview(Reachability reachability) : this(ImmutableHashSet.Create <UniqueAddress>(), reachability)
 {
 }
Exemplo n.º 8
0
 public GossipOverview Copy(ImmutableHashSet<UniqueAddress> seen = null, Reachability reachability = null)
 {
     return new GossipOverview(seen ?? _seen, reachability ?? _reachability);
 }
Exemplo n.º 9
0
 public GossipOverview(ImmutableHashSet<UniqueAddress> seen, Reachability reachability)
 {
     _seen = seen;
     _reachability = reachability;
 }
Exemplo n.º 10
0
 public GossipOverview(Reachability reachability) : this(ImmutableHashSet.Create<UniqueAddress>(), reachability) { }