public bool TryGetByRef(ActorRef actor, out ChildRestartStats childRestartStats)
 {
     ChildStats stats;
     if (InternalChildren.TryGet(actor.Path.Name, out stats))
     {
         //Since the actor exists, ChildRestartStats is the only valid ChildStats.
         var crStats = stats as ChildRestartStats;
         if (crStats != null && actor.Equals(crStats.Child))
         {
             childRestartStats = crStats;
             return true;
         }
     }
     childRestartStats = null;
     return false;
 }
 /// <summary>
 ///     This is the main entry point: in case of a child’s failure, this method
 ///     must try to handle the failure by resuming, restarting or stopping the
 ///     child (and returning `true`), or it returns `false` to escalate the
 ///     failure, which will lead to this actor re-throwing the exception which
 ///     caused the failure. The exception will not be wrapped.
 ///     This method calls <see cref="Akka.Actor.SupervisorStrategy"/>, which will
 ///     log the failure unless it is escalated. You can customize the logging by
 ///     setting <see cref="Akka.Actor.SupervisorStrategy" /> to `false` and
 ///     do the logging inside the `decider` or override the `LogFailure` method.
 /// </summary>
 /// <param name="actorCell">The actor cell.</param>
 /// <param name="cause">The cause.</param>
 /// <param name="failedChildStats">The stats for the failed child.</param>
 /// <param name="allChildren"></param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
 public bool HandleFailure(ActorCell actorCell, Exception cause, ChildRestartStats failedChildStats, IReadOnlyCollection<ChildRestartStats> allChildren)
 {
     var child = failedChildStats.Child;
     var directive = Handle(child, cause);
     switch (directive)
     {
         case Directive.Escalate:
             LogFailure(actorCell, child, cause, directive);
             return false;
         case Directive.Resume:
             LogFailure(actorCell, child, cause, directive);
             ResumeChild(child, cause);
             return true;
         case Directive.Restart:
             LogFailure(actorCell, child, cause, directive);
             ProcessFailure(actorCell, true, cause, failedChildStats, allChildren);
             return true;
         case Directive.Stop:
             LogFailure(actorCell, child, cause, directive);
             ProcessFailure(actorCell, false, cause, failedChildStats, allChildren);
             return true;
     }
     return false;
 }
 public bool TryGetByRef(IActorRef actor, out ChildRestartStats childRestartStats)
 {
     childRestartStats = null;
     return false;
 }
 public virtual IChildrenContainer Add(string name, ChildRestartStats stats)
 {
     var newMap = _emptyStats.Add(name, stats);
     return NormalChildrenContainer.Create(newMap);
 }
Esempio n. 5
0
 protected override void ProcessFailure(IActorContext context, bool restart, Exception cause, ChildRestartStats failedChildStats, IReadOnlyCollection<ChildRestartStats> allChildren)
 {
     var child = failedChildStats.Child;
     TestActor.Tell(new FF(new Failed(child, cause, failedChildStats.Uid)), child);
     base.ProcessFailure(context, restart, cause, failedChildStats, allChildren);
 }
 public abstract ChildrenContainer Add(string name, ChildRestartStats stats);
 public override IChildrenContainer Add(string name, ChildRestartStats stats)
 {
     return this;
 }
 public override IChildrenContainer Add(string name, ChildRestartStats stats)
 {
     var newMap = InternalChildren.AddOrUpdate(name, stats);
     return new TerminatingChildrenContainer(newMap, _toDie, _reason);
 }
        protected override void ProcessFailure(IActorContext context, bool restart, Exception cause, ChildRestartStats failedChildStats, IReadOnlyCollection<ChildRestartStats> allChildren)
        {
            if (allChildren.Count > 0)
            {
                var failedChild = failedChildStats.Child;

                if (restart && allChildren.All(c => c.RequestRestartPermission(_maxNumberOfRetries, _withinTimeRangeMilliseconds)))
                {
                    foreach (var crs in allChildren)
                    {
                        RestartChild(crs.Child, cause, suspendFirst: !failedChild.Equals(crs.Child));
                    }
                }
                else
                {
                    foreach (var crs in allChildren)
                    {
                        context.Stop(crs.Child);
                    }
                }
            }
        }
Esempio n. 10
0
        protected override void ProcessFailure(IActorContext context, bool restart, Exception cause, ChildRestartStats failedChildStats, IReadOnlyCollection<ChildRestartStats> allChildren)
        {
            var failedChild = failedChildStats.Child;

            if (restart && failedChildStats.RequestRestartPermission(_maxNumberOfRetries, _withinTimeRangeMilliseconds))
                RestartChild(failedChild, cause, suspendFirst: false);
            else
                context.Stop(failedChild);
        }
Esempio n. 11
0
 /// <summary>
 /// This method is called to act on the failure of a child: restart if the flag is true, stop otherwise.
 /// </summary>
 /// <param name="context">The actor context.</param>
 /// <param name="restart">if set to <c>true</c> restart, stop otherwise.</param>
 /// <param name="cause">The exception that caused the child to fail.</param>
 /// <param name="failedChildStats">The stats for the child that failed. The ActorRef to the child can be obtained via the <see cref="ChildRestartStats.Child"/> property</param>
 /// <param name="allChildren">The stats for all children</param>
 protected abstract void ProcessFailure(IActorContext context, bool restart, Exception cause, ChildRestartStats failedChildStats, IReadOnlyCollection<ChildRestartStats> allChildren);
Esempio n. 12
0
 public override IChildrenContainer Add(string name, ChildRestartStats stats)
 {
     return Create(InternalChildren.SetItem(name, stats));
 }
Esempio n. 13
0
 protected override void ProcessFailure(IActorContext context, bool restart, IActorRef child, Exception cause, ChildRestartStats stats, IReadOnlyCollection<ChildRestartStats> children)
 {
     TestActor.Tell(new FF(new Failed(child, cause, stats.Uid)), child);
     base.ProcessFailure(context, restart, child, cause, stats, children);
 }
 public override ChildrenContainer Add(string name, ChildRestartStats stats)
 {
     return Create(InternalChildren.AddOrUpdate(name, stats));
 }