コード例 #1
0
ファイル: Replicator.cs プロジェクト: ziez/akka.net
        private void ReceiveDelete(IKey key, IWriteConsistency consistency)
        {
            var envelope = GetData(key.Id);

            if (envelope != null)
            {
                if (envelope.Data is DeletedData)
                {
                    Sender.Tell(new DataDeleted(key));
                }
                else
                {
                    SetData(key.Id, DeletedEnvelope);
                    if (IsLocalUpdate(consistency))
                    {
                        Sender.Tell(new DeleteSuccess(key));
                    }
                    else
                    {
                        Context.ActorOf(WriteAggregator.Props(key, DeletedEnvelope, consistency, null, _nodes, Sender)
                                        .WithDispatcher(Context.Props.Dispatcher));
                    }
                }
            }
        }
コード例 #2
0
ファイル: Replicator.cs プロジェクト: wj60387/akka.net
        private void ReceiveDelete(IKey key, IWriteConsistency consistency, object request)
        {
            var envelope = GetData(key.Id);

            if (envelope != null)
            {
                if (envelope.Data is DeletedData)
                {
                    Sender.Tell(new DataDeleted(key, request));
                }
                else
                {
                    SetData(key.Id, DeletedEnvelope);
                    var durable = IsDurable(key.Id);
                    if (IsLocalUpdate(consistency))
                    {
                        if (durable)
                        {
                            var reply = new StoreReply(
                                successMessage: new DeleteSuccess(key, request),
                                failureMessage: new StoreFailure(key, request),
                                replyTo: Sender);
                            _durableStore.Tell(new Store(key.Id, new DurableDataEnvelope(DeletedEnvelope), reply));
                        }
                        Sender.Tell(new DeleteSuccess(key, request));
                    }
                    else
                    {
                        var writeAggregator = Context.ActorOf(WriteAggregator.Props(key, DeletedEnvelope, consistency, null, _nodes, _unreachable, Sender, durable)
                                                              .WithDispatcher(Context.Props.Dispatcher));

                        if (durable)
                        {
                            var reply = new StoreReply(
                                successMessage: new DeleteSuccess(key, request),
                                failureMessage: new StoreFailure(key, request),
                                replyTo: writeAggregator);
                            _durableStore.Tell(new Store(key.Id, new DurableDataEnvelope(DeletedEnvelope), reply));
                        }
                    }
                }
            }
        }
コード例 #3
0
ファイル: Replicator.cs プロジェクト: ziez/akka.net
        private void ReceiveUpdate(IKey key, Func <IReplicatedData, IReplicatedData> modify, IWriteConsistency consistency, object request)
        {
            try
            {
                var             localValue = GetData(key.Id);
                IReplicatedData modifiedValue;
                if (localValue == null)
                {
                    modifiedValue = modify(null);
                }
                else if (localValue.Data is DeletedData)
                {
                    _log.Debug("Received update for deleted key {0}", key);
                    Sender.Tell(new DataDeleted(key));
                    return;
                }
                else
                {
                    var existing = localValue.Data;
                    modifiedValue = existing.Merge(modify(existing));
                }

                _log.Debug("Received Update for key {0}, old data {1}, new data {2}", key, localValue, modifiedValue);
                var envelope = new DataEnvelope(PruningCleanupTombstoned(modifiedValue));
                SetData(key.Id, envelope);
                if (IsLocalUpdate(consistency))
                {
                    Sender.Tell(new UpdateSuccess(key, request));
                }
                else
                {
                    Context.ActorOf(WriteAggregator.Props(key, envelope, consistency, request, _nodes, Sender).WithDispatcher(Context.Props.Dispatcher));
                }
            }
            catch (Exception ex)
            {
                _log.Debug("Received update for key {0}, failed {1}", key, ex.Message);
                Sender.Tell(new ModifyFailure(key, "Update failed: " + ex.Message, ex, request));
            }
        }