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; }
public ActorCell(ActorSystemImpl system, InternalActorRef self, Props props, MessageDispatcher dispatcher, InternalActorRef parent) { _self = self; _props = props; _systemImpl = system; Parent = parent; Dispatcher = dispatcher; }
public override void Init(ActorSystemImpl system) { //Complete the usual RemoteActorRefProvider initializations - need access to transports and RemoteWatcher before clustering can work base.Init(system); // initialize/load the Cluster extension Cluster.Get(system); }
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; }
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; }
//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 }
public ResizablePoolCell(ActorSystemImpl system, IInternalActorRef self, Props routerProps, MessageDispatcher dispatcher, Props routeeProps, IInternalActorRef supervisor, Pool pool) : base(system,self, routerProps,dispatcher, routeeProps, supervisor) { if (pool.Resizer == null) throw new ArgumentException("RouterConfig must be a Pool with defined resizer"); resizer = pool.Resizer; _routerProps = routerProps; _pool = pool; _resizeCounter = new AtomicCounterLong(0); _resizeInProgress = new AtomicBoolean(); }
protected override IActorRef CreateRemoteWatcher(ActorSystemImpl system) { // make sure Cluster extension is initialized/loaded from init thread Cluster.Get(system); var failureDetector = CreateRemoteWatcherFailureDetector(system); return system.SystemActorOf(ClusterRemoteWatcher.Props( failureDetector, RemoteSettings.WatchHeartBeatInterval, RemoteSettings.WatchUnreachableReaperInterval, RemoteSettings.WatchHeartbeatExpectedResponseAfter), "remote-watcher"); }
public void ActorOf_gives_child_unique_name_if_not_specified() { //arrange var system = new ActorSystemImpl("test"); system.Start(); //When we create a system manually we have to start it ourselves //act var child1 = system.ActorOf<TestActor>(); var child2 = system.ActorOf<TestActor>(); //assert Assert.NotEqual(child1.Path, child2.Path); }
public RoutedActorCell( ActorSystemImpl system, IInternalActorRef self, Props routerProps, MessageDispatcher dispatcher, Props routeeProps, IInternalActorRef supervisor) : base(system, self, routerProps, dispatcher, supervisor) { RouteeProps = routeeProps; RouterConfig = routerProps.RouterConfig; Router = null; }
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 void ActorSystem_ActorOf_adds_a_child_to_Guardian() { //arrange var system = new ActorSystemImpl("test"); system.Start(); //When we create a system manually we have to start it ourselves //act var child = system.ActorOf<TestActor>("test"); //assert var children = system.Provider.Guardian.Children; Assert.True(children.Any(c => c == child)); }
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); }
public RoutedActorCell(ActorSystemImpl system, InternalActorRef self, Props routerProps, MessageDispatcher dispatcher, Props routeeProps, InternalActorRef supervisor) : base(system, self, routerProps, dispatcher, supervisor) { _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 = ActorOf(_routeeProps); routees.Add(new ActorRefRoutee(routee)); } AddRoutees(routees.ToArray()); }) .With<Group>(r => { var routees = _routerConfig.GetRoutees(this).ToArray(); AddRoutees(routees); }); }
//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, MailboxType mailboxType, IInternalActorRef supervisor, ActorPath path) { _system = system; _props = props; _dispatcher = dispatcher; MailboxType = mailboxType; _supervisor = supervisor; _path = path; /* * Safe publication of this class’s fields is guaranteed by Mailbox.SetActor() * which is called indirectly from ActorCell.init() (if you’re wondering why * this is at all important, remember that under the CLR readonly fields are only * frozen at the _end_ of the constructor, but we are publishing “this” before * that is reached). * This means that the result of NewActorCell needs to be written to the field * _cell before we call init and start, since we can start using "this" * object from another thread as soon as we run init. */ // ReSharper disable once VirtualMemberCallInContructor _cell = NewActorCell(_system, this, _props, _dispatcher, _supervisor); // _cell needs to be assigned before Init is called. _cell.Init(true, MailboxType); }
public InternalActorRef ActorOf(ActorSystemImpl system, Props props, InternalActorRef supervisor, ActorPath path, bool systemService, Deploy deploy, bool lookupDeploy, bool async) { //TODO: This does not match Akka's ActorOf at all Deploy configDeploy = _system.Provider.Deployer.Lookup(path); 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 (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"); } //TODO: how should this be dealt with? //akka simply passes the "deploy" var from remote daemon to ActorOf //so it atleast seems like they ignore if remote scope is provided here. //leaving this for now since it does work //if (props.Deploy != null && props.Deploy.Scope is RemoteScope) //{ // throw new NotSupportedException("LocalActorRefProvider can not deploy remote"); //} if (props.RouterConfig is NoRouter || props.RouterConfig == null) { props = props.WithDeploy(deploy); var dispatcher = system.Dispatchers.FromConfig(props.Dispatcher); var mailbox = _system.Mailboxes.FromConfig(props.Mailbox); //TODO: Should be: system.mailboxes.getMailboxType(props2, dispatcher.configurator.config) if (async) { var reActorRef = new RepointableActorRef(system, props, dispatcher, () => mailbox, supervisor, path); reActorRef.Initialize(async: true); return reActorRef; } return new LocalActorRef(system, props, dispatcher, () => mailbox, supervisor, path); } else { //if no Router config value was specified, override with procedural input if (deploy.RouterConfig is NoRouter) { deploy = deploy.WithRouterConfig(props.RouterConfig); } var routerDispatcher = system.Dispatchers.FromConfig(props.RouterConfig.RouterDispatcher); var routerMailbox = _system.Mailboxes.FromConfig(props.Mailbox); //TODO: Should be val routerMailbox = system.mailboxes.getMailboxType(routerProps, routerDispatcher.configurator.config) // routers use context.actorOf() to create the routees, which does not allow us to pass // these through, but obtain them here for early verification var routerProps = Props.Empty.WithDeploy(deploy); var routeeProps = props.WithRouter(RouterConfig.NoRouter); var routedActorRef = new RoutedActorRef(system, routerProps, routerDispatcher, () => routerMailbox, routeeProps, supervisor, path); routedActorRef.Initialize(async); return routedActorRef; } }
private InternalActorRef CreateWithRouter(ActorSystemImpl system, Props props, InternalActorRef supervisor, ActorPath path, Deploy deploy, bool async) { //if no Router config value was specified, override with procedural input if (deploy.RouterConfig.NoRouter()) { deploy = deploy.WithRouterConfig(props.RouterConfig); } var routerDispatcher = system.Dispatchers.FromConfig(props.RouterConfig.RouterDispatcher); var routerMailbox = _system.Mailboxes.CreateMailbox(props, null); //TODO: Should be val routerMailbox = system.mailboxes.getMailboxType(routerProps, routerDispatcher.configurator.config) // routers use context.actorOf() to create the routees, which does not allow us to pass // these through, but obtain them here for early verification var routerProps = Props.Empty.WithDeploy(deploy); var routeeProps = props.WithRouter(RouterConfig.NoRouter); var routedActorRef = new RoutedActorRef(system, routerProps, routerDispatcher, () => routerMailbox, routeeProps, supervisor, path); routedActorRef.Initialize(async); return routedActorRef; }
/// <summary> /// Initializes a new instance of the <see cref="RemoteDaemon" /> class. /// </summary> /// <param name="system">The system.</param> /// <param name="path">The path.</param> /// <param name="parent">The parent.</param> /// <param name="log"></param> public RemoteDaemon(ActorSystemImpl system, ActorPath path, InternalActorRef parent, LoggingAdapter log) : base(system.Provider, path, parent, log) { _system = system; AddressTerminatedTopic.Get(system).Subscribe(this); }
public IInternalActorRef ActorOf(ActorSystemImpl system, Props props, IInternalActorRef supervisor, ActorPath path, bool systemService, Deploy deploy, bool lookupDeploy, bool async) { if (props.Deploy.RouterConfig.NoRouter()) { if (Settings.DebugRouterMisconfiguration) { var d = Deployer.Lookup(path); if (d != null && d.RouterConfig != RouterConfig.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(string.Format("Dispatcher [{0}] not configured for path {1}", props2.Dispatcher, path)); } try { // for consistency we check configuration of dispatcher and mailbox locally var dispatcher = _system.Dispatchers.Lookup(props2.Dispatcher); if (async) return new RepointableActorRef(system, props2, dispatcher, () => _system.Mailboxes.CreateMailbox(props2, dispatcher.Configurator.Config), supervisor, path).Initialize(async); return new LocalActorRef(system, props2, dispatcher, () => _system.Mailboxes.CreateMailbox(props2, dispatcher.Configurator.Config), supervisor, path); } 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); } } else //routers!!! { var lookup = (lookupDeploy ? Deployer.Lookup(path) : null) ?? Deploy.None; var fromProps = new List<Deploy>() { props.Deploy, deploy, lookup }; var d = fromProps.Where(x => x != null).Aggregate((deploy1, deploy2) => deploy2.WithFallback(deploy1)); var p = props.WithRouter(d.RouterConfig); if (!system.Dispatchers.HasDispatcher(p.Dispatcher)) throw new ConfigurationException(string.Format("Dispatcher [{0}] not configured for routees of path {1}", p.Dispatcher, path)); if (!system.Dispatchers.HasDispatcher(d.RouterConfig.RouterDispatcher)) throw new ConfigurationException(string.Format("Dispatcher [{0}] not configured for router of path {1}", p.RouterConfig.RouterDispatcher, path)); var routerProps = Props.Empty.WithRouter(p.Deploy.RouterConfig).WithDispatcher(p.RouterConfig.RouterDispatcher); var routeeProps = props.WithRouter(RouterConfig.NoRouter); try { var routerDispatcher = system.Dispatchers.Lookup(p.RouterConfig.RouterDispatcher); var routerMailbox = system.Mailboxes.CreateMailbox(routerProps, routerDispatcher.Configurator.Config); // routers use context.actorOf() to create the routees, which does not allow us to pass // these through, but obtain them here for early verification var routeeDispatcher = system.Dispatchers.Lookup(p.Dispatcher); var routedActorRef = new RoutedActorRef(system, routerProps, routerDispatcher, () => routerMailbox, routeeProps, supervisor, path); routedActorRef.Initialize(async); return routedActorRef; } catch (Exception) { throw new ConfigurationException(string.Format("Configuration problem while creating [{0}] with router dispatcher [{1}] and mailbox {2}" + " and routee dispatcher [{3}] and mailbox [{4}].", path, routerProps.Dispatcher, routerProps.Mailbox, routeeProps.Dispatcher, routeeProps.Mailbox)); } } }
private RootGuardianActorRef CreateRootGuardian(ActorSystemImpl system) { var supervisor = new RootGuardianSupervisor(_rootPath, this, _terminationPromise, _log); var rootGuardianStrategy = new OneForOneStrategy(ex => { _log.Error(ex, "Guardian failed. Shutting down system"); return Directive.Stop; }); var props = Props.Create<GuardianActor>(rootGuardianStrategy); var rootGuardian = new RootGuardianActorRef(system, props, DefaultDispatcher, _defaultMailbox, supervisor, _rootPath, _deadLetters, _extraNames); return rootGuardian; }
/// <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)); } }
public InternalActorRef ActorOf(ActorSystemImpl system, Props props, InternalActorRef supervisor, ActorPath path, bool systemService, Deploy deploy, bool lookupDeploy, bool async) { //TODO: This does not match Akka's ActorOf at all Deploy configDeploy = _system.Provider.Deployer.Lookup(path); deploy = configDeploy ?? props.Deploy ?? Deploy.None; if(deploy.Mailbox != Deploy.NoMailboxGiven) props = props.WithMailbox(deploy.Mailbox); if(deploy.Dispatcher != Deploy.NoDispatcherGiven) props = props.WithDispatcher(deploy.Dispatcher); //TODO: how should this be dealt with? //akka simply passes the "deploy" var from remote daemon to ActorOf //so it atleast seems like they ignore if remote scope is provided here. //leaving this for now since it does work if(props.RouterConfig.NoRouter()) { return CreateNoRouter(system, props, supervisor, path, deploy, async); } return CreateWithRouter(system, props, supervisor, path, deploy, async); }
public void Start(ActorSystemImpl system, EventStream eventStream, bool debug) { system.SystemActorOf(Props.Create<EventStreamUnsubscriber>(eventStream, system, debug), string.Format("EventStreamUnsubscriber-{0}", _unsubscribersCounter.IncrementAndGet())); }
private InternalTestActorRef(ActorSystemImpl system, Props props, MessageDispatcher dispatcher, MailboxType mailboxType, IInternalActorRef supervisor, ActorPath path) : base(system, props, dispatcher, mailboxType, supervisor, path) { }
public ActorLookupSpec() { c1 = Sys.ActorOf(P, "c1"); c2 = Sys.ActorOf(P, "c2"); c21 = c2.Ask<IActorRef>(new Create("c21"), RemainingOrDefault).Result; SysImpl = (ActorSystemImpl) Sys; user = SysImpl.Guardian; syst = SysImpl.SystemGuardian; root = SysImpl.LookupRoot; }
public TraceRepointableActorRef(ActorSystemImpl system, Props props, MessageDispatcher dispatcher, MailboxType mailboxType, IInternalActorRef supervisor, ActorPath path) : base(system, props, dispatcher, mailboxType, supervisor, path) { _mailboxType = mailboxType; }
public void StartUnsubscriber(ActorSystemImpl system) { EventStreamUnsubscribersProvider.Instance.Start(system, this, _debug); }
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)); }
protected override ActorCell NewActorCell(ActorSystemImpl system, IInternalActorRef self, Props props, MessageDispatcher dispatcher, IInternalActorRef supervisor) { return new TestActorCell((ActorSystemImpl)system, self, props, dispatcher, supervisor); }
/// <summary> /// Starts the loggers defined in the system configuration. /// </summary> /// <param name="system">The system that the loggers need to start monitoring.</param> /// <exception cref="ConfigurationException"> /// This exception is thrown if the logger specified in the <paramref name="system"/> configuration could not be found or loaded. /// </exception> /// <exception cref="LoggerInitializationException"> /// This exception is thrown if the logger doesn't respond with a <see cref="LoggerInitialized"/> message when initialized. /// </exception> internal void StartDefaultLoggers(ActorSystemImpl system) { var logName = SimpleName(this) + "(" + system.Name + ")"; var logLevel = Logging.LogLevelFor(system.Settings.LogLevel); var loggerTypes = system.Settings.Loggers; var timeout = system.Settings.LoggerStartTimeout; var asyncStart = system.Settings.LoggerAsyncStart; var shouldRemoveStandardOutLogger = true; foreach (var strLoggerType in loggerTypes) { var loggerType = Type.GetType(strLoggerType); if (loggerType == null) { throw new ConfigurationException($@"Logger specified in config cannot be found: ""{strLoggerType}"""); } if (typeof(MinimalLogger).IsAssignableFrom(loggerType)) { shouldRemoveStandardOutLogger = false; continue; } if (asyncStart) { // Not awaiting for result, and not depending on current thread context Task.Run(() => AddLogger(system, loggerType, logLevel, logName, timeout)) .ContinueWith(t => { if (t.Exception != null) { Console.WriteLine($"Logger [{strLoggerType}] specified in config cannot be loaded: {t.Exception}"); } }); } else { try { AddLogger(system, loggerType, logLevel, logName, timeout); } catch (Exception ex) { throw new ConfigurationException($"Logger [{strLoggerType}] specified in config cannot be loaded: {ex}", ex); } } } LogLevel = logLevel; if (system.Settings.DebugUnhandledMessage) { var forwarder = system.SystemActorOf(Props.Create(typeof(UnhandledMessageForwarder)), "UnhandledMessageForwarder"); Subscribe(forwarder, typeof(UnhandledMessage)); } if (shouldRemoveStandardOutLogger) { var stdOutLogger = system.Settings.StdoutLogger; Publish(new Debug(logName, GetType(), $"{Logging.SimpleName(stdOutLogger)} being removed")); Unsubscribe(stdOutLogger); } Publish(new Debug(logName, GetType(), "Default Loggers started")); }
private InternalActorRef CreateNoRouter(ActorSystemImpl system, Props props, InternalActorRef supervisor, ActorPath path, Deploy deploy, bool async) { if(props.Deploy != deploy) props = props.WithDeploy(deploy); var dispatcher = system.Dispatchers.FromConfig(props.Dispatcher); var mailbox = _system.Mailboxes.CreateMailbox(props, null /*dispatcher.Configurator.Config*/); //TODO: Should be: system.mailboxes.getMailboxType(props2, dispatcher.configurator.config) if (async) { var reActorRef = new RepointableActorRef(system, props, dispatcher, () => mailbox, supervisor, path); reActorRef.Initialize(async: true); return reActorRef; } return new LocalActorRef(system, props, dispatcher, () => mailbox, supervisor, path); }
protected virtual ActorCell NewActorCell(ActorSystemImpl system, IInternalActorRef self, Props props, MessageDispatcher dispatcher, IInternalActorRef supervisor) { return(new ActorCell(system, self, props, dispatcher, supervisor)); }
public TestActorCell(ActorSystemImpl system, IInternalActorRef self, Props props, MessageDispatcher dispatcher, IInternalActorRef parent) : base(system, self, props, dispatcher, parent) { }
public InternalActorRef ActorOf(ActorSystemImpl system, Props props, InternalActorRef supervisor, ActorPath path, bool systemService, Deploy deploy, bool lookupDeploy, bool async) { if (systemService) { return(LocalActorOf(system, props, supervisor, path, true, deploy, lookupDeploy, async)); } Deploy configDeploy = system.Provider.Deployer.Lookup(path); 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) { var addr = props.Deploy.Scope.AsInstanceOf <RemoteScope>().Address; //Even if this actor is in RemoteScope, it might still be a local address if (HasAddress(addr)) { //if (path.Elements.First() == "remote") //{ // //this is a remote deployed actor //} //else //{ return(LocalActorOf(system, props, supervisor, path, false, null, false, async)); //TODO: replace deploy:null with deployment.headOption // } } return(RemoteActorOf(system, props, supervisor, path)); } return(LocalActorOf(system, props, supervisor, path, false, null, false, async)); //TODO: replace deploy:null with deployment.headOption }
/// <summary> /// TBD /// </summary> /// <param name="system">TBD</param> /// <param name="eventStream">TBD</param> /// <param name="debug">TBD</param> public void Start(ActorSystemImpl system, EventStream eventStream, bool debug) { system.SystemActorOf(Props.Create <EventStreamUnsubscriber>(eventStream, system, debug), string.Format("EventStreamUnsubscriber-{0}", _unsubscribersCounter.IncrementAndGet())); }
/// <summary> /// TBD /// </summary> /// <param name="system">TBD</param> /// <returns>TBD</returns> protected virtual IActorRef CreateRemoteDeploymentWatcher(ActorSystemImpl system) { return(system.SystemActorOf(RemoteSettings.ConfigureDispatcher(Props.Create <RemoteDeploymentWatcher>()), "remote-deployment-watcher")); }
public void Init(ActorSystemImpl system) { _system = system; //The following are the lazy val statements in Akka var defaultDispatcher = system.Dispatchers.DefaultGlobalDispatcher; _defaultMailbox = () => new ConcurrentQueueMailbox(); //TODO:system.Mailboxes.FromConfig(Mailboxes.DefaultMailboxId) _rootGuardian = CreateRootGuardian(system); _tempContainer = new VirtualPathContainer(system.Provider, _tempNode, _rootGuardian, _log); _rootGuardian.SetTempContainer(_tempContainer); _userGuardian = CreateUserGuardian(_rootGuardian, "user"); _systemGuardian = CreateSystemGuardian(_rootGuardian, "system", _userGuardian); //End of lazy val _rootGuardian.Start(); // chain death watchers so that killing guardian stops the application _systemGuardian.SendSystemMessage(new Watch(_userGuardian, _systemGuardian)); _rootGuardian.SendSystemMessage(new Watch(_systemGuardian, _rootGuardian)); _eventStream.StartDefaultLoggers(_system); }
public UnstartedCell(ActorSystemImpl system, RepointableActorRef self, Props props, IInternalActorRef supervisor) { _system = system; _self = self; _props = props; _supervisor = supervisor; _timeout = _system.Settings.UnstartedPushTimeout; }
/// <summary> /// TBD /// </summary> /// <param name="system">TBD</param> /// <param name="self">TBD</param> /// <param name="props">TBD</param> /// <param name="dispatcher">TBD</param> /// <param name="supervisor">TBD</param> /// <returns>TBD</returns> protected override ActorCell NewActorCell(ActorSystemImpl system, IInternalActorRef self, Props props, MessageDispatcher dispatcher, IInternalActorRef supervisor) { return(new TestActorCell((ActorSystemImpl)system, self, props, dispatcher, supervisor)); }
public IInternalActorRef ActorOf(ActorSystemImpl system, Props props, IInternalActorRef supervisor, ActorPath path, bool systemService, Deploy deploy, bool lookupDeploy, bool async) { if (props.Deploy.RouterConfig.NoRouter()) { if (Settings.DebugRouterMisconfiguration) { var d = Deployer.Lookup(path); if (d != null && d.RouterConfig != RouterConfig.NoRouter) { Log.Warning( string.Format( "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(string.Format("Dispatcher [{0}] not configured for path {1}", props2.Dispatcher, 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, ConfigurationFactory.Empty); if (async) { return (new RepointableActorRef(system, props2, dispatcher, () => _system.Mailboxes.CreateMailbox(props2, ConfigurationFactory.Empty), supervisor, path).Initialize(async)); } return(new LocalActorRef(system, props2, dispatcher, () => _system.Mailboxes.CreateMailbox(props2, ConfigurationFactory.Empty), supervisor, path)); } 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); } } else //routers!!! { var lookup = (lookupDeploy ? Deployer.Lookup(path) : null) ?? Deploy.None; var fromProps = new List <Deploy>() { props.Deploy, deploy, lookup }; var d = fromProps.Where(x => x != null).Aggregate((deploy1, deploy2) => deploy2.WithFallback(deploy1)); var p = props.WithRouter(d.RouterConfig); if (!system.Dispatchers.HasDispatcher(p.Dispatcher)) { throw new ConfigurationException(string.Format("Dispatcher [{0}] not configured for routees of path {1}", p.Dispatcher, path)); } if (!system.Dispatchers.HasDispatcher(d.RouterConfig.RouterDispatcher)) { throw new ConfigurationException(string.Format("Dispatcher [{0}] not configured for router of path {1}", p.RouterConfig.RouterDispatcher, path)); } var routerProps = Props.Empty.WithRouter(p.Deploy.RouterConfig).WithDispatcher(p.RouterConfig.RouterDispatcher); var routeeProps = props.WithRouter(RouterConfig.NoRouter); try { // routers use context.actorOf() to create the routees, which does not allow us to pass // these through, but obtain them here for early verification var routerDispatcher = system.Dispatchers.Lookup(props.RouterConfig.RouterDispatcher); var routerMailbox = _system.Mailboxes.CreateMailbox(props, null); var routedActorRef = new RoutedActorRef(system, routerProps, routerDispatcher, () => routerMailbox, routeeProps, supervisor, path); routedActorRef.Initialize(async); return(routedActorRef); } catch (Exception) { throw new ConfigurationException(string.Format("Configuration problem while creating [{0}] with router dispatcher [{1}] and mailbox {2}" + " and routee dispatcher [{3}] and mailbox [{4}].", path, routerProps.Dispatcher, routerProps.Mailbox, routeeProps.Dispatcher, routeeProps.Mailbox)); } } }
public TestActorCell(ActorSystemImpl system, InternalActorRef self, Props props, MessageDispatcher dispatcher, InternalActorRef parent) : base(system, self, props, dispatcher, parent) { }
public InternalActorRef ActorOf(ActorSystemImpl system, Props props, InternalActorRef supervisor, ActorPath path, bool systemService, Deploy deploy, bool lookupDeploy, bool async) { //TODO: This does not match Akka's ActorOf at all Deploy configDeploy = _system.Provider.Deployer.Lookup(path); 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 (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"); } //TODO: how should this be dealt with? //akka simply passes the "deploy" var from remote daemon to ActorOf //so it atleast seems like they ignore if remote scope is provided here. //leaving this for now since it does work //if (props.Deploy != null && props.Deploy.Scope is RemoteScope) //{ // throw new NotSupportedException("LocalActorRefProvider can not deploy remote"); //} if (props.RouterConfig is NoRouter || props.RouterConfig == null) { props = props.WithDeploy(deploy); var dispatcher = system.Dispatchers.FromConfig(props.Dispatcher); var mailbox = _system.Mailboxes.FromConfig(props.Mailbox); //TODO: Should be: system.mailboxes.getMailboxType(props2, dispatcher.configurator.config) if (async) { var reActorRef = new RepointableActorRef(system, props, dispatcher, () => mailbox, supervisor, path); reActorRef.Initialize(async: true); return(reActorRef); } return(new LocalActorRef(system, props, dispatcher, () => mailbox, supervisor, path)); } else { //if no Router config value was specified, override with procedural input if (deploy.RouterConfig is NoRouter) { deploy = deploy.WithRouterConfig(props.RouterConfig); } var routerDispatcher = system.Dispatchers.FromConfig(props.RouterConfig.RouterDispatcher); var routerMailbox = _system.Mailboxes.FromConfig(props.Mailbox); //TODO: Should be val routerMailbox = system.mailboxes.getMailboxType(routerProps, routerDispatcher.configurator.config) // routers use context.actorOf() to create the routees, which does not allow us to pass // these through, but obtain them here for early verification var routerProps = Props.Empty.WithDeploy(deploy); var routeeProps = props.WithRouter(RouterConfig.NoRouter); var routedActorRef = new RoutedActorRef(system, routerProps, routerDispatcher, () => routerMailbox, routeeProps, supervisor, path); routedActorRef.Initialize(async); return(routedActorRef); } }
public RoutedActorCell(ActorSystemImpl system, IInternalActorRef self, Props routerProps, MessageDispatcher dispatcher, Props routeeProps, IInternalActorRef supervisor) : base(system, self, routerProps, dispatcher, supervisor) { _routeeProps = routeeProps; _routerConfig = routerProps.RouterConfig; }
/// <summary> /// Initializes a new instance of the <see cref="RemoteSystemDaemon" /> class. /// </summary> /// <param name="system">The system.</param> /// <param name="path">The path.</param> /// <param name="parent">The parent.</param> /// <param name="terminator"></param> /// <param name="log"></param> public RemoteSystemDaemon(ActorSystemImpl system, ActorPath path, IInternalActorRef parent,IActorRef terminator, ILoggingAdapter log) : base(system.Provider, path, parent, log) { _terminator = terminator; _system = system; AddressTerminatedTopic.Get(system).Subscribe(this); }
public void Init(ActorSystemImpl system) { _localActorRefProvider.Init(system); }