public CountDownActor(CountdownEvent restartsCountdown, SupervisorStrategy supervisorStrategy)
 {
     _restartsCountdown = restartsCountdown;
     _supervisorStrategy = supervisorStrategy;
     Receive<Props>(p => Sender.Tell(Context.ActorOf(p)));
     Receive<PropsWithName>(p => Sender.Tell(Context.ActorOf(p.Props, p.Name)));
 }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RandomPool"/> class.
 /// </summary>
 /// <param name="nrOfInstances">The initial number of routees in the pool.</param>
 /// <param name="resizer">The resizer to use when dynamically allocating routees to the pool.</param>
 /// <param name="supervisorStrategy">The strategy to use when supervising the pool.</param>
 /// <param name="routerDispatcher">The dispatcher to use when passing messages to the routees.</param>
 /// <param name="usePoolDispatcher"><c>true</c> to use the pool dispatcher; otherwise <c>false</c>.</param>
 public RandomPool(
     int nrOfInstances,
     Resizer resizer,
     SupervisorStrategy supervisorStrategy,
     string routerDispatcher,
     bool usePoolDispatcher = false)
     : base(nrOfInstances, resizer, supervisorStrategy, routerDispatcher, usePoolDispatcher)
 {
 }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RouterPoolActor"/> class.
        /// </summary>
        /// <param name="supervisorStrategy">The supervisor strategy.</param>
        /// <exception cref="ActorInitializationException"></exception>
        public RouterPoolActor(SupervisorStrategy supervisorStrategy)
        {
            _supervisorStrategy = supervisorStrategy;

            var pool = Cell.RouterConfig as Pool;
            if (pool != null)
            {
                Pool = pool;
            }
            else
            {
                throw new ActorInitializationException($"RouterPoolActor can only be used with Pool, not {Cell.RouterConfig.GetType()}");
            }
        }
        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;

        }
Exemplo n.º 5
0
        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;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Creates an actor using a specified lambda expression.
        /// </summary>
        /// <typeparam name="TActor">The type of the actor to create.</typeparam>
        /// <param name="factory">The lambda expression used to create the actor.</param>
        /// <param name="supervisorStrategy">Optional: The supervisor strategy used to manage the actor.</param>
        /// <returns>The newly created <see cref="Akka.Actor.Props" />.</returns>
        /// <exception cref="ArgumentException">The create function must be a 'new T (args)' expression</exception>
        public static Props Create <TActor>(Expression <Func <TActor> > factory, SupervisorStrategy supervisorStrategy = null) where TActor : ActorBase
        {
            if (factory.Body is UnaryExpression)
            {
                return(new DynamicProps <TActor>(factory.Compile()));
            }

            var newExpression = factory.Body.AsInstanceOf <NewExpression>();

            if (newExpression == null)
            {
                throw new ArgumentException("The create function must be a 'new T (args)' expression");
            }

            object[] args = newExpression.GetArguments().ToArray();

            return(new Props(typeof(TActor), supervisorStrategy, args));
        }
Exemplo n.º 7
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="systemName">TBD</param>
        /// <param name="settings">TBD</param>
        /// <param name="eventStream">TBD</param>
        /// <param name="deployer">TBD</param>
        /// <param name="deadLettersFactory">TBD</param>
        public LocalActorRefProvider(string systemName, Settings settings, EventStream eventStream, Deployer deployer, Func <ActorPath, IInternalActorRef> 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");
            IgnoreRef    = new IgnoreActorRef(this);

            _tempNumber = new AtomicCounterLong(1);
            _tempNode   = _rootPath / "temp";

            _systemGuardianStrategy           = SupervisorStrategy.DefaultStrategy;
            _userGuardianStrategyConfigurator = SupervisorStrategyConfigurator.CreateConfigurator(Settings.SupervisorStrategyClass);
        }
Exemplo n.º 8
0
 public Supervisor(SupervisorStrategy supervisorStrategy)
 {
     _supervisorStrategy = supervisorStrategy;
 }
Exemplo n.º 9
0
        public LocalActorRefProvider(string systemName, Settings settings, EventStream eventStream, Deployer deployer, Func<ActorPath, IInternalActorRef> 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";

            _systemGuardianStrategy = SupervisorStrategy.DefaultStrategy;
            _userGuardianStrategyConfigurator = SupervisorStrategyConfigurator.CreateConfigurator(Settings.SupervisorStrategyClass);
        }
 /// <summary>
 /// Sets the supervisor strategy to use for the pool.
 /// </summary>
 /// <param name="strategy">The strategy to use.</param>
 /// <returns>The tail chopping pool.</returns>
 public TailChoppingPool WithSupervisorStrategy(SupervisorStrategy strategy)
 {
     SupervisorStrategy = strategy;
     return this;
 }
Exemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TailChoppingPool"/> class.
 /// </summary>
 /// <param name="nrOfInstances">The initial number of routees in the pool.</param>
 /// <param name="resizer">The resizer to use when dynamically allocating routees to the pool.</param>
 /// <param name="supervisorStrategy">The strategy to use when supervising the pool.</param>
 /// <param name="routerDispatcher">The dispatcher to use when passing messages to the routees.</param>
 /// <param name="within">The amount of time to wait for a response.</param>
 /// <param name="interval">The interval to wait before sending to the next routee.</param>
 /// <param name="usePoolDispatcher"><c>true</c> to use the pool dispatcher; otherwise <c>false</c>.</param>
 public TailChoppingPool(int nrOfInstances, Resizer resizer, SupervisorStrategy supervisorStrategy, string routerDispatcher, TimeSpan within, TimeSpan interval, bool usePoolDispatcher = false)
     : base(nrOfInstances, resizer, supervisorStrategy, routerDispatcher, usePoolDispatcher)
 {
     Within = within;
     Interval = interval;
 }
Exemplo n.º 12
0
   //     private SupervisorStrategy supervisorStrategy;

        /// <summary>
        /// Initializes a new instance of the <see cref="RouterPoolActor"/> class.
        /// </summary>
        /// <param name="supervisorStrategy">The supervisor strategy.</param>
        public RouterPoolActor(SupervisorStrategy supervisorStrategy)
        {
            this.supervisorStrategy = supervisorStrategy;
        }
 /// <summary>
 /// </summary>
 /// <param name="nrOfInstances">The nr of instances.</param>
 /// <param name="resizer">The resizer.</param>
 /// <param name="supervisorStrategy">The supervisor strategy.</param>
 /// <param name="routerDispatcher">The router dispatcher.</param>
 /// <param name="usePoolDispatcher">if set to <c>true</c> [use pool dispatcher].</param>
 public ScatterGatherFirstCompletedPool(int nrOfInstances, Resizer resizer, SupervisorStrategy supervisorStrategy,
     string routerDispatcher,TimeSpan within, bool usePoolDispatcher = false)
     : base(nrOfInstances, resizer, supervisorStrategy, routerDispatcher, usePoolDispatcher)
 {
     _within = within;
 }
Exemplo n.º 14
0
 public ClusterRouterPoolActor(SupervisorStrategy supervisorStrategy, ClusterRouterPoolSettings settings) : base(settings)
 {
     Settings = settings;
     _supervisorStrategy = supervisorStrategy;
     _pool = (Pool)Cell.RouterConfig;
 }
Exemplo n.º 15
0
 /// <summary>
 /// Creates a new <see cref="SmallestMailboxPool" /> router with a given <see cref="SupervisorStrategy" />.
 /// 
 /// <note>
 /// This method is immutable and returns a new instance of the router.
 /// </note>
 /// </summary>
 /// <param name="strategy">The <see cref="SupervisorStrategy" /> used to configure the new router.</param>
 /// <returns>A new router with the provided <paramref name="strategy" />.</returns>
 public SmallestMailboxPool WithSupervisorStrategy(SupervisorStrategy strategy)
 {
     return new SmallestMailboxPool(NrOfInstances, Resizer, strategy, RouterDispatcher, UsePoolDispatcher);
 }
Exemplo n.º 16
0
 protected Pool(int nrOfInstances, Resizer resizer, SupervisorStrategy supervisorStrategy, string routerDispatcher,
     bool usePoolDispatcher = false)
 {
     NrOfInstances = nrOfInstances;
     Resizer = resizer;
     SupervisorStrategy = supervisorStrategy ?? Pool.DefaultStrategy;
     UsePoolDispatcher = usePoolDispatcher;
     RouterDispatcher = routerDispatcher;
 }
Exemplo n.º 17
0
        public ClusterRouterPoolActor(SupervisorStrategy supervisorStrategy, ClusterRouterPoolSettings settings) : base(settings)
        {
            _supervisorStrategy = supervisorStrategy;
            Settings = settings;

            var pool = Cell.RouterConfig as Pool;
            if (pool != null)
            {
                Pool = pool;
            }
            else
            {
                throw new ActorInitializationException("RouterPoolActor can only be used with Pool, not " +
                                                       Cell.RouterConfig.GetType());
            }
        }
Exemplo n.º 18
0
   //     private SupervisorStrategy supervisorStrategy;

        /// <summary>
        /// Initializes a new instance of the <see cref="RouterPoolActor"/> class.
        /// </summary>
        /// <param name="supervisorStrategy">The supervisor strategy.</param>
        public RouterPoolActor(SupervisorStrategy supervisorStrategy)
        {
            SupervisorStrategyInternal = supervisorStrategy;
        }
Exemplo n.º 19
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="Props" /> class.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="supervisorStrategy">The supervisor strategy.</param>
 /// <param name="args">The arguments.</param>
 public Props(Type type, SupervisorStrategy supervisorStrategy, IEnumerable <object> args)
     : this(defaultDeploy, type, args.ToArray())
 {
     SupervisorStrategy = supervisorStrategy;
 }
Exemplo n.º 20
0
 public override Pool WithSupervisorStrategy(SupervisorStrategy strategy)
 {
     return new RemoteRouterConfig(Local.WithSupervisorStrategy(strategy), Nodes);
 }
Exemplo n.º 21
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="Props" /> class.
 /// </summary>
 /// <param name="type">The type.</param>
 /// <param name="supervisorStrategy">The supervisor strategy.</param>
 /// <param name="args">The arguments.</param>
 public Props(Type type, SupervisorStrategy supervisorStrategy, params object[] args)
     : this(defaultDeploy, type, args)
 {
     SupervisorStrategy = supervisorStrategy;
 }
 /// <summary>
 /// Creates a new <see cref="ScatterGatherFirstCompletedPool" /> router with a given <see cref="SupervisorStrategy" />.
 /// 
 /// <note>
 /// This method is immutable and returns a new instance of the router.
 /// </note>
 /// </summary>
 /// <param name="strategy">The <see cref="SupervisorStrategy" /> used to configure the new router.</param>
 /// <returns>A new router with the provided <paramref name="strategy" />.</returns>
 public override Pool WithSupervisorStrategy(SupervisorStrategy strategy)
 {
     return new ScatterGatherFirstCompletedPool(NrOfInstances, Resizer, strategy, RouterDispatcher, _within, UsePoolDispatcher);
 }
Exemplo n.º 23
0
 public override Pool WithSupervisorStrategy(SupervisorStrategy strategy)
 {
     return new BroadcastPool(NrOfInstances, Resizer, strategy, RouterDispatcher, UsePoolDispatcher);
 }
Exemplo n.º 24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConsistentHashingPool"/> class.
 /// </summary>
 /// <param name="nrOfInstances">The initial number of routees in the pool.</param>
 /// <param name="resizer">The resizer to use when dynamically allocating routees to the pool.</param>
 /// <param name="supervisorStrategy">The strategy to use when supervising the pool.</param>
 /// <param name="routerDispatcher">The dispatcher to use when passing messages to the routees.</param>
 /// <param name="usePoolDispatcher"><c>true</c> to use the pool dispatcher; otherwise <c>false</c>.</param>
 /// <param name="virtualNodesFactor">The number of virtual nodes to use on the hash ring.</param>
 /// <param name="hashMapping">The consistent hash mapping function to use on incoming messages.</param>
 public ConsistentHashingPool(
     int nrOfInstances,
     Resizer resizer,
     SupervisorStrategy supervisorStrategy,
     string routerDispatcher,
     bool usePoolDispatcher = false,
     int virtualNodesFactor = 0,
     ConsistentHashMapping hashMapping = null)
     : base(nrOfInstances, resizer, supervisorStrategy, routerDispatcher, usePoolDispatcher)
 {
     VirtualNodesFactor = virtualNodesFactor;
     _hashMapping = hashMapping;
 }
Exemplo n.º 25
0
   //     private SupervisorStrategy supervisorStrategy;

        public ResizablePoolActor(SupervisorStrategy supervisorStrategy)
        {
            this.supervisorStrategy = supervisorStrategy;
        }
Exemplo n.º 26
0
   //     private SupervisorStrategy supervisorStrategy;

        public ResizablePoolActor(SupervisorStrategy supervisorStrategy)
        {
            SupervisorStrategyInternal = supervisorStrategy;
        }
Exemplo n.º 27
0
 /// <summary>
 /// Creates a new <see cref="TailChoppingPool"/> router with a given <see cref="SupervisorStrategy"/>.
 /// 
 /// <note>
 /// This method is immutable and returns a new instance of the router.
 /// </note>
 /// </summary>
 /// <param name="strategy">The <see cref="SupervisorStrategy"/> used to configure the new router.</param>
 /// <returns>A new router with the provided <paramref name="strategy"/>.</returns>
 public TailChoppingPool WithSupervisorStrategy(SupervisorStrategy strategy)
 {
     return new TailChoppingPool(NrOfInstances, Resizer, strategy, RouterDispatcher, Within, Interval, UsePoolDispatcher);
 }
Exemplo n.º 28
0
 public Supervisor(SupervisorStrategy supervisorStrategy)
 {
     this.supervisorStrategy = supervisorStrategy;
 }
Exemplo n.º 29
0
 /// <summary>
 /// Creates an actor using a specified supervisor strategy.
 /// </summary>
 /// <typeparam name="TActor">The type of the actor to create.</typeparam>
 /// <param name="supervisorStrategy">The supervisor strategy used to manage the actor.</param>
 /// <returns>The newly created <see cref="Akka.Actor.Props" />.</returns>
 public static Props Create <TActor>(SupervisorStrategy supervisorStrategy) where TActor : ActorBase, new()
 {
     return(new Props(typeof(TActor), supervisorStrategy));
 }
Exemplo n.º 30
0
 /// <summary>
 /// Creates a new <see cref="RoundRobinPool"/> router with a given <see cref="SupervisorStrategy"/>.
 /// <note>
 /// This method is immutable and returns a new instance of the router.
 /// </note>
 /// </summary>
 /// <param name="strategy">The <see cref="SupervisorStrategy"/> used to configure the new router.</param>
 /// <returns>A new router with the provided <paramref name="strategy"/>.</returns>
 public RoundRobinPool WithSupervisorStrategy(SupervisorStrategy strategy)
 {
     return new RoundRobinPool(NrOfInstances, Resizer, strategy, RouterDispatcher, UsePoolDispatcher);
 }
Exemplo n.º 31
0
 /// <summary>
 /// Creates a new <see cref="ConsistentHashingPool" /> router with a given <see cref="SupervisorStrategy" />.
 /// <note>
 /// This method is immutable and returns a new instance of the router.
 /// </note>
 /// </summary>
 /// <param name="strategy">The <see cref="SupervisorStrategy" /> used to configure the new router.</param>
 /// <returns>A new router with the provided <paramref name="strategy" />.</returns>
 public ConsistentHashingPool WithSupervisorStrategy(SupervisorStrategy strategy)
 {
     return new ConsistentHashingPool(NrOfInstances, Resizer, strategy, RouterDispatcher, UsePoolDispatcher,
         VirtualNodesFactor, _hashMapping);
 }
Exemplo n.º 32
0
        //     private SupervisorStrategy supervisorStrategy;

        public ResizablePoolActor(SupervisorStrategy supervisorStrategy) : base(supervisorStrategy)
        {
        }