Example #1
0
        /// <summary>
        /// Adds an entry to the map.
        /// Note that the new <paramref name="value"/> will be merged with existing values
        /// on other nodes and the outcome depends on what <see cref="IReplicatedData"/>
        /// type that is used.
        ///
        /// Consider using <see cref="AddOrUpdate(Akka.Cluster.Cluster, TKey, TValue, Func{TValue, TValue})">AddOrUpdate</see> instead of <see cref="SetItem(UniqueAddress,TKey,TValue)"/> if you want modify
        /// existing entry.
        ///
        /// <see cref="ArgumentException"/> is thrown if you try to replace an existing <see cref="ORSet{T}"/>
        /// value, because important history can be lost when replacing the `ORSet` and
        /// undesired effects of merging will occur. Use <see cref="ORMultiValueDictionary{TKey,TValue}"/> or <see cref="AddOrUpdate(Akka.Cluster.Cluster, TKey, TValue, Func{TValue, TValue})">AddOrUpdate</see> instead.
        /// </summary>
        public ORDictionary <TKey, TValue> SetItem(UniqueAddress node, TKey key, TValue value)
        {
            if (value is IORSet && ValueMap.ContainsKey(key))
            {
                throw new ArgumentException("ORDictionary.SetItems may not be used to replace an existing ORSet", nameof(value));
            }

            var newKeys = KeySet.ResetDelta().Add(node, key);
            var delta   = new PutDeltaOperation(newKeys.Delta, key, value);

            // put forcibly damages history, so we propagate full value that will overwrite previous values
            return(new ORDictionary <TKey, TValue>(newKeys, ValueMap.SetItem(key, value), NewDelta(delta)));
        }
Example #2
0
        public WriteAggregatorSpec(ITestOutputHelper output) : base(ConfigurationFactory.ParseString($@"
            akka.actor.provider = ""Akka.Cluster.ClusterActorRefProvider, Akka.Cluster""
            akka.remote.dot-netty.tcp.port = 0
            akka.cluster.distributed-data.durable.lmdb {{
                dir = ""target/WriteAggregatorSpec-{DateTime.UtcNow.Ticks}-ddata""
                map-size = 10MiB
            }}"), "WriteAggregatorSpec", output)
        {
            _nodes = ImmutableList.CreateRange(new[] { _nodeA, _nodeB, _nodeC, _nodeD });

            var cluster = Akka.Cluster.Cluster.Get(Sys);

            _fullState1 = ORSet <string> .Empty.Add(cluster, "a").Add(cluster, "b");

            _fullState2 = _fullState1.ResetDelta().Add(cluster, "c");
            _delta      = new Delta(new DataEnvelope(_fullState2.Delta), 2L, 2L);
            _writeAll   = new WriteAll(Dilated(TimeSpan.FromSeconds(3)));
        }