public Delivery(ActorPath destination, object message, DateTime timestamp, int attempt)
 {
     Destination = destination;
     Message = message;
     Timestamp = timestamp;
     Attempt = attempt;
 }
Beispiel #2
0
 public FutureActorRef(TaskCompletionSource<object> result, ActorRef sender, Action unregister, ActorPath path)
 {
     this.result = result;
     this.sender = sender;
     this.unregister = unregister;
     Path = path;
 }
 public RootGuardianSupervisor(RootActorPath root, IActorRefProvider provider, TaskCompletionSource<Status> terminationPromise, ILoggingAdapter log)
 {
     _log = log;
     _terminationPromise = terminationPromise;
     _provider = provider;
     _path = root / "_Root-guardian-supervisor";   //In akka this is root / "bubble-walker" 
 }
Beispiel #4
0
        public RoutedActorCell(ActorSystem system, InternalActorRef supervisor, Props routerProps, Props routeeProps, ActorPath path,
            Mailbox mailbox)
            : base(system, supervisor, routerProps, path, mailbox)
        {
            RouteeProps = routeeProps;
            routerConfig = routerProps.RouterConfig;
            Router = routerConfig.CreateRouter(system);
            routerConfig.Match()
                .With<Pool>(r =>
                {
                    var routees = new List<Routee>();
                    for (int i = 0; i < r.NrOfInstances; i++)
                    {
                        var routee = this.ActorOf(RouteeProps);
                        routees.Add(new ActorRefRoutee(routee));
                    }
                    AddRoutees(routees.ToArray());
                })
                .With<Group>(r =>
                {
                    var routees = routerConfig.GetRoutees(this).ToArray();
                    AddRoutees(routees);
                });



            Self = new RoutedActorRef(path, this);
        }
Beispiel #5
0
 public RootGuardianActorRef(ActorSystemImpl system, Props props, MessageDispatcher dispatcher, Func<Mailbox> createMailbox, //TODO: switch from  Func<Mailbox> createMailbox to MailboxType mailboxType
     IInternalActorRef supervisor, ActorPath path, IInternalActorRef deadLetters, IReadOnlyDictionary<string, IInternalActorRef> extraNames)
     : base(system,props,dispatcher,createMailbox,supervisor,path)
 {
     _deadLetters = deadLetters;
     _extraNames = extraNames;
 }
Beispiel #6
0
 public FutureActorRef(TaskCompletionSource<object> result, ActorRef sender, Action unregister, ActorPath path)
 {
     _result = result;
     _sender = sender ?? ActorRef.NoSender;
     _unregister = unregister;
     Path = path;
 }
Beispiel #7
0
        public void CreateFromStringAndToString()
        {
            string path ="abc\\def";
            var ap = new ActorPath(path);

            Assert.AreEqual(path, ap.ToString());
        }
Beispiel #8
0
        public void CreateFromParentAndToString()
        {
            var ap1 = new ActorPath("");
            var ap2 = new ActorPath("test", ap1);

            Assert.AreEqual("\\test", ap2.ToString());
        }
Beispiel #9
0
 public void WhenAddChild_ThenNewActorRefPathIncludesCurrentPlusChild()
 {
     var actorPath = new ActorPath("root", null);
     ActorPath childPath = actorPath.AddChild("child");
     string[] elements = childPath.Elements.ToArray();
     Assert.AreEqual("root", elements[0]);
     Assert.AreEqual("child", elements[1]);
 }
Beispiel #10
0
        public Deploy Lookup(ActorPath path)
        {
            if (path.Elements.Head() != "user" || path.Elements.Count() < 2)
                return Deploy.None;

            var elements = path.Elements.Drop(1);
            return Lookup(elements);
        }
            public static SurrogateForActorPath Convert(ActorPath value)
            {
                if (value == null)
                    return null;

                var path = ((ActorPath.Surrogate)value.ToSurrogate(CurrentSystem)).Path;
                return new SurrogateForActorPath { Path = path };
            }
 public void Setup(BenchmarkContext context)
 {
     _selectionOpCounter = context.GetCounter(ActorSelectionCounterName);
     System = ActorSystem.Create("MailboxThroughputSpecBase" + Counter.GetAndIncrement());
     _receiver = System.ActorOf(Props.Create(() => new BenchmarkActor(_selectionOpCounter, NumberOfMessages, _resetEvent)));
     _receiverActorPath = _receiver.Path;
     _oneMessageBenchmarkProps = Props.Create(() => new BenchmarkActor(_selectionOpCounter, 1, _resetEvent));
 }
 public RepointableActorRef(ActorSystemImpl system, Props props, MessageDispatcher dispatcher, Func<Mailbox> createMailbox, IInternalActorRef supervisor, ActorPath path)
 {
     _system = system;
     _props = props;
     _dispatcher = dispatcher;
     _createMailbox = createMailbox;
     _supervisor = supervisor;
     _path = path;
 }
Beispiel #14
0
        async Task Activate(ActorPath path)
        {
            var system = ClusterActorSystem.Current;

            actor = Activator.Activate(path.Type);
            actor.Initialize(path.Id, system, this, ActorPrototype.Of(path.Type));

            await actor.OnActivate();
        }
 public RepointableActorRef(ActorSystemImpl system, Props props, MessageDispatcher dispatcher, MailboxType mailboxType, IInternalActorRef supervisor, ActorPath path)
 {
     System = system;
     Props = props;
     Dispatcher = dispatcher;
     MailboxType = mailboxType;
     Supervisor = supervisor;
     _path = path;
 }
Beispiel #16
0
        public void EqualsTest()
        {
            var ap1 = new ActorPath("");
            var ap2 = new ActorPath("test", ap1);
            var ap3 = new ActorPath("\\test");

            Assert.IsTrue(ap2 == ap3);
            Assert.IsFalse(ap1 == ap3);
        }
Beispiel #17
0
 /// <summary>
 /// Inheritors should only call this constructor
 /// </summary>
 internal protected  LocalActorRef(ActorSystem system, Props props, MessageDispatcher dispatcher, Func<Mailbox> createMailbox, IInternalActorRef supervisor, ActorPath path, Func<LocalActorRef, ActorCell> createActorCell) //TODO: switch from  Func<Mailbox> createMailbox to MailboxType mailboxType      
 {
     _system = system;
     _props = props;
     _dispatcher = dispatcher;
     _createMailbox = createMailbox;
     _supervisor = supervisor;
     _path = path;
     _cell = createActorCell(this);
 }
Beispiel #18
0
 public void WhenAddDescendantsWithPathString_ThenNewActorRefPathIncludesCurrentPlusChild()
 {
     var actorPath = new ActorPath("root", null);
     ActorPath childPath = actorPath.AddDescendant("child1/child2/child3");
     string[] elements = childPath.Elements.ToArray();
     Assert.AreEqual("root", elements[0]);
     Assert.AreEqual("child1", elements[1]);
     Assert.AreEqual("child2", elements[2]);
     Assert.AreEqual(actorPath, childPath.Root);
 }
        public static IActorEndpoint Proxy(ActorPath path)
        {
            var factory = factories.Find(path.Type);

            if (factory == null)
               throw new InvalidOperationException(
                   string.Format("Type: '{0}' is not registered as an Actor or Worker", path.Type));

            return (IActorEndpoint)factory(path.ToString());
        }
Beispiel #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RemoteActorRef"/> class.
 /// </summary>
 /// <param name="remote">The remote.</param>
 /// <param name="localAddressToUse">The local address to use.</param>
 /// <param name="path">The path.</param>
 /// <param name="parent">The parent.</param>
 /// <param name="props">The props.</param>
 /// <param name="deploy">The deploy.</param>
 internal RemoteActorRef(RemoteTransport remote, Address localAddressToUse, ActorPath path, InternalActorRef parent,
     Props props, Deploy deploy)
 {
     Remote = remote;
     LocalAddressToUse = localAddressToUse;
     Path = path;
     _parent = parent;
     _props = props;
     _deploy = deploy;
 }
Beispiel #21
0
 public void WhenAddDescendant_ThenNewActorRefPathIncludesCurrentPlusAllDescendants()
 {
     var actorPath = new ActorPath("root", null);
     ActorPath childPath1 = actorPath.AddChild("child1");
     ActorPath childPath2 = childPath1.AddChild("child2");
     string[] elements = childPath2.Elements.ToArray();
     Assert.AreEqual("root", elements[0]);
     Assert.AreEqual("child1", elements[1]);
     Assert.AreEqual("child2", elements[2]);
 }
Beispiel #22
0
        //This mimics what's done in Akka`s construction of an LocalActorRef.
        //The actorCell is created in the overridable newActorCell() during creation of the instance.
        //Since we don't want calls to virtual members in C# we must supply it. 
        //
        //This is the code from Akka:
        //    private[akka] class LocalActorRef private[akka] (
        //        _system: ActorSystemImpl,
        //        _props: Props,
        //        _dispatcher: MessageDispatcher,
        //        _mailboxType: MailboxType,
        //        _supervisor: InternalActorRef,
        //        override val path: ActorPath) extends ActorRefWithCell with LocalRef {
        //      private val actorCell: ActorCell = newActorCell(_system, this, _props, _dispatcher, _supervisor)
        //      actorCell.init(sendSupervise = true, _mailboxType)
        //      ...
        //    }
        public LocalActorRef(ActorSystemImpl system, Props props, MessageDispatcher dispatcher, Func<Mailbox> createMailbox, IInternalActorRef supervisor, ActorPath path) //TODO: switch from  Func<Mailbox> createMailbox to MailboxType mailboxType      
            : this(system, props, dispatcher, createMailbox, supervisor, path, self =>
            {
                var cell= new ActorCell(system, self, props, dispatcher, supervisor);
                cell.Init(sendSupervise: true, createMailbox: createMailbox);
                return cell;
            })
        {
            //Intentionally left blank

        }
Beispiel #23
0
        Task Activate(ActorPath path)
        {
            var system = ClusterActorSystem.Current;

            var runtime = new ActorRuntime(system, this);
            actor = Activator.Activate(path, runtime);

            var prototype = ActorPrototype.Of(path);
            actor.Initialize(path.Id, runtime, prototype);

            return actor.OnActivate();
        }
        public static IActorEndpoint Proxy(ActorPath path)
        {
            var type = ActorType.Registered(path.Code);

            var factory = factories.Find(type);
            if (factory == null)
               throw new InvalidOperationException(
                   $"Path '{path}' is not registered as an Actor or Worker." +
                   "Make sure you've registered assembly containing this type");

            return (IActorEndpoint)factory(path.Serialize());
        }
Beispiel #25
0
        internal static ActorPrototype Of(ActorPath path)
        {
            var type = ActorType.Registered(path.Code);

            var prototype = cache.Find(type);
            if (prototype == null)
                throw new InvalidOperationException(
                    $"Can't find implementation for path '{path}'." +
                     "Make sure you've registered assembly containing this type");

            return prototype;
        }
Beispiel #26
0
        public ResizablePoolCell(ActorSystem system, InternalActorRef supervisor, Props routerProps,
            Props routeeProps, ActorPath path, Mailbox mailbox, Pool pool)
            : base(system, supervisor, routerProps, routeeProps, path, mailbox)
        {
            if (pool.Resizer == null)
                throw new ArgumentException("RouterConfig must be a Pool with defined resizer");

            resizer = pool.Resizer;
            this._pool = pool;
            this._resizeCounter = 0;
            this._resizeInProgress = ResizeInProgressState.False;
        }
Beispiel #27
0
 public RoutedActorRef(
     ActorSystemImpl system,
     Props routerProps,
     MessageDispatcher routerDispatcher,
     MailboxType routerMailbox,
     Props routeeProps,
     IInternalActorRef supervisor,
     ActorPath path)
     : base(system, routerProps, routerDispatcher, routerMailbox, supervisor, path)
 {
     _routeeProps = routeeProps;
     routerProps.RouterConfig.VerifyConfig(path);
 }
        public LocalActorRefProvider(string systemName, Settings settings, EventStream eventStream, Deployer deployer, Func<ActorPath, InternalActorRef> deadLettersFactory)
        {
            _settings = settings;
            _eventStream = eventStream;
            _deployer = deployer ?? new Deployer(settings);
            _rootPath = new RootActorPath(new Address("akka", systemName));
            _log = Logging.GetLogger(eventStream, "LocalActorRefProvider(" + _rootPath.Address + ")");
            if (deadLettersFactory == null)
                deadLettersFactory = p => new DeadLetterActorRef(this, p, _eventStream);
            _deadLetters = deadLettersFactory(_rootPath / "deadLetters");
            _tempNumber = new AtomicCounterLong(1);
            _tempNode = _rootPath / "temp";

            //TODO: _guardianSupervisorStrategyConfigurator = dynamicAccess.createInstanceFor[SupervisorStrategyConfigurator](settings.SupervisorStrategyClass, EmptyImmutableSeq).get
            _systemGuardianStrategy = SupervisorStrategy.DefaultStrategy;

        }
        public override InternalActorRef ActorOf(ActorSystem system, Props props, InternalActorRef supervisor,
            ActorPath path)
        {
            Mailbox mailbox = System.Mailboxes.FromConfig(props.Mailbox);

            Deploy configDeploy = System.Provider.Deployer.Lookup(path);
            var deploy = configDeploy ?? props.Deploy ?? Deploy.None;
            if (deploy.Mailbox != null)
                props = props.WithMailbox(deploy.Mailbox);
            if (deploy.Dispatcher != null)
                props = props.WithDispatcher(deploy.Dispatcher);
            if (deploy.Scope is RemoteScope)
            {

            }

            //If this actor is a Router
            if (!(props.RouterConfig is NoRouter || props.RouterConfig == null))
            {
                //if no Router config value was specified, override with procedural input
                if (deploy.RouterConfig is NoRouter)
                {
                    deploy = deploy.WithRouterConfig(props.RouterConfig);
                }
            }
            props = props.WithDeploy(deploy);
            

            if (string.IsNullOrEmpty(props.Mailbox))
            {
                //   throw new NotSupportedException("Mailbox can not be configured as null or empty");
            }
            if (string.IsNullOrEmpty(props.Dispatcher))
            {
                //TODO: fix this..
                //    throw new NotSupportedException("Dispatcher can not be configured as null or empty");
            }


            if (props.Deploy != null && props.Deploy.Scope is RemoteScope)
            {
                return RemoteActorOf(system, props, supervisor, path, mailbox);
            }
            return LocalActorOf(system, props, supervisor, path, mailbox);
        }
Beispiel #30
0
 public RoutedActorRef(ActorSystemImpl system, Props routerProps, MessageDispatcher routerDispatcher,
     Func<Mailbox> createMailbox, Props routeeProps, IInternalActorRef supervisor, ActorPath path)
     : base(system, routerProps, routerDispatcher, createMailbox, supervisor, path)
 {
     _system = system;
     _routerProps = routerProps;
     _routerDispatcher = routerDispatcher;
     _createMailbox = createMailbox;
     _routeeProps = routeeProps;
     _supervisor = supervisor;
     //TODO: Implement:
     // // verify that a BalancingDispatcher is not used with a Router
     // if (!(routerProps.RouterConfig is NoRouter) && routerDispatcher is BalancingDispatcher)
     // {
     //     throw new ConfigurationException("Configuration for " + this +
     //                                 " is invalid - you can not use a 'BalancingDispatcher' as a Router's dispatcher, you can however use it for the routees.");
     // }
     // routerProps.RouterConfig.VerifyConfig(path);
 }
Beispiel #31
0
 /// <summary>
 /// Send the message created with <paramref name="deliveryMessageMapper" /> function to the
 /// <paramref name="destination" /> actor. It will retry sending the message until the delivery is
 /// confirmed with <see cref="ConfirmDelivery" />.
 /// Correlation between these two methods is performed by deliveryId that is provided as parameter
 /// to the <paramref name="deliveryMessageMapper"/> function. The deliveryId is typically passed in the message to
 /// the destination, which replies with a message containing the same 'deliveryId'.
 ///
 /// The 'deliveryId' is a strictly monotonically increasing sequence number without gaps.
 /// The same sequence is used for all destinations of the actor, i.e. when sending
 /// to multiple destinations the destinations will see gaps in the sequence if no translation is performed.
 ///
 /// During recovery this method will not send out the message, but it will be sent later if no matching
 /// <see cref="ConfirmDelivery" /> was performed.
 /// </summary>
 /// <param name="destination">TBD</param>
 /// <param name="deliveryMessageMapper">TBD</param>
 /// <exception cref="MaxUnconfirmedMessagesExceededException">
 /// Thrown when <see cref="UnconfirmedCount" /> is greater than or equal to <see cref="MaxUnconfirmedMessages" />.
 /// </exception>
 public void Deliver(ActorPath destination, Func <long, object> deliveryMessageMapper)
 {
     _atLeastOnceDeliverySemantic.Deliver(destination, deliveryMessageMapper, IsRecovering);
 }
Beispiel #32
0
        internal static void Tell(ActorPath path, object message)
        {
            var selection = System.ActorSelection(path);

            selection.Tell(message);
        }
Beispiel #33
0
 /// <summary>
 /// N/A
 /// </summary>
 /// <param name="path">N/A</param>
 /// <exception cref="ConfigurationException">
 /// This exception is automatically thrown since 'akka.actor.dispatch' is missing router configuration for <paramref name="path"/>.
 /// </exception>
 /// <returns>N/A</returns>
 public override void VerifyConfig(ActorPath path)
 {
     throw new ConfigurationException($"Configuration missing for router [{path}] in 'akka.actor.deployment' section.");
 }
Beispiel #34
0
        ActorRef IActorSystem.ActorOf(Type type, string id)
        {
            var path = ActorPath.From(type, id);

            return((this as IActorSystem).ActorOf(path));
        }
Beispiel #35
0
 public ActorPath ActorPath_Parse()
 {
     return(ActorPath.Parse("akka.tcp://system/user/parent/child"));
 }
Beispiel #36
0
 public ActorRefMock(ActorPath path, IMessageSerializer serializer = null)
     : base(path)
 {
     this.serializer = serializer;
 }
Beispiel #37
0
 public void RegisterTempActor(IInternalActorRef actorRef, ActorPath path) => _localActorRefProvider.RegisterTempActor(actorRef, path);
Beispiel #38
0
        public IInternalActorRef ActorOf(ActorSystemImpl system, Props props, IInternalActorRef supervisor, ActorPath path, bool systemService, Deploy deploy, bool lookupDeploy, bool async)
        {
            if (props.Deploy.RouterConfig is NoRouter)
            {
                if (Settings.DebugRouterMisconfiguration)
                {
                    var d = Deployer.Lookup(path);
                    if (d != null && !(d.RouterConfig is NoRouter))
                    {
                        Log.Warning("Configuration says that [{0}] should be a router, but code disagrees. Remove the config or add a RouterConfig to its Props.",
                                    path);
                    }
                }

                var props2 = props;

                // mailbox and dispatcher defined in deploy should override props
                var propsDeploy = lookupDeploy ? Deployer.Lookup(path) : deploy;
                if (propsDeploy != null)
                {
                    if (propsDeploy.Mailbox != Deploy.NoMailboxGiven)
                    {
                        props2 = props2.WithMailbox(propsDeploy.Mailbox);
                    }
                    if (propsDeploy.Dispatcher != Deploy.NoDispatcherGiven)
                    {
                        props2 = props2.WithDispatcher(propsDeploy.Dispatcher);
                    }
                }

                if (!system.Dispatchers.HasDispatcher(props2.Dispatcher))
                {
                    throw new ConfigurationException($"Dispatcher [{props2.Dispatcher}] not configured for path {path}");
                }

                try
                {
                    // for consistency we check configuration of dispatcher and mailbox locally
                    var dispatcher  = _system.Dispatchers.Lookup(props2.Dispatcher);
                    var mailboxType = _system.Mailboxes.GetMailboxType(props2, dispatcher.Configurator.Config);

                    if (async)
                    {
                        return
                            (new TraceRepointableActorRef(system, props2, dispatcher,
                                                          mailboxType, supervisor,
                                                          path).Initialize(async));
                    }
                    return(new TraceLocalActorRef(system, props2, dispatcher,
                                                  mailboxType, supervisor, path));
                }
                catch (Exception ex)
                {
                    throw new ConfigurationException(
                              $"Configuration problem while creating [{path}] with dispatcher [{props.Dispatcher}] and mailbox [{props.Mailbox}]", ex);
                }
            }
            else //routers!!!
            {
                throw new NotImplementedException("Router not support");
            }
        }
 /// <inheritdoc/>
 public void RegisterTempActor(IInternalActorRef actorRef, ActorPath path)
 {
     _local.RegisterTempActor(actorRef, path);
 }
 private InternalTestActorRef(ActorSystem system, Props props, MessageDispatcher dispatcher, Func <Mailbox> createMailbox, IInternalActorRef supervisor, ActorPath path) //TODO: switch from  Func<Mailbox> createMailbox to MailboxType mailboxType
     : base(system, props, dispatcher, createMailbox, supervisor, path, actorRef => NewActorCell(system, actorRef, props, dispatcher, supervisor, createMailbox))
 {
 }
 public RemoteDeadLetterActorRef(IActorRefProvider provider, ActorPath actorPath, EventStream eventStream)
     : base(provider, actorPath, eventStream)
 {
 }
 /// <summary>
 /// Used to create <see cref="RemoteActorRef"/> instances upon deserialiation inside the Akka.Remote pipeline.
 /// </summary>
 /// <param name="actorPath">The remote path of the actor on its physical location on the network.</param>
 /// <param name="localAddress">The local path of the actor.</param>
 /// <returns>An <see cref="IInternalActorRef"/> instance.</returns>
 protected virtual IInternalActorRef CreateRemoteRef(ActorPath actorPath, Address localAddress)
 {
     return(new RemoteActorRef(Transport, localAddress, actorPath, ActorRefs.Nobody, Props.None, Deploy.None));
 }
 private IInternalActorRef LocalActorOf(ActorSystemImpl system, Props props, IInternalActorRef supervisor,
                                        ActorPath path, bool systemService, Deploy deploy, bool lookupDeploy, bool async)
 {
     return(_local.ActorOf(system, props, supervisor, path, systemService, deploy, lookupDeploy, async));
 }
Beispiel #44
0
 public IActorRef ResolveActorRef(ActorPath actorPath) => _localActorRefProvider.ResolveActorRef(actorPath);
 public EqualTestActorRef(ActorPath path)
 {
     _path = path;
 }
Beispiel #46
0
 public void UnregisterTempActor(ActorPath path) => _localActorRefProvider.UnregisterTempActor(path);
Beispiel #47
0
 public DummyActorRef(ActorPath path)
 {
     _path = path;
 }
Beispiel #48
0
 /// <summary>
 /// Check that everything is there which is needed. Called in constructor of RoutedActorRef to fail early.
 /// </summary>
 public virtual void VerifyConfig(ActorPath path)
 {
 }
Beispiel #49
0
 public ActorRefMock(ActorPath path)
     : base(path)
 {
 }
 public ActorSelection ActorSelection(ActorPath actorPath)
 {
     return(Sys.ActorSelection(actorPath));
 }
        public ActorRef ActorOf(ActorPath path)
        {
            var endpoint = HttpActorEndpoint.From(client, serializer, mapper, path);

            return(new ActorRef(path, endpoint, middleware));
        }
 public void ParseLocalThroughput(BenchmarkContext context)
 {
     ActorPath.Parse("akka://Sys/user/foo");
     _parseThroughput.Increment();
 }
Beispiel #53
0
 public void Setup()
 {
     x = new RootActorPath(new Address("akka.tcp", "system", "127.0.0.1", 1337), "user");
     y = new RootActorPath(new Address("akka.tcp", "system", "127.0.0.1", 1337), "system");
 }
 public void ParseRemoteThroughput(BenchmarkContext context)
 {
     ActorPath.Parse("akka.tcp://Sys@localhost:9091/user/foo");
     _parseThroughput.Increment();
 }
Beispiel #55
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="path">TBD</param>
 /// <returns>TBD</returns>
 public static string MakeKey(ActorPath path)
 {
     return(_pathRegex.Replace(path.ToStringWithoutAddress(), "$1"));
 }
 /// <inheritdoc/>
 public void UnregisterTempActor(ActorPath path)
 {
     _local.UnregisterTempActor(path);
 }
Beispiel #57
0
        public void Can_be_constructed_and_serialized_without_actor_registration()
        {
            var path = ActorPath.From("T", "42");

            Assert.AreEqual("T:42", path.ToString());
        }
Beispiel #58
0
 public ActorRef ActorOf(ActorPath path)
 {
     return(RequestedRef = new ActorRefMock(path));
 }
        /// <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));
            }
        }
Beispiel #60
0
 public WorkDoneMessage(Guid id, ActorPath executor)
 {
     Id       = id;
     Executor = executor;
 }