コード例 #1
0
        // Failure -------------------------------------------------------------------------------------


        protected virtual bool EscalateError(Exception exception, IEnumerable <ActorRef> childrenNotToSuspend = null)        //virtual so we can override it to be able to write tests
        {
            if (!IsFailed)
            {
                try
                {
                    SuspendThisOnly();
                    var childrenToSkip = childrenNotToSuspend == null ? new HashSet <ActorRef>() : new HashSet <ActorRef>(childrenNotToSuspend);
                    var currentMessage = CurrentMessage;
                    var wasHandled     =
                        (currentMessage != null && PatternMatcher.Match <ActorFailed>(currentMessage.Message, m =>
                    {
                        SetFailedPerpatrator(m.Child);
                        childrenToSkip.Add(m.Child);
                    })) ||
                        PatternMatcher.MatchAll(() => SetFailedPerpatrator(this));

                    SuspendChildren(childrenToSkip);
                    _supervisor.SendSystemMessage(new ActorFailed(this, exception, InstanceId), this);
                }
                catch (Exception e)
                {
                    Publish(new ErrorLogEvent(_path.ToString(), SafeGetTypeForLogging(), "Emergency stop: exception in failure handling for " + exception, e));
                    try
                    {
                        Children.GetChildrenRefs().ForEach(c => c.Stop());
                    }
                    finally
                    {
                        //TODO: FinishTerminate()
                    }
                }
            }
            return(true);
        }
コード例 #2
0
 public override void SendSystemMessage(SystemMessage message, ActorRef sender)
 {
     var ignored = PatternMatcher.Match <SuperviseActor>(message, _ => { }) ||
                   PatternMatcher.MatchAll(message, _ =>
     {
         //TODO: Log "Recevied unexpected system message of type {0}: {1}", message.GetType(), message
     });
 }
コード例 #3
0
 private static bool IfMatchSysCause <T>(SystemMessage message, Action <Exception> handler) where T : ExceptionSystemMessage
 {
     return(PatternMatcher.Match <T>(message, m => handler(m.CausedByFailure)));
 }
コード例 #4
0
 private static bool IfMatchSys <T>(SystemMessage message, Action <T> handler) where T : class, SystemMessage
 {
     return(PatternMatcher.Match(message, handler));
 }