コード例 #1
0
ファイル: VersionedObject.cs プロジェクト: fallin/Wildling
        public static VersionedObject FromJson(JToken token)
        {
            JToken value            = token["value"];
            DottedVersionVector dvv = DottedVersionVector.FromJson(token["clock"]);

            return(new VersionedObject(value, dvv));
        }
コード例 #2
0
ファイル: VersionedObject.cs プロジェクト: fallin/Wildling
        public VersionedObject(JToken value, DottedVersionVector clock)
        {
            Ensure.That(value, "value").IsNotNull();
            Ensure.That(clock, "clock").IsNotNull();

            Value = value;
            Clock = clock;
        }
コード例 #3
0
        internal async Task PutAsync(string key, JToken value, VersionVector context = null)
        {
            Ensure.That(key, "key").IsNotNullOrWhiteSpace();

            context = context ?? new VersionVector();

            string coordinatingNode = _ring.Node(key);

            if (_ring.PreferenceList(key, N).Contains(_name))
            {
                Log.DebugFormat("put k={0}", key);

                BigInteger hash     = _ring.Hash(key);
                Siblings   siblings = _data.GetValueOrDefault(hash);
                if (siblings != null)
                {
                    // discard obsolete versions
                    siblings = _kernel.Discard(siblings, context);
                }
                else
                {
                    siblings = new Siblings();
                }

                DottedVersionVector dvv = _kernel.Event(context, siblings, _name);
                var versionedObject     = new VersionedObject(value, dvv);

                siblings.Add(versionedObject);

                _data[hash] = siblings;

                await ReplicatePutAsync(key, siblings);
            }
            else
            {
                Log.DebugFormat("forward to coordinating node {0}", coordinatingNode);
                await _remote.PutAsync(coordinatingNode, key, value, context);
            }
        }
コード例 #4
0
ファイル: Siblings.cs プロジェクト: fallin/Wildling
 public void Add(JToken value, string version)
 {
     Add(value, DottedVersionVector.Parse(version));
 }
コード例 #5
0
ファイル: Siblings.cs プロジェクト: fallin/Wildling
 public void Add(JToken value, DottedVersionVector clock)
 {
     Add(new VersionedObject(value, clock));
 }