Exemple #1
0
        public void RemoveReplica(ReplicaId id)
        {
            var desc = replicas[id];

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

            desc.Value.MergeFrom(replica);
            ReplicaUpdated?.Invoke(desc);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #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);
        }
Exemple #6
0
 internal Replica(ReplicaId id, IMessage value, ReplicaOptions options)
 {
     Id      = id;
     Value   = value;
     Options = options;
 }
Exemple #7
0
 public Replica GetReplica(ReplicaId replicaId)
 {
     return(replicas[replicaId]);
 }
Exemple #8
0
        public void UpdateReplica(ReplicaId id)
        {
            var desc = replicas[id];

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