Class RemoteActorRef.
Inheritance: Akka.Actor.InternalActorRef, RemoteRef
コード例 #1
0
        public void UseActorOnNode(RemoteActorRef actor, Props props, Deploy deploy, IInternalActorRef supervisor)
        {
            _log.Debug("[{0}] Instantiating Remote Actor [{1}]", RootPath, actor.Path);
            IActorRef remoteNode = ResolveActorRef(new RootActorPath(actor.Path.Address) / "remote");

            remoteNode.Tell(new DaemonMsgCreate(props, deploy, actor.Path.ToSerializationFormat(), supervisor));
        }
コード例 #2
0
 public Send(object message, RemoteActorRef recipient, ActorRef senderOption = null, SeqNo seqOpt = null)
 {
     Recipient    = recipient;
     SenderOption = senderOption;
     Message      = message;
     _seq         = seqOpt;
 }
コード例 #3
0
ファイル: Remoting.cs プロジェクト: yildizoglu/akka.net
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="message">TBD</param>
        /// <param name="sender">TBD</param>
        /// <param name="recipient">TBD</param>
        /// <exception cref="RemoteTransportException">TBD</exception>
        public override void Send(object message, IActorRef sender, RemoteActorRef recipient)
        {
            if (_endpointManager == null)
            {
                throw new RemoteTransportException("Attempted to send remote message but Remoting is not running.", null);
            }

            _endpointManager.Tell(new EndpointManager.Send(message, recipient, sender), sender ?? ActorRefs.NoSender);
        }
コード例 #4
0
ファイル: Remoting.cs プロジェクト: Badmoonz/akka.net
        public override void Send(object message, ActorRef sender, RemoteActorRef recipient)
        {
            if (EndpointManager == null)
            {
                throw new RemotingException("Attempted to send remote message but Remoting is not running.", null);
            }
            if (sender == null)
                sender = ActorRef.NoSender;

            EndpointManager.Tell(new Send(message, sender, recipient), sender);
        }
コード例 #5
0
        public void UseActorOnNode(RemoteActorRef actor, Props props, Deploy deploy, IInternalActorRef supervisor)
        {
            Akka.Serialization.Serialization.CurrentTransportInformation = new Information
            {
                System  = _system,
                Address = actor.LocalAddressToUse,
            };
            _log.Debug("[{0}] Instantiating Remote Actor [{1}]", RootPath, actor.Path);
            IActorRef remoteNode = ResolveActorRef(new RootActorPath(actor.Path.Address) / "remote");

            remoteNode.Tell(new DaemonMsgCreate(props, deploy, actor.Path.ToSerializationFormat(), supervisor));
        }
コード例 #6
0
        private IInternalActorRef RemoteActorOf(ActorSystemImpl system, Props props, IInternalActorRef supervisor,
                                                ActorPath path)
        {
            var scope = (RemoteScope)props.Deploy.Scope;
            var d     = props.Deploy;
            var addr  = scope.Address;

            var localAddress = Transport.LocalAddressForRemote(addr);

            var rpath = (new RootActorPath(addr) / "remote" / localAddress.Protocol / localAddress.HostPort() /
                         path.Elements.ToArray()).
                        WithUid(path.Uid);
            var remoteRef = new RemoteActorRef(Transport, localAddress, rpath, supervisor, props, d);

            remoteRef.Start();
            return(remoteRef);
        }
コード例 #7
0
 public Send(object message, RemoteActorRef recipient, IActorRef senderOption = null, SeqNo seqOpt = null)
 {
     Recipient = recipient;
     SenderOption = senderOption;
     Message = message;
     _seq = seqOpt;
 }
コード例 #8
0
 /// <summary>
 /// Sends the given message to the recipient, supplying <paramref name="sender"/> if any.
 /// </summary>
 /// <param name="message">TBD</param>
 /// <param name="sender">TBD</param>
 /// <param name="recipient">TBD</param>
 public abstract void Send(object message, IActorRef sender, RemoteActorRef recipient);
コード例 #9
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="system">TBD</param>
        /// <param name="props">TBD</param>
        /// <param name="supervisor">TBD</param>
        /// <param name="path">TBD</param>
        /// <param name="systemService">TBD</param>
        /// <param name="deploy">TBD</param>
        /// <param name="lookupDeploy">TBD</param>
        /// <param name="async">TBD</param>
        /// <exception cref="ActorInitializationException">
        /// This exception is thrown when the remote deployment to the specified <paramref name="path"/> fails.
        /// </exception>
        /// <exception cref="ConfigurationException">
        /// This exception is thrown when either the scope of the deployment is local
        /// or the specified <paramref name="props"/> is invalid for deployment to the specified <paramref name="path"/>.
        /// </exception>
        /// <returns>TBD</returns>
        public IInternalActorRef ActorOf(ActorSystemImpl system, Props props, IInternalActorRef supervisor, ActorPath path, bool systemService, Deploy deploy, bool lookupDeploy, bool async)
        {
            if (systemService)
            {
                return(LocalActorOf(system, props, supervisor, path, true, deploy, lookupDeploy, async));
            }

            /*
             * This needs to deal with "mangled" paths, which are created by remote
             * deployment, also in this method. The scheme is the following:
             *
             * Whenever a remote deployment is found, create a path on that remote
             * address below "remote", including the current system’s identification
             * as "sys@host:port" (typically; it will use whatever the remote
             * transport uses). This means that on a path up an actor tree each node
             * change introduces one layer or "remote/scheme/sys@host:port/" within the URI.
             *
             * Example:
             *
             * akka.tcp://sys@home:1234/remote/akka/sys@remote:6667/remote/akka/sys@other:3333/user/a/b/c
             *
             * means that the logical parent originates from "akka.tcp://sys@other:3333" with
             * one child (may be "a" or "b") being deployed on "akka.tcp://sys@remote:6667" and
             * finally either "b" or "c" being created on "akka.tcp://sys@home:1234", where
             * this whole thing actually resides. Thus, the logical path is
             * "/user/a/b/c" and the physical path contains all remote placement
             * information.
             *
             * Deployments are always looked up using the logical path, which is the
             * purpose of the lookupRemotes internal method.
             */

            var    elements     = path.Elements;
            Deploy configDeploy = null;

            if (lookupDeploy)
            {
                if (elements.Head().Equals("user"))
                {
                    configDeploy = Deployer.Lookup(elements.Drop(1));
                }
                else if (elements.Head().Equals("remote"))
                {
                    configDeploy = LookUpRemotes(elements);
                }
            }

            //merge all of the fallbacks together
            var deployment = new List <Deploy>()
            {
                deploy, configDeploy
            }.Where(x => x != null).Aggregate(Deploy.None, (deploy1, deploy2) => deploy2.WithFallback(deploy1));
            var propsDeploy = new List <Deploy>()
            {
                props.Deploy, deployment
            }.Where(x => x != null)
            .Aggregate(Deploy.None, (deploy1, deploy2) => deploy2.WithFallback(deploy1));

            //match for remote scope
            if (propsDeploy.Scope is RemoteScope)
            {
                var addr = propsDeploy.Scope.AsInstanceOf <RemoteScope>().Address;

                //Even if this actor is in RemoteScope, it might still be a local address
                if (HasAddress(addr))
                {
                    return(LocalActorOf(system, props, supervisor, path, false, deployment, false, async));
                }

                //check for correct scope configuration
                if (props.Deploy.Scope is LocalScope)
                {
                    throw new ConfigurationException($"configuration requested remote deployment for local-only Props at {path}");
                }

                try
                {
                    try
                    {
                        // for consistency we check configuration of dispatcher and mailbox locally
                        var dispatcher  = _system.Dispatchers.Lookup(props.Dispatcher);
                        var mailboxType = _system.Mailboxes.GetMailboxType(props, dispatcher.Configurator.Config);
                    }
                    catch (Exception ex)
                    {
                        throw new ConfigurationException(
                                  $"Configuration problem while creating {path} with dispatcher [{props.Dispatcher}] and mailbox [{props.Mailbox}]", ex);
                    }
                    var localAddress = Transport.LocalAddressForRemote(addr);
                    var rpath        = (new RootActorPath(addr) / "remote" / localAddress.Protocol / localAddress.HostPort() /
                                        path.Elements.ToArray()).
                                       WithUid(path.Uid);
                    var remoteRef = new RemoteActorRef(Transport, localAddress, rpath, supervisor, props, deployment);
                    return(remoteRef);
                }
                catch (Exception ex)
                {
                    throw new ActorInitializationException($"Remote deployment failed for [{path}]", ex);
                }
            }
            else
            {
                return(LocalActorOf(system, props, supervisor, path, false, deployment, false, async));
            }
        }
コード例 #10
0
 /// <summary>
 /// Sends the given message to the recipient, supplying <see cref="sender"/> if any.
 /// </summary>
 public abstract void Send(object message, IActorRef sender, RemoteActorRef recipient);
コード例 #11
0
 public Send(object message, ActorRef sender, RemoteActorRef recipient)
 {
     Message = message;
     Sender = sender;
     Recipient = recipient;
 }
コード例 #12
0
 public void UseActorOnNode(RemoteActorRef actor, Props props, Deploy deploy, InternalActorRef supervisor)
 {
     Akka.Serialization.Serialization.CurrentTransportInformation = new Information
     {
         System = System,
         Address = actor.LocalAddressToUse,
     };
     log.Debug("[{0}] Instantiating Remote Actor [{1}]", RootPath, actor.Path);
     ActorRef remoteNode = ResolveActorRef(new RootActorPath(actor.Path.Address)/"remote");
     remoteNode.Tell(new DaemonMsgCreate(props, deploy, actor.Path.ToSerializationFormat(), supervisor));
 }
コード例 #13
0
        private InternalActorRef RemoteActorOf(ActorSystem system, Props props, InternalActorRef supervisor,
            ActorPath path, Mailbox mailbox)
        {
            var scope = (RemoteScope) props.Deploy.Scope;
            Deploy d = props.Deploy;
            Address addr = scope.Address;

            if (HasAddress(addr))
            {
                return LocalActorOf(System, props, supervisor, path, mailbox);
            }

            Address localAddress = Transport.LocalAddressForRemote(addr);

            ActorPath rpath = (new RootActorPath(addr)/"remote"/localAddress.Protocol/localAddress.HostPort()/
                               path.Elements.Drop(1).ToArray()).
                WithUid(path.Uid);
            var remoteRef = new RemoteActorRef(Transport, localAddress, rpath, supervisor, props, d);
            remoteRef.Start();
            return remoteRef;
        }