Exemplo n.º 1
0
 public void ProcSystemActorRestartedByException(Exception e, ActorRef act)
 {
     this.ex = e;
     this.Act = act;
     mname = "ProcSystemActorRestartedByException";
     setted = true;
 }
        public SubscriptionRouterService(IServiceBus bus, SubscriptionRepository repository, string network)
        {
            _peerUri = bus.ControlBus.Endpoint.Address.Uri;

            _repository = repository;
            _network = network;

            _peerId = NewId.NextGuid();

            _observers = new List<SubscriptionObserver>();
            _listeners = new List<BusSubscriptionEventListener>();

            _unregister = () => true;

            _peerUri = bus.ControlBus.Endpoint.Address.Uri;

            var connector = new BusSubscriptionConnector(bus);

            _peerCache = ActorFactory.Create<PeerCache>(x =>
                {
                    x.ConstructedBy((fiber, scheduler, inbox) =>
                                    new PeerCache(connector, _peerId, _peerUri, repository));
                    x.UseSharedScheduler();
                    x.HandleOnPoolFiber();
                })
                .GetActor();

            // at this point, existing subscriptions need to be loaded...

            _repository.Load(this);
        }
		public SubscriptionRouterService(IServiceBus bus, string network)
		{
			_peerUri = bus.ControlBus.Endpoint.Address.Uri;

			_network = network;

			_peerId = CombGuid.Generate();

			_observers = new List<SubscriptionObserver>();
			_listeners = new List<BusSubscriptionEventListener>();

			_unregister = () => true;

			_peerUri = bus.ControlBus.Endpoint.Address.Uri;

			var connector = new BusSubscriptionConnector(bus);

			_peerCache = ActorFactory.Create<PeerCache>(x =>
				{
					x.ConstructedBy((fiber, scheduler, inbox) =>
					                new PeerCache(fiber, scheduler, connector, _peerId, _peerUri));
					x.UseSharedScheduler();
					x.HandleOnPoolFiber();
				})
				.GetActor();
		}
Exemplo n.º 4
0
 public void ProcPostStopException(Exception e, ActorRef act)
 {
     this.ex = e;
     this.Act = act;
     mname = "ProcPostStopException";
     setted = true;
 }
Exemplo n.º 5
0
        public void Show(ActorRef actor)
        {
            var inbox = actor as ActorInbox;
            if (inbox == null)
                return;

            Trace.WriteLine(new StringRoutingEngineVisitor(inbox.Engine).ToString());
        }
Exemplo n.º 6
0
 void Ilogger.ProcPostStopException(Exception e, ActorRef act)
 {
     string s = "";
     s += "Exception in PostStop procedure\n";
     s += String.Format("In: {0}\n", act.FullName);
     s += String.Format("Exception: {0}\n", e);
     Printf(s);
 }
Exemplo n.º 7
0
 void Ilogger.ProcSystemActorRestartedByException(Exception e, ActorRef act)
 {
     string s = "";
     s += "System actor has been restarted by exception\n";
     s += String.Format("Actor: {0}\n", act.FullName);
     s += String.Format("Exception: {0}\n", e);
     Printf(s);
 }
Exemplo n.º 8
0
 void Ilogger.ProcUserActorStoppedByException(Exception e, ActorRef act)
 {
     string s = "";
     s += "User actor has been stopped by exception\n";
     s += String.Format("Actor: {0}\n", act.FullName);
     s += String.Format("Exception: {0}\n", e);
     Printf(s);
 }
Exemplo n.º 9
0
 public override Task OnActivate()
 {
     hub = HubGateway.GetLocalHub();
     
     Timers.Register("flush", flushPeriod, flushPeriod, Flush);
     
     return base.OnActivate();
 }
Exemplo n.º 10
0
        void AssertReminderScheduled(ActorRef api)
        {
            var scheduled = Reminder(api.Path.Id);

            IsTrue(()=> scheduled.Id == api.Path.Id);
            IsTrue(()=> scheduled.Due == TimeSpan.Zero);
            IsTrue(()=> scheduled.Period == schedule[api]);
        }
Exemplo n.º 11
0
 public void ProcNotHandledMsg(ActorRef Sender, object[] args, Type ReturnType, ActorRef act)
 {
     this.Sender = Sender;
     this.args = args;
     this.ReturnType = ReturnType;
     this.Act = act;
     mname = "ProcNotHandledMsg";
     setted = true;
 }
Exemplo n.º 12
0
 public ActorCore()
 {
     RootActor = CreateActorEx(new ActorInstanceGenerator(typeof(Actors.RootActor)), null, "");
     //UserActor_ = CreateActor(new ActorInstanceGenerator(typeof(Actors.UserActor)), RootActor, "user");
     //var SystemActor = CreateActor(new ActorInstanceGenerator(typeof(Actors.SystemActor)), RootActor, "system");
     //LogActor = CreateActor(new ActorInstanceGenerator(typeof(Log.LogActor)), RootActor, "log");
     UserActor_ = FindActorByPath("\\user");
     LogActor = FindActorByPath("\\system\\log");
 }
Exemplo n.º 13
0
        static async Task Print(ActorRef item)
        {
            var details = await item.Ask(new GetInventoryItemDetails());

            Console.WriteLine("{0}: {1} {2}",
                                details.Name,
                                details.Total,
                                details.Active ? "" : "(deactivated)");
        }
Exemplo n.º 14
0
 public void ProcMsgInStoppedActor(ActorRef Sender, object[] args, Type ReturnType, ActorRef act)
 {
     this.Sender = Sender;
     this.args = args;
     this.ReturnType = ReturnType;
     this.Act = act;
     mname = "ProcMsgInStoppedActor";
     setted = true;
 }
Exemplo n.º 15
0
 public Message(Guid id, ActorRef sender, ActorRef receiver, string contract, MessageType type, Type responseType, object[] args)
 {
     Id = id;
     Sender = sender;
     Type = type;
     Contract = contract;
     Response = responseType;
     Args = args;
 }
 public override ChildrenContainer Remove(ActorRef child)
 {
     var set = _toDie.Remove(child);
     if (set.IsEmpty)
     {
         if (_reason is SuspendReason.Termination) return TerminatedChildrenContainer.Instance;
         return NormalChildrenContainer.Create(InternalChildren.Remove(child.Path.Name));
     }
     return new TerminatingChildrenContainer(InternalChildren.Remove(child.Path.Name), set, _reason);
 }
Exemplo n.º 17
0
        public void Equatable_by_path()
        {
            var path = ActorPath.From("T", "42");

            var ref1 = new ActorRef(path);
            var ref2 = new ActorRef(path);
            
            Assert.True(ref1 == ref2);
            Assert.True(ref1.Equals(ref2));
        }
Exemplo n.º 18
0
        public void Run(int nodeCount, int roundCount)
        {
            _complete = new Future<bool>();
            _first = _ringNodeFactory.GetActor();
            _first.Request(new Init
                {
                    NodeCount = nodeCount - 1,
                    RoundCount = roundCount,
                }, _first);

            _complete.WaitUntilCompleted(300.Seconds());
        }
Exemplo n.º 19
0
 public void ProcMsgInStoppedActor(string name,Message msg, ActorRef act)
 {
     if (msg is AskMessage)
     {
         var t = (AskMessage)msg;
         logger.ProcMsgInStoppedActor(t.Sender, t.args, t.ReturnType, act);
         return;
     }
     if (msg is TellMessage)
     {
         var t = (TellMessage)msg;
         logger.ProcMsgInStoppedActor(t.Sender, t.args, null, act);
     }
 }
Exemplo n.º 20
0
 void Ilogger.ProcNotHandledMsg(ActorRef Sender, object[] args, Type ReturnType, ActorRef act)
 {
     string s = "";
     s += "Message has no handler in actor \n";
     s += String.Format("From: {0}\n", Sender.FullName);
     s += String.Format("To: {0}\n", act.FullName);
     s += String.Format("Return type: {0}\n", ReturnType != null ? ReturnType.ToString() : "null");
     for (int i = 0; i < args.Length; i++)
     {
         s += String.Format("Argument {0} : Type = {1}, Value = {2}\n",
             i, args[i].GetType(), args[i]);
     }
     Printf(s);
 }
Exemplo n.º 21
0
 public void ProcNotHandledMsg(string name, Message msg, ActorRef act)
 {
     //LogActor.Tell("ProcNotHandledMsg", msg, act);
     if (msg is AskMessage)
     {
         var t = (AskMessage)msg;
         logger.ProcNotHandledMsg(t.Sender, t.args, t.ReturnType, act);
         return;
     }
     if (msg is TellMessage)
     {
         var t = (TellMessage)msg;
         logger.ProcNotHandledMsg(t.Sender, t.args, null, act);
     }
 }
Exemplo n.º 22
0
 public bool TryGetByRef(ActorRef actor, out ChildRestartStats childRestartStats)
 {
     ChildStats stats;
     if (InternalChildren.TryGet(actor.Path.Name, out stats))
     {
         //Since the actor exists, ChildRestartStats is the only valid ChildStats.
         var crStats = stats as ChildRestartStats;
         if (crStats != null && actor.Equals(crStats.Child))
         {
             childRestartStats = crStats;
             return true;
         }
     }
     childRestartStats = null;
     return false;
 }
Exemplo n.º 23
0
		public void When_two_actors_are_linked()
		{
			_a = AnonymousActor.New(inbox =>
			{
				inbox.Receive<Die>(x =>
				{
					inbox.Exit();
				});
			});

			_b = AnonymousActor.New(inbox =>
			{
				_a.Link(inbox);

				inbox.Receive<Die>(x =>
				{
				});
			});
		}
Exemplo n.º 24
0
        public void An_exit_is_sent_to_an_actor_that_intercepts_exit()
        {
            _intercepted = new Future<Exit>();
            _receivedA = new Future<A>();

            _actor = AnonymousActor.New(inbox =>
            {
                inbox.Receive<Request<Exit>>(request =>
                {
                    _intercepted.Complete(request.Body);
                    request.Respond(request.Body);
                });

                inbox.Receive<A>(message =>
                {
                    _receivedA.Complete(message);
                });
            });
        }
Exemplo n.º 25
0
 public abstract ChildrenContainer ShallDie(ActorRef actor);
 void IActor.Init(IActorSystem system, ActorRef actorRef)
 {
     MySystem = system;
     ActorRef = actorRef;
     OnInitialise();
 }
Exemplo n.º 27
0
 public StartTail(string filePath, ActorRef reporterActor)
 {
     FilePath      = filePath;
     ReporterActor = reporterActor;
 }
Exemplo n.º 28
0
 protected Terminated expectTerminated(ActorRef @ref, TimeSpan timeout)
 {
     return(ExpectTerminated(@ref, timeout));
 }
Exemplo n.º 29
0
 /// <summary>
 ///     Publishes the specified event.
 /// </summary>
 /// <param name="event">The event.</param>
 /// <param name="subscriber">The subscriber.</param>
 protected override void Publish(object @event, ActorRef subscriber)
 {
     subscriber.Tell(@event);
 }
 public override ChildrenContainer ShallDie(ActorRef actor)
 {
     return(new TerminatingChildrenContainer(InternalChildren, _toDie.Add(actor), _reason));
 }
Exemplo n.º 31
0
 public bool IsReadOnly(ActorRef endpoint)
 {
     return(readonlyToAddress.ContainsKey(endpoint));
 }
Exemplo n.º 32
0
 public bool IsWritable(ActorRef endpoint)
 {
     return(writableToAddress.ContainsKey(endpoint));
 }
 public PerformanceCounterCoordinatorActor(ActorRef chartingActor) : this(chartingActor, new Dictionary <CounterType, ActorRef>())
 {
 }
Exemplo n.º 34
0
 /// <summary>
 /// Have the <see cref="TestActor"/> stop watching an actor.
 /// </summary>
 /// <param name="actorToUnwatch">The actor to unwatch.</param>
 /// <returns>The actor to unwatch, i.e. the parameter <paramref name="actorToUnwatch"/></returns>
 public ActorRef Unwatch(ActorRef actorToUnwatch)
 {
     _testActor.Tell(new TestActor.Unwatch(actorToUnwatch));
     return(actorToUnwatch);
 }
Exemplo n.º 35
0
 /// <summary>
 /// Have the <see cref="TestActor"/> watch an actor and receive
 /// <see cref="Terminated"/> messages when the actor terminates.
 /// </summary>
 /// <param name="actorToWatch">The actor to watch.</param>
 /// <returns>The actor to watch, i.e. the parameter <paramref name="actorToWatch"/></returns>
 public ActorRef Watch(ActorRef actorToWatch)
 {
     _testActor.Tell(new TestActor.Watch(actorToWatch));
     return(actorToWatch);
 }
Exemplo n.º 36
0
 public SendEventImpl(ActorRef tBrokerAct)
 {
     _tBrokerAct = tBrokerAct;
 }
Exemplo n.º 37
0
 public ChatClient(IActorSystem system, string user, string room)
 {
     this.user = system.ActorOf <ChatUser>(user);
     this.room = system.StreamOf <SimpleMessageStreamProvider>(room);
 }
Exemplo n.º 38
0
 public bool Contains(ActorRef actor)
 {
     ChildRestartStats stats;
     return TryGetByRef(actor, out stats);
 }
Exemplo n.º 39
0
		public ActorRegisteredImpl(ActorRegistry registry, ActorRef actor, Guid key)
		{
			Registry = registry;
			Instance = actor;
			Key = key;
		}
Exemplo n.º 40
0
 /// <summary>
 /// Directly inject messages into actor receive behavior. Any exceptions
 /// thrown will be available to you, while still being able to use
 /// become/unbecome.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="sender">The sender.</param>
 public void Receive(object message, ActorRef sender = null)
 {
     _internalRef.Receive(message, sender);
 }
Exemplo n.º 41
0
 /// <summary>
 /// Registers this actor to be a death monitor of the provided ActorRef
 /// This means that this actor will get a Terminated()-message when the provided actor
 /// is permanently terminated.
 /// Returns the same ActorRef that is provided to it, to allow for cleaner invocations.
 /// </summary>
 /// <param name="subject">The subject to watch.</param>
 /// <returns>Returns the same ActorRef that is provided to it, to allow for cleaner invocations.</returns>
 public void Watch(ActorRef subject)
 {
     _internalRef.Watch(subject);
 }
Exemplo n.º 42
0
 protected TestActorRefBase(ActorSystem system, Props actorProps, ActorRef supervisor = null, string name = null)
 {
     _internalRef = InternalTestActorRef.Create(system, actorProps, supervisor, name);
 }
 public TerminatingChildrenContainer(IImmutableMap <string, ChildStats> children, ActorRef toDie, SuspendReason reason)
     : this(children, ImmutableTreeSet <ActorRef> .Create(toDie), reason)
 {
     //Intentionally left blank
 }
Exemplo n.º 44
0
 public bool Equals(ActorRef other)
 {
     return(_internalRef.Equals(other));
 }
Exemplo n.º 45
0
 protected void watch(ActorRef @ref)
 {
     Watch(@ref);
 }
Exemplo n.º 46
0
 /// <summary>
 /// Deregisters this actor from being a death monitor of the provided ActorRef
 /// This means that this actor will not get a Terminated()-message when the provided actor
 /// is permanently terminated.
 /// Returns the same ActorRef that is provided to it, to allow for cleaner invocations.
 /// </summary>
 /// <returns>Returns the same ActorRef that is provided to it, to allow for cleaner invocations.</returns>
 /// <param name="subject">The subject to unwatch.</param>
 public void Unwatch(ActorRef subject)
 {
     _internalRef.Unwatch(subject);
 }
Exemplo n.º 47
0
 protected Terminated expectTerminated(ActorRef @ref)
 {
     return(ExpectTerminated(@ref));
 }
Exemplo n.º 48
0
 public KillableActor(ActorRef testActor)
 {
     this.testActor = testActor;
 }
Exemplo n.º 49
0
 public ActorAssociationEventListener(ActorRef actor)
 {
     Actor = actor;
 }
Exemplo n.º 50
0
 public SupervisorTestActor(ActorRef testActor)
 {
     this.testActor = testActor;
 }
Exemplo n.º 51
0
 public abstract ChildrenContainer Remove(ActorRef child);
Exemplo n.º 52
0
 public BecomeActor(ActorRef testActor)
 {
     this.testActor = testActor;
 }
Exemplo n.º 53
0
 public ActorHandleEventListener(ActorRef actor)
 {
     Actor = actor;
 }
Exemplo n.º 54
0
 public RewatchRemote(ActorRef watchee, ActorRef watcher)
     : base(watchee, watcher)
 {
 }
Exemplo n.º 55
0
 public ChatClient(IActorSystem system, string user, string room)
 {
     this.user = system.ActorOf<ChatUser>(user);
     this.room = system.StreamOf("sms", room);
 }
Exemplo n.º 56
0
 protected WatchCommand(ActorRef watchee, ActorRef watcher)
 {
     _watchee = watchee;
     _watcher = watcher;
 }
Exemplo n.º 57
0
 private static string GetActorRefLogSource(ActorRef actorRef)
 {
     return(actorRef.Path.ToString());                   //TODO: Include systems address?
 }
Exemplo n.º 58
0
 /// <summary>
 ///     Tells the internal.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="sender">The sender.</param>
 protected override void TellInternal(object message, ActorRef sender)
 {
     OnReceive(message);
 }
Exemplo n.º 59
0
 public ActorRef RegisterReadOnlyEndpoint(Address address, ActorRef endpoint)
 {
     addressToReadonly.Add(address, endpoint);
     readonlyToAddress.Add(endpoint, address);
     return(endpoint);
 }
Exemplo n.º 60
0
 /// <summary>
 /// Sends a message to this actor with the specified sender.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="sender">The sender</param>
 public void Tell(object message, ActorRef sender)
 {
     _internalRef.Tell(message, sender);
 }