/// <summary> /// Resolves the actor reference. /// </summary> /// <param name="actorPath">The actor path.</param> /// <returns>ActorRef.</returns> /// <exception cref="System.NotSupportedException">The provided actor path is not valid in the LocalActorRefProvider</exception> public override ActorRef ResolveActorRef(ActorPath actorPath) { if (Address.Equals(actorPath.Address)) { if (actorPath.Elements.Head() == "temp") { //skip ""/"temp", string[] parts = actorPath.Elements.Drop(1).ToArray(); return(TempContainer.GetChild(parts)); } //standard ActorCell currentContext = RootCell; foreach (string part in actorPath.Elements) { currentContext = ((LocalActorRef)currentContext.Child(part)).Cell; } return(currentContext.Self); } throw new NotSupportedException("The provided actor path is not valid in the LocalActorRefProvider"); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <param name="other"> An object to compare with this object. </param> /// <returns> true if the current object is equal to the <paramref name="other" /> parameter; otherwise, false. </returns> public bool Equals(ActorPath other) { return(Address.Equals(other.Address) && Elements.SequenceEqual(other.Elements)); }
// Try to join this cluster node with the node specified by `address`. // It's only allowed to join from an empty state, i.e. when not already a member. // A `Join(selfUniqueAddress)` command is sent to the node to join, // which will reply with a `Welcome` message. public void Join(Address address) { if (address.Protocol != _cluster.SelfAddress.Protocol) { _log.Warning("Trying to join member with wrong protocol, but was ignored, expected [{0}] but was [{1}]", _cluster.SelfAddress.Protocol, address.Protocol); } else if (address.System != _cluster.SelfAddress.System) { _log.Warning( "Trying to join member with wrong ActorSystem name, but was ignored, expected [{0}] but was [{1}]", _cluster.SelfAddress.System, address.System); } else { //TODO: Akka exception? if (!_latestGossip.Members.IsEmpty) throw new InvalidOperationException("Join can only be done from an empty state"); // to support manual join when joining to seed nodes is stuck (no seed nodes available) StopSeedNodeProcess(); if (address.Equals(_cluster.SelfAddress)) { BecomeInitialized(); Joining(SelfUniqueAddress, _cluster.SelfRoles); } else { var joinDeadline = _cluster.Settings.RetryUnsuccessfulJoinAfter == null ? null : Deadline.Now + _cluster.Settings.RetryUnsuccessfulJoinAfter; Context.Become(m => TryingToJoin(m, address, joinDeadline)); ClusterCore(address).Tell(new InternalClusterAction.Join(_cluster.SelfUniqueAddress, _cluster.SelfRoles)); } } }
//Reply from Join request public void Welcome(Address joinWith, UniqueAddress from, Gossip gossip) { if (!_latestGossip.Members.IsEmpty) throw new InvalidOperationException("Welcome can only be done from an empty state"); if (!joinWith.Equals(from.Address)) { _log.Info("Ignoring welcome from [{0}] when trying to join with [{1}]", from.Address, joinWith); } else { _log.Info("Welcome from [{0}]", from.Address); _latestGossip = gossip.Seen(SelfUniqueAddress); Publish(_latestGossip); if (!from.Equals(SelfUniqueAddress)) GossipTo(from, Sender); BecomeInitialized(); } }
public override Address GetExternalAddressFor(Address address) { return address.Equals(RootPath.Address) ? address : null; }
public override Address GetExternalAddressFor(Address address) { return(address.Equals(RootPath.Address) ? address : null); }