예제 #1
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="RemoteSystemDaemon" /> class.
 /// </summary>
 /// <param name="system">The system.</param>
 /// <param name="path">The path.</param>
 /// <param name="parent">The parent.</param>
 /// <param name="terminator"></param>
 /// <param name="log"></param>
 public RemoteSystemDaemon(ActorSystemImpl system, ActorPath path, IInternalActorRef parent, IActorRef terminator, ILoggingAdapter log)
     : base(system.Provider, path, parent, log)
 {
     _terminator = terminator;
     _system     = system;
     AddressTerminatedTopic.Get(system).Subscribe(this);
 }
예제 #2
0
        protected override SupervisorStrategy SupervisorStrategy()
        {
            return(new OneForOneStrategy(ex =>
            {
                var directive = Directive.Stop;

                ex.Match()
                .With <InvalidAssociation>(ia =>
                {
                    log.Warning("Tried to associate with unreachable remote address [{0}]. " +
                                "Address is now gated for {1} ms, all messages to this address will be delivered to dead letters. Reason: [{2}]",
                                ia.RemoteAddress, settings.RetryGateClosedFor.TotalMilliseconds, ia.Message);
                    endpoints.MarkAsFailed(Sender, Deadline.Now + settings.RetryGateClosedFor);
                    AddressTerminatedTopic.Get(Context.System).Publish(new AddressTerminated(ia.RemoteAddress));
                    directive = Directive.Stop;
                })
                .With <ShutDownAssociation>(shutdown =>
                {
                    log.Debug("Remote system with address [{0}] has shut down. " +
                              "Address is not gated for {1}ms, all messages to this address will be delivered to dead letters.",
                              shutdown.RemoteAddress, settings.RetryGateClosedFor.TotalMilliseconds);
                    endpoints.MarkAsFailed(Sender, Deadline.Now + settings.RetryGateClosedFor);
                    AddressTerminatedTopic.Get(Context.System).Publish(new AddressTerminated(shutdown.RemoteAddress));
                    directive = Directive.Stop;
                })
                .With <HopelessAssociation>(hopeless =>
                {
                    if (settings.QuarantineDuration.HasValue && hopeless.Uid.HasValue)
                    {
                        endpoints.MarkAsQuarantined(hopeless.RemoteAddress, hopeless.Uid.Value,
                                                    Deadline.Now + settings.QuarantineDuration.Value);
                        eventPublisher.NotifyListeners(new QuarantinedEvent(hopeless.RemoteAddress,
                                                                            hopeless.Uid.Value));
                    }
                    else
                    {
                        log.Warning("Association to [{0}] with unknown UID is irrecoverably failed. " +
                                    "Address cannot be quarantined without knowing the UID, gating instead for {1} ms.",
                                    hopeless.RemoteAddress, settings.RetryGateClosedFor.TotalMilliseconds);
                        endpoints.MarkAsFailed(Sender, Deadline.Now + settings.RetryGateClosedFor);
                    }
                    AddressTerminatedTopic.Get(Context.System).Publish(new AddressTerminated(hopeless.RemoteAddress));
                    directive = Directive.Stop;
                })
                .Default(msg =>
                {
                    if (msg is EndpointDisassociatedException || msg is EndpointAssociationException)
                    {
                    }                                                                                         //no logging
                    else
                    {
                        log.Error(ex, ex.Message);
                    }
                });

                return directive;
            }));
        }
예제 #3
0
 protected virtual void PublishAddressTerminated(Address address)
 {
     AddressTerminatedTopic.Get(Context.System).Publish(new AddressTerminated(address));
 }
 private void SubscribeAddressTerminated()
 {
     AddressTerminatedTopic.Get(System).Subscribe(Self);
 }