Start() 공개 메소드

Starts this instance.
public Start ( ) : void
리턴 void
예제 #1
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);
        }
예제 #2
0
        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(
                              string.Format("configuration requested remote deployment for local-only Props at {0}", 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(
                                  string.Format(
                                      "Configuration problem while creating {0} with dispatcher [{1}] and mailbox [{2}]", path,
                                      props.Dispatcher, 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);
                    remoteRef.Start();
                    return(remoteRef);
                }
                catch (Exception ex)
                {
                    throw new ActorInitializationException(string.Format("Remote deployment failed for [{0}]", path), ex);
                }
            }
            else
            {
                return(LocalActorOf(system, props, supervisor, path, false, deployment, false, async));
            }
        }
예제 #3
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;
        }