コード例 #1
0
        public void RemoveReplica(ReplicaId id)
        {
            var desc = replicas[id];

            replicas.Remove(id);
            ReplicaRemoved?.Invoke(desc);
        }
コード例 #2
0
        public void UpdateReplica(ReplicaId id, ByteString replica)
        {
            var desc = replicas[id];

            desc.Value.MergeFrom(replica);
            ReplicaUpdated?.Invoke(desc);
        }
コード例 #3
0
        internal void AddReplica(ReplicaId id, IMessage replica, ReplicaOptions options)
        {
            var desc = new Replica(id, replica, options);

            replicas.Add(desc.Id, desc);
            ReplicaAdded?.Invoke(desc);
        }
コード例 #4
0
        public void AddStaticReplica(ReplicaId id, IMessage replica, StaticReplicaOptions options)
        {
            if (id < 0 || StaticIdCount <= id)
            {
                throw new ArgumentException($"{nameof(id)} must be in range [0,{StaticIdCount}[");
            }

            ReplicaOptions replicaOptions = (ReplicaOptions)options;

            AddReplica(id, replica, replicaOptions);
        }
コード例 #5
0
        public ReplicaId AddDynamicReplica(IMessage replica, DynamicReplicaOptions options = DynamicReplicaOptions.DefaultMaster)
        {
            ReplicaOptions replicaOptions = (ReplicaOptions)options;

            replicaOptions |= ReplicaOptions.AddOrRemove;
            replicaOptions |= ReplicaOptions.Master;

            ReplicaId id = GetNextDynamicId();

            AddReplica(id, replica, replicaOptions);
            return(id);
        }
コード例 #6
0
ファイル: Replica.cs プロジェクト: Revell0/Replication
 internal Replica(ReplicaId id, IMessage value, ReplicaOptions options)
 {
     Id      = id;
     Value   = value;
     Options = options;
 }
コード例 #7
0
 public Replica GetReplica(ReplicaId replicaId)
 {
     return(replicas[replicaId]);
 }
コード例 #8
0
        public void UpdateReplica(ReplicaId id)
        {
            var desc = replicas[id];

            ReplicaUpdated?.Invoke(desc);
        }
コード例 #9
0
 public void UpdateReplica(ReplicaId id, IMessage replica)
 {
     UpdateReplica(id, replica.ToByteString());
 }
コード例 #10
0
 public T GetReplica <T>(ReplicaId replicaId) where T : IMessage
 {
     return((T)(GetReplica(replicaId).Value));
 }