private void HandleMessage(CreateEventMarket message)
        {
            try
            {
                var cluster    = Cluster.Get(Context.System);
                var replicator = DistributedData.Get(Context.System).Replicator;

                var key = new ORSetKey <string>($"Event-{message.EventId}");

                var writeConsistency = new WriteMajority(TimeSpan.FromSeconds(2));

                replicator.Tell(Dsl.Update(key, ORSet <string> .Empty, writeConsistency,
                                           existing => existing.Add(cluster, message.Market)));

                var localEvent =
                    replicator.Ask <IGetResponse>(Dsl.Get(key, ReadLocal.Instance));


                Sender.Tell(localEvent.Result);
            }
            catch (Exception e)
            {
                _log.Error(e, "Unable to process message CreateEventMarket for Event {0} Market {1}", message.EventId,
                           message.Market);
                Sender.Tell(
                    $"Unable to process message CreateEventMarket for Event {message.EventId} Market {message.Market}");
            }
        }
        public async Task DistributedData_Replicator_Defaults_to_NoSupervisor()
        {
            const string replicatorActorPath   = "/user/ddataReplicator";
            const string durableStoreActorPath = "/user/ddataReplicator/durableStore";

            await InitCluster();

            var replicator = DistributedData.Get(_sys1).Replicator;

            IActorRef durableStore = null;

            await AwaitAssertAsync(() =>
            {
                durableStore = _sys1.ActorSelection(durableStoreActorPath).ResolveOne(TimeSpan.FromSeconds(3))
                               .ContinueWith(
                    m => m.Result).Result;
            }, TimeSpan.FromSeconds(10), TimeSpan.FromMilliseconds(100));

            Watch(replicator);
            Watch(durableStore);
            durableStore.Tell(new InitFail());

            // termination orders aren't guaranteed, so can't use ExpectTerminated here
            var terminated1 = ExpectMsg <Terminated>(TimeSpan.FromSeconds(10));
            var terminated2 = ExpectMsg <Terminated>(TimeSpan.FromSeconds(10));

            ImmutableHashSet.Create(terminated1.ActorRef, terminated2.ActorRef).Should().BeEquivalentTo(durableStore, replicator);

            // The replicator should not have been recreated, so expect ActorNotFound
            await Assert.ThrowsAsync <ActorNotFoundException>(() =>
                                                              _sys1.ActorSelection(replicatorActorPath).ResolveOne(TimeSpan.FromSeconds(5)));
        }
Exemple #3
0
        private static async Task Main()
        {
            Console.WriteLine("Put the ddata mdb file in a folder called cluster-data in the application root folder. Press a key when done");
            Console.Read();

            var cfg = ConfigurationFactory.ParseString(File.ReadAllText("HOCON"))
                      .WithFallback(DistributedData.DefaultConfig());

            var originalColour = Console.ForegroundColor;

            var sys           = ActorSystem.Create("test", cfg);
            var dd            = DistributedData.Get(sys);
            int emptyKeyCount = 0;

            var resp = await dd.Replicator.Ask <GetKeysIdsResult>(Dsl.GetKeyIds);

            foreach (var resultKey in resp.Keys)
            {
                var key = new ORSetKey <string>($"{resultKey}");

                var keyResp = await dd.Replicator.Ask <IGetResponse>(Dsl.Get(key));

                Console.ForegroundColor = ConsoleColor.Green;
                if (keyResp.Get(key).Elements.Count == 0)
                {
                    emptyKeyCount++;
                }

                Console.WriteLine($"{key.Id}\t{string.Join<string>(",", keyResp.Get(key).Elements)}");
            }

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine($"Finished loading {resp.Keys.Count} keys. There were {emptyKeyCount} empty keys");
            Console.ForegroundColor = originalColour;
        }
        //The way our data works, I opted to just removed all the key data, but leave the key intact as sometimes i need to use the key again in rare instances, but once deleted, ddata doesn't allow this.
        private void HandleMessage(CloseEvent message)
        {
            try
            {
                var replicator       = DistributedData.Get(Context.System).Replicator;
                var cluster          = Cluster.Get(Context.System);
                var key              = new ORSetKey <string>($"Event-{message.EventId}");
                var writeConsistency = WriteLocal.Instance;
                replicator.Tell(Dsl.Update(key, ORSet <string> .Empty, writeConsistency, $"Event-{message.EventId}",
                                           existing =>
                {
                    return(existing.Clear(cluster));
                }));

                var finalResult =
                    replicator.Ask <IGetResponse>(Dsl.Get(key, ReadLocal.Instance));
                Sender.Tell(finalResult.Result);
            }
            catch (DataDeletedException e)
            {
                Sender.Tell($"Event {message.EventId} has been deleted");
            }
            catch (Exception e)
            {
                _log.Error(e, "Unable to process message CloseEvent for Event {0}", message.EventId);
                Sender.Tell($"Unable to process message CloseEvent for Event {message.EventId}");
            }
        }
Exemple #5
0
        public DurableDataSpecConfig(bool writeBehind)
        {
            First  = Role("first");
            Second = Role("second");

            var tempDir = Path.Combine(Path.GetTempPath(), "target", $"DurableDataSpec-{DateTime.UtcNow.Ticks}-ddata");

            CommonConfig = DebugConfig(false)
                           .WithFallback(ConfigurationFactory.ParseString($@"
                akka.loglevel = INFO
                akka.actor.provider = ""Akka.Cluster.ClusterActorRefProvider, Akka.Cluster""
                akka.log-dead-letters-during-shutdown = off
                akka.cluster.distributed-data.durable.keys = [""durable*""]
                akka.cluster.distributed-data.durable.lmdb {{
                    dir = """"""{tempDir}""""""
                    map-size = 10 MiB
                    write-behind-interval = {(writeBehind ? "200ms" : "off")}
                }}
                akka.cluster.distributed-data.durable.store-actor-class = ""Akka.DistributedData.LightningDB.LmdbDurableStore, Akka.DistributedData.LightningDB""
                # initialization of lmdb can be very slow in CI environment
                akka.test.single-expect-default = 15s"))
                           .WithFallback(DistributedData.DefaultConfig());

            TestTransport = true;
        }
 static ReplicatorSpecs()
 {
     SpecConfig = ConfigurationFactory.ParseString(@"
         akka.loglevel = DEBUG
         akka.actor.provider = cluster
         akka.remote.dot-netty.tcp.port = 0")
                  .WithFallback(DistributedData.DefaultConfig());
 }
 public LocalConcurrencySpec(ITestOutputHelper output)
     : base(ConfigurationFactory.ParseString(@"
       akka.actor.provider = ""Akka.Cluster.ClusterActorRefProvider, Akka.Cluster""
       akka.remote.dot-netty.tcp.port = 0"),
            "LocalConcurrencySpec", output)
 {
     _replicator = DistributedData.Get(Sys).Replicator;
 }
Exemple #8
0
 public App(ActorSystem system)
 {
     this.system           = system;
     this.cluster          = Cluster.Get(system);
     this.ddata            = DistributedData.Get(system);
     this.timeout          = TimeSpan.FromSeconds(10);
     this.readConsistency  = new ReadMajority(timeout);
     this.writeConsistency = new WriteMajority(timeout);
 }
 static ReplicatorResiliencySpec()
 {
     SpecConfig = ConfigurationFactory.ParseString(@"
         akka.loglevel = DEBUG
         akka.actor.provider = cluster
         akka.remote.dot-netty.tcp.port = 0
         akka.cluster.distributed-data.durable.keys = [""*""]
         akka.cluster.distributed-data.durable.store-actor-class = ""Akka.DistributedData.Tests.FakeDurableStore, Akka.DistributedData.Tests")
                  .WithFallback(DistributedData.DefaultConfig());
 }
Exemple #10
0
        static void StartActors(ActorSystem sys)
        {
            var replicator = DistributedData.Get(sys).Replicator;

            catalogRegistries.Add(sys.ActorOf(
                                      Props.Create(() => new CatalogRegistryActor()),
                                      "CatalogRegistryActor"));

            genericActors.Add(sys.ActorOf(Props.Create(() => new SomeGenericActor(replicator)),
                                          "SomeActor"));
        }
            public Updater()
            {
                var cluster    = Cluster.Cluster.Get(Context.System);
                var replicator = DistributedData.Get(Context.System).Replicator;

                Receive <string>(s =>
                {
                    var update = Dsl.Update(Key, ORSet <string> .Empty, WriteLocal.Instance, old => old.Add(cluster.SelfUniqueAddress, s));
                    replicator.Tell(update);
                });
            }
Exemple #12
0
        public ReplicatorPruningSpecConfig()
        {
            First  = Role("first");
            Second = Role("second");
            Third  = Role("third");

            CommonConfig = ConfigurationFactory.ParseString(@"
                akka.loglevel = INFO
                akka.actor.provider = ""Akka.Cluster.ClusterActorRefProvider, Akka.Cluster""
                akka.log-dead-letters-during-shutdown = off")
                           .WithFallback(DistributedData.DefaultConfig());
        }
 private void Join(RoleName from, RoleName to)
 {
     RunOn(() =>
     {
         Cluster.Join(Node(to).Address);
         _replicator = DistributedData.Get(Sys).Replicator;
         _nodeConfig = new NodeConfig(from.Name)
         {
             GossipTimeFrameInSeconds = 5
         };
         _actorDirectory = new ActorDirectory <XmlMessage, XmlMessagePattern>(Sys);
     }, from);
     EnterBarrier(from.Name + "-joined");
 }
        public JepsenInspiredInsertSpec(JepsenInspiredInsertSpecConfig config) : base(config)
        {
            _cluster      = Cluster.Cluster.Get(Sys);
            _replicator   = DistributedData.Get(Sys).Replicator;
            _nodes        = Roles.Remove(Controller);
            _nodeCount    = _nodes.Count;
            _timeout      = Dilated(TimeSpan.FromSeconds(3));
            _expectedData = Enumerable.Range(0, _totalCount).ToArray();
            var nodeindex = _nodes.Zip(Enumerable.Range(0, _nodes.Count - 1), (name, i) => new KeyValuePair <int, RoleName>(i, name))
                            .ToImmutableDictionary();

            _data = Enumerable.Range(0, _totalCount).GroupBy(i => nodeindex[i % _nodeCount])
                    .ToImmutableDictionary(x => x.Key, x => (IEnumerable <int>)x.ToArray());
        }
Exemple #15
0
        public ReplicatorSpecConfig()
        {
            First  = Role("first");
            Second = Role("second");
            Third  = Role("third");

            CommonConfig = ConfigurationFactory.ParseString(@"
                akka.actor.provider = cluster
                akka.loglevel = DEBUG
                akka.log-dead-letters-during-shutdown = on
            ").WithFallback(DistributedData.DefaultConfig());

            TestTransport = true;
        }
        public DurablePruningSpecConfig()
        {
            First  = Role("first");
            Second = Role("second");

            CommonConfig = DebugConfig(on: false).WithFallback(ConfigurationFactory.ParseString(@"
            akka.loglevel = INFO
            akka.actor.provider = ""cluster""
            akka.log-dead-letters-during-shutdown = off
            akka.cluster.distributed-data.durable.keys = [""*""]
            akka.cluster.distributed-data.durable.lmdb {
              dir = ""target/DurablePruningSpec-" + DateTime.UtcNow.Ticks + @"-ddata""
              map-size = 10 MiB
            }")).WithFallback(DistributedData.DefaultConfig());
        }
        public ReplicatorPruningSpecConfig()
        {
            First  = Role("first");
            Second = Role("second");
            Third  = Role("third");

            CommonConfig = ConfigurationFactory.ParseString(@"
                akka.loglevel = DEBUG
                akka.actor.provider = cluster
                # we use 3s as write timeouts in test, make sure we see that
                # and not time out the expectMsg at the same time
                akka.test.single-expect-default = 5s
                akka.log-dead-letters-during-shutdown = off")
                           .WithFallback(DistributedData.DefaultConfig());
        }
        public ReplicatorChaosSpecConfig()
        {
            First  = Role("first");
            Second = Role("second");
            Third  = Role("third");
            Fourth = Role("fourth");
            Fifth  = Role("fifth");

            CommonConfig = ConfigurationFactory.ParseString(@"
                akka.loglevel = INFO
                akka.actor.provider = ""Akka.Cluster.ClusterActorRefProvider, Akka.Cluster""
                akka.cluster.roles = [""backend""]
                akka.log-dead-letters-during-shutdown = off")
                           .WithFallback(DistributedData.DefaultConfig());

            TestTransport = true;
        }
        public ActorDirectoryTestsConfig()
        {
            First  = Role("first");
            Second = Role("second");
            Third  = Role("third");

            CommonConfig =
                ConfigurationFactory.ParseString($@"
                    akka.actor.provider = ""Akka.Cluster.ClusterActorRefProvider, Akka.Cluster""
                    akka.loglevel = DEBUG
                    akka.log-dead-letters-during-shutdown = off
                    akka.test.timefactor = 1
                    akka.cluster.roles = [ {Hexagon.Constants.NodeRoleName} ]
                ")
                .WithFallback(MultiNodeClusterSpec.ClusterConfig())
                .WithFallback(DistributedData.DefaultConfig());
        }
        public XmlMessageSystemTestsConfig()
        {
            First  = Role("first");
            Second = Role("second");
            Third  = Role("third");

            CommonConfig =
                ConfigurationFactory
                .ParseString(@"
                    akka.loglevel = DEBUG
                    akka.test.timefactor = 1
                ")
                .WithFallback(MultiNodeClusterSpec.ClusterConfig())
                .WithFallback(DistributedData.DefaultConfig())
                .WithFallback(DistributedPubSub.DefaultConfig());

            //TestTransport = true;
        }
        public XmlMessageSystemWithRemoteDeployTestsConfig()
        {
            DeployTarget1 = Role("deployTarget1");
            DeployTarget2 = Role("deployTarget2");
            Deployer      = Role("deployer");

            CommonConfig =
                ConfigurationFactory
                .ParseString(@"
                    akka.loglevel = DEBUG
                    akka.test.timefactor = 1
                    akka.log-config-on-start = on
                    akka.cluster.roles = [ ""routeHere"" ]
                ")
                .WithFallback(MultiNodeClusterSpec.ClusterConfig())
                .WithFallback(DistributedData.DefaultConfig())
                .WithFallback(DistributedPubSub.DefaultConfig());
        }
Exemple #22
0
        public ReplicatorSpecConfig()
        {
            First  = Role("first");
            Second = Role("second");
            Third  = Role("third");

            CommonConfig = DebugConfig(true).WithFallback(ConfigurationFactory.ParseString(@"
                akka.actor.provider=""Akka.Cluster.ClusterActorRefProvider, Akka.Cluster""
                akka.test.timefactor=1.0
                akka.test.calling-thread-dispatcher.type=""Akka.TestKit.CallingThreadDispatcherConfigurator, Akka.TestKit""
                akka.test.calling-thread-dispatcher.throughput=2147483647
                akka.test.test-actor.dispatcher.type=""Akka.TestKit.CallingThreadDispatcherConfigurator, Akka.TestKit""
                akka.test.test-actor.dispatcher.throughput=2147483647
                akka.cluster.distributed-data.gossip-interval=2s
            ")).WithFallback(DistributedData.DefaultConfig());

            TestTransport = true;
        }
Exemple #23
0
        public async Task <IEnumerable <MatchingActor> > GetMatchingActorsAsync(M message, IMessagePatternFactory <P> messagePatternFactory)
        {
            var replicator        = DistributedData.Get(ActorSystem).Replicator;
            GetKeysIdsResult keys = await replicator.Ask <GetKeysIdsResult>(Dsl.GetKeyIds);

            var matchingActors = new List <MatchingActor>();

            foreach (var node in keys.Keys)
            {
                var setKey      = new LWWRegisterKey <ActorProps[]>(node);
                var getResponse = await replicator.Ask <IGetResponse>(Dsl.Get(setKey, ReadLocal.Instance));

                if (!getResponse.IsSuccessful)
                {
                    throw new Exception($"cannot get message patterns for node {node}");
                }
                var actorPropsList = getResponse.Get(setKey).Value;

                foreach (var actorProps in actorPropsList)
                {
                    var path                  = actorProps.Path;
                    var matchingPatterns      = actorProps.Patterns.Where(pattern => pattern.Match(message));
                    int matchingPatternsCount = matchingPatterns.Count();
                    if (matchingPatternsCount > 0)
                    {
                        var matchingPattern = matchingPatterns.First();
                        if (matchingPatternsCount > 1)
                        {
                            Logger.Warning("For actor {0}, found {1} patterns matching message {2}. Taking first one = {3}", path, matchingPatternsCount, message, matchingPattern);
                        }
                        matchingActors.Add(
                            new MatchingActor
                        {
                            Path           = path,
                            IsSecondary    = matchingPattern.IsSecondary,
                            MatchingScore  = matchingPattern.Conjuncts.Length,
                            MistrustFactor = actorProps.MistrustFactor
                        });
                    }
                }
            }
            return(matchingActors);
        }
Exemple #24
0
        public DurableDataSpecConfig(bool writeBehind)
        {
            First  = Role("first");
            Second = Role("second");

            var writeBehindInterval = writeBehind ? "200ms" : "off";

            CommonConfig = ConfigurationFactory.ParseString(@"
            akka.loglevel = INFO
            akka.actor.provider = ""Akka.Cluster.ClusterActorRefProvider, Akka.Cluster""
            akka.log-dead-letters-during-shutdown = off
            akka.cluster.distributed-data.durable.keys = [""durable*""]
            akka.cluster.distributed-data.durable.lmdb {
              dir = ""target/DurableDataSpec-" + DateTime.UtcNow.Ticks + @"-ddata""
              map-size = 10 MiB
              write-behind-interval = " + writeBehindInterval + @"
            }
            akka.test.single-expect-default = 5s").WithFallback(DistributedData.DefaultConfig());
        }
Exemple #25
0
        public JepsenInspiredInsertSpecConfig()
        {
            Controller = Role("controller");
            N1         = Role("n1");
            N2         = Role("n2");
            N3         = Role("n3");
            N4         = Role("n4");
            N5         = Role("n5");

            CommonConfig = ConfigurationFactory.ParseString(@"
                akka.loglevel = INFO
                akka.actor.provider = cluster
                akka.log-dead-letters = off
                akka.log-dead-letters-during-shutdown = off
                akka.remote.log-remote-lifecycle-events = ERROR
                akka.testconductor.barrier-timeout = 60s")
                           .WithFallback(DistributedData.DefaultConfig());

            TestTransport = true;
        }
Exemple #26
0
        public DurableDataPocoSpecConfig(bool writeBehind)
        {
            First  = Role("first");
            Second = Role("second");
            Third  = Role("third");

            var tempDir = Path.Combine(Path.GetTempPath(), "target", "DurableDataPocoSpec", $"Spec-{DateTime.UtcNow.Ticks}");

            CommonConfig = ConfigurationFactory.ParseString($@"
                akka.loglevel = INFO
                akka.log-config-on-start = off
                akka.actor.provider = ""Akka.Cluster.ClusterActorRefProvider, Akka.Cluster""
                akka.log-dead-letters-during-shutdown = off
                akka.cluster.distributed-data.durable.keys = [""durable*""]
                akka.cluster.distributed-data.durable.lmdb {{
                    map-size = 10 MiB
                    write-behind-interval = {(writeBehind ? "200ms" : "off")}
                }}
                akka.cluster.distributed-data.durable.store-actor-class = ""Akka.DistributedData.LightningDB.LmdbDurableStore, Akka.DistributedData.LightningDB""
                # initialization of lmdb can be very slow in CI environment
                akka.test.single-expect-default = 15s")
                           .WithFallback(DistributedData.DefaultConfig());

            NodeConfig(new[] { First }, new[] { ConfigurationFactory.ParseString($@"
                akka.cluster.distributed-data.durable.lmdb {{
                  dir = ""target/DurableDataPocoSpec/first-ddata""
                }}
            ") });

            NodeConfig(new[] { Second }, new[] { ConfigurationFactory.ParseString($@"
                akka.cluster.distributed-data.durable.lmdb {{
                  dir = ""target/DurableDataPocoSpec/second-ddata""
                }}
            ") });

            NodeConfig(new[] { Third }, new[] { ConfigurationFactory.ParseString($@"
                akka.cluster.distributed-data.durable.lmdb {{
                  dir = ""target/DurableDataPocoSpec/third-ddata""
                }}
            ") });
        }
Exemple #27
0
        /// <summary>
        /// the HOCON is set to DEBUG logs, to show the behaviour of DData with this small dataset. If you set to WARNING, you can use key commands m, c and i to just mimic how I interact with ddata.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            var finalConfig = ConfigurationFactory.Empty.FromEnvironment();

            var cfg = finalConfig.WithFallback(ConfigurationFactory.ParseString(File.ReadAllText("HOCON")))
                      .BootstrapFromDocker()
                      .WithFallback(DistributedData.DefaultConfig());

            Task.Run(() =>
            {
                Sys1         = ActorSystem.Create("test", cfg);
                var cluster1 = Cluster.Get(Sys1);
                cluster1.Join(Address.Parse($"akka.tcp://test@{cluster1.SelfAddress.Host}:18001"));
                cluster1.RegisterOnMemberUp(() => StartActors(Sys1));
            });


            char command = Char.MinValue;

            while (!command.Equals('q'))
            {
                command = Console.ReadKey().KeyChar;
                switch (command)
                {
                case 'm':
                    SendEventMessageToRegistry(Sys1);
                    break;

                case 'c':
                    SendCloseMessageToRegistry(Sys1);
                    break;

                case 'i':
                    QueryDDataThroughActor(Sys1);
                    break;
                }
            }
        }
        public void Pruning_of_durable_CRDT_should_move_data_from_removed_node()
        {
            Join(first, first);
            Join(second, first);

            var sys2             = ActorSystem.Create(Sys.Name, Sys.Settings.Config);
            var cluster2         = Akka.Cluster.Cluster.Get(sys2);
            var distributedData2 = DistributedData.Get(sys2);
            var replicator2      = StartReplicator(sys2);
            var probe2           = new TestProbe(sys2, new XunitAssertions());

            cluster2.Join(Node(first).Address);

            AwaitAssert(() =>
            {
                cluster.State.Members.Count.ShouldBe(4);
                cluster.State.Members.All(m => m.Status == MemberStatus.Up).ShouldBe(true);
                cluster2.State.Members.Count.ShouldBe(4);
                cluster2.State.Members.All(m => m.Status == MemberStatus.Up).ShouldBe(true);
            }, TimeSpan.FromSeconds(10));
            EnterBarrier("joined");

            Within(TimeSpan.FromSeconds(5), () => AwaitAssert(() =>
            {
                replicator.Tell(Dsl.GetReplicaCount);
                ExpectMsg(new ReplicaCount(4));
                replicator2.Tell(Dsl.GetReplicaCount, probe2.Ref);
                probe2.ExpectMsg(new ReplicaCount(4));
            }));

            replicator.Tell(Dsl.Update(keyA, GCounter.Empty, WriteLocal.Instance, c => c.Increment(cluster, 3)));
            ExpectMsg(new UpdateSuccess(keyA, null));

            replicator2.Tell(Dsl.Update(keyA, GCounter.Empty, WriteLocal.Instance, c => c.Increment(cluster2.SelfUniqueAddress, 2)), probe2.Ref);
            probe2.ExpectMsg(new UpdateSuccess(keyA, null));

            EnterBarrier("updates-done");

            Within(TimeSpan.FromSeconds(10), () => AwaitAssert(() =>
            {
                replicator.Tell(Dsl.Get(keyA, new ReadAll(TimeSpan.FromSeconds(1))));
                var counter1 = ExpectMsg <GetSuccess>().Get(keyA);
                counter1.Value.ShouldBe(10UL);
                counter1.State.Count.ShouldBe(4);
            }));

            Within(TimeSpan.FromSeconds(10), () => AwaitAssert(() =>
            {
                replicator2.Tell(Dsl.Get(keyA, new ReadAll(TimeSpan.FromSeconds(1))), probe2.Ref);
                var counter2 = probe2.ExpectMsg <GetSuccess>().Get(keyA);
                counter2.Value.ShouldBe(10UL);
                counter2.State.Count.ShouldBe(4);
            }));
            EnterBarrier("get1");

            RunOn(() => cluster.Leave(cluster2.SelfAddress), first);

            Within(TimeSpan.FromSeconds(15), () => AwaitAssert(() =>
            {
                replicator.Tell(Dsl.GetReplicaCount);
                ExpectMsg(new ReplicaCount(3));
            }));
            EnterBarrier("removed");

            RunOn(() => sys2.Terminate().Wait(TimeSpan.FromSeconds(5)), first);

            Within(TimeSpan.FromSeconds(15), () =>
            {
                var values = ImmutableHashSet <int> .Empty;
                AwaitAssert(() =>
                {
                    replicator.Tell(Dsl.Get(keyA, ReadLocal.Instance));
                    var counter3 = ExpectMsg <GetSuccess>().Get(keyA);
                    var value    = counter3.Value;
                    values       = values.Add((int)value);
                    value.ShouldBe(10UL);
                    counter3.State.Count.ShouldBe(3);
                });
                values.ShouldBe(ImmutableHashSet.Create(10));
            });
            EnterBarrier("prunned");

            RunOn(() =>
            {
                var address     = cluster2.SelfAddress;
                var sys3        = ActorSystem.Create(Sys.Name, ConfigurationFactory.ParseString($@"
                    akka.remote.dot-netty.tcp.port = {address.Port}
                ").WithFallback(Sys.Settings.Config));
                var cluster3    = Akka.Cluster.Cluster.Get(sys3);
                var replicator3 = StartReplicator(sys3);
                var probe3      = new TestProbe(sys3, new XunitAssertions());
                cluster3.Join(Node(first).Address);

                Within(TimeSpan.FromSeconds(10), () =>
                {
                    var values = ImmutableHashSet <int> .Empty;
                    AwaitAssert(() =>
                    {
                        replicator3.Tell(Dsl.Get(keyA, ReadLocal.Instance), probe3.Ref);
                        var counter4 = probe3.ExpectMsg <GetSuccess>().Get(keyA);
                        var value    = counter4.Value;
                        values       = values.Add((int)value);
                        value.ShouldBe(10UL);
                        counter4.State.Count.ShouldBe(3);
                    });
                    values.ShouldBe(ImmutableHashSet.Create(10));
                });

                // all must at least have seen it as joining
                AwaitAssert(() =>
                {
                    cluster3.State.Members.Count.ShouldBe(4);
                    cluster3.State.Members.All(m => m.Status == MemberStatus.Up).ShouldBeTrue();
                }, TimeSpan.FromSeconds(10));

                // after merging with others
                replicator3.Tell(Dsl.Get(keyA, new ReadAll(RemainingOrDefault)));
                var counter5 = ExpectMsg <GetSuccess>().Get(keyA);
                counter5.Value.ShouldBe(10UL);
                counter5.State.Count.ShouldBe(3);
            }, first);

            EnterBarrier("sys3-started");

            replicator.Tell(Dsl.Get(keyA, new ReadAll(RemainingOrDefault)));
            var counter6 = ExpectMsg <GetSuccess>().Get(keyA);

            counter6.Value.ShouldBe(10UL);
            counter6.State.Count.ShouldBe(3);

            EnterBarrier("after-1");
        }
Exemple #29
0
 public Listener()
 {
     var ddata = DistributedData.Get(Context.System);
 }