-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
maxim.salamatko
committed
Oct 9, 2015
1 parent
a36dadd
commit 44c29cc
Showing
6 changed files
with
90 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Akka.Actor; | ||
using Akka.Dispatch; | ||
using Akka.Dispatch.SysMsg; | ||
using Akka.Util.Internal.Collections; | ||
|
||
namespace Akka.Remote | ||
{ | ||
/// <summary> | ||
/// Responsible for cleaning up child references of remote deployed actors when remote node | ||
/// goes down (crash, network failure), i.e. triggered by Akka.Actor.Terminated.AddressTerminated | ||
/// </summary> | ||
internal class RemoteDeploymentWatcher : ActorBase, IRequiresMessageQueue<IUnboundedMessageQueueSemantics> | ||
{ | ||
|
||
private readonly IImmutableMap<IActorRef, IInternalActorRef> _supervisors = | ||
ImmutableTreeMap<IActorRef, IInternalActorRef>.Empty; | ||
protected override bool Receive(object message) | ||
{ | ||
if (message == null) | ||
{ | ||
return false; | ||
} | ||
return message.Match().With<WatchRemote>(w => | ||
{ | ||
_supervisors.Add(w.Actor, w.Supervisor); | ||
Context.Watch(w.Actor); | ||
}).With<Terminated>(t => | ||
{ | ||
IInternalActorRef supervisor; | ||
if (_supervisors.TryGet(t.ActorRef, out supervisor)) | ||
{ | ||
supervisor.SendSystemMessage(new DeathWatchNotification(t.ActorRef, t.ExistenceConfirmed, t.AddressTerminated), supervisor); | ||
_supervisors.Remove(t.ActorRef); | ||
} | ||
}).WasHandled; | ||
} | ||
|
||
internal class WatchRemote | ||
{ | ||
public WatchRemote(IActorRef actor, IInternalActorRef supervisor) | ||
{ | ||
Actor = actor; | ||
Supervisor = supervisor; | ||
} | ||
|
||
public IActorRef Actor { get; private set; } | ||
public IInternalActorRef Supervisor { get; private set; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters