public RecommendationWorkflow(IActorRef viewsRepo, IActorRef videoDetails) { _viewsRepo = viewsRepo; _videoDetails = videoDetails; AcceptingJob(); }
/// <summary> /// Initializes a new instance of the <see cref="DaemonMsgCreate" /> class. /// </summary> /// <param name="props">The props.</param> /// <param name="deploy">The deploy.</param> /// <param name="path">The path.</param> /// <param name="supervisor">The supervisor.</param> public DaemonMsgCreate(Props props, Deploy deploy, string path, IActorRef supervisor) { Props = props; Deploy = deploy; Path = path; Supervisor = supervisor; }
public Pass(IActorRef endpoint, int? uid, int? refuseUid) : base(false) { Uid = uid; Endpoint = endpoint; RefuseUid = refuseUid; }
protected override void PreStart() { var errorSelector = Context.ActorSelection(ClientActorPaths.ErrorDialogActor.Path) .ResolveOne(TimeSpan.FromSeconds(1)); _errorActor = errorSelector.Result; var settingsSelector = Context.ActorSelection(ClientActorPaths.SettingsActor.Path) .ResolveOne(TimeSpan.FromSeconds(1)); _settingsActor = settingsSelector.Result; var clientsSelector = Context.ActorSelection(ClientActorPaths.ClientsActor.Path) .ResolveOne(TimeSpan.FromSeconds(1)); _clientsActor = clientsSelector.Result; _messagingActor = Context.ActorSelection(ClientActorPaths.ChatMessageRouter.Path) .ResolveOne(TimeSpan.FromSeconds(1)) .Result; Become(Disconnected); base.PreStart(); }
private void Main_Load(object sender, EventArgs e) { _chartActor = Program.ChartActors.ActorOf(Props.Create(() => new ChartingActor(sysChart, btnPauseResume)), "charting"); _chartActor.Tell(new ChartingActor.InitializeChart(null)); //no initial series _coordinatorActor = Program.ChartActors.ActorOf(Props.Create(() => new PerformanceCounterCoordinatorActor(_chartActor)), "counters"); // CPU button toggle actor _toggleActors[CounterType.Cpu] = Program.ChartActors.ActorOf( Props.Create(() => new ButtonToggleActor(_coordinatorActor, btnCPU, CounterType.Cpu, false)) .WithDispatcher("akka.actor.synchronized-dispatcher")); // MEMORY button toggle actor _toggleActors[CounterType.Memory] = Program.ChartActors.ActorOf( Props.Create(() => new ButtonToggleActor(_coordinatorActor, btnMemory, CounterType.Memory, false)) .WithDispatcher("akka.actor.synchronized-dispatcher")); // DISK button toggle actor _toggleActors[CounterType.Disk] = Program.ChartActors.ActorOf( Props.Create(() => new ButtonToggleActor(_coordinatorActor, btnDisk, CounterType.Disk, false)) .WithDispatcher("akka.actor.synchronized-dispatcher")); // Set the CPU toggle to ON so we start getting some data _toggleActors[CounterType.Cpu].Tell(new ButtonToggleActor.Toggle()); }
// ReSharper disable ConvertToLambdaExpression public DeadLettersEventFilterTests() : base("akka.loglevel=ERROR") { _deadActor = Sys.ActorOf(BlackHoleActor.Props, "dead-actor"); Watch(_deadActor); Sys.Stop(_deadActor); ExpectTerminated(_deadActor); }
public ClusterMetricsCollector(IActorRef publisher) { _publisher = publisher; _cluster = Cluster.Get(Context.System); Collector = MetricsCollector.Get(Context.System.AsInstanceOf<ExtendedActorSystem>(), _cluster.Settings); LatestGossip = MetricsGossip.Empty; Nodes = ImmutableHashSet.Create<Address>(); _metricsCancelable = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable( _cluster.Settings.PeriodicTasksInitialDelay.Max(_cluster.Settings.MetricsInterval), _cluster.Settings.MetricsInterval, Self, InternalClusterAction.MetricsTick.Instance, Self); _gossipCancelable = Context.System.Scheduler.ScheduleTellRepeatedlyCancelable( _cluster.Settings.PeriodicTasksInitialDelay.Max(_cluster.Settings.GossipInterval), _cluster.Settings.GossipInterval, Self, InternalClusterAction.GossipTick.Instance, Self); Receive<InternalClusterAction.GossipTick>(tick => Gossip()); Receive<InternalClusterAction.MetricsTick>(tick => Collect()); Receive<MetricsGossipEnvelope>(envelope => ReceiveGossip(envelope)); Receive<ClusterEvent.CurrentClusterState>(state => ReceiveState(state)); Receive<ClusterEvent.MemberUp>(up => AddMember(up.Member)); Receive<ClusterEvent.MemberRemoved>(removed => RemoveMember(removed.Member)); Receive<ClusterEvent.MemberExited>(exited => RemoveMember(exited.Member)); Receive<ClusterEvent.UnreachableMember>(member => RemoveMember(member.Member)); Receive<ClusterEvent.ReachableMember>(member => { if (member.Member.Status == MemberStatus.Up) AddMember(member.Member); }); Receive<ClusterEvent.IMemberEvent>(@event => { }); //not interested in other types of member event }
private void ForwardMessages(BufferedMessages messages, IActorRef recipient) { messages.ForEach(c => { recipient.Tell(c.Key, c.Value); }); }
public FileObserver(IActorRef tailActor, string absoluteFilePath) { _tailActor = tailActor; _absoluteFilePath = absoluteFilePath; _fileDir = Path.GetDirectoryName(absoluteFilePath); _fileNameOnly = Path.GetFileName(absoluteFilePath); }
protected override void PreStart() { var notifierProp = Context.DI().Props<NotificationActor>(); _notifierActor = Context.ActorOf(notifierProp); base.PreStart(); }
public StockActor(string stockSymbol) { _stockSymbol = stockSymbol; _subscribers = new HashSet<IActorRef>(); _priceLookupChild = Context.ActorOf(Context.DI().Props<StockPriceLookupActor>()); Receive<SubscribeToNewStockPricesMessage>(message => _subscribers.Add(message.Subscriber)); Receive<UnSubscribeFromNewStockPricesMessage>(message => _subscribers.Remove(message.Subscriber)); Receive<RefreshStockPriceMessage>(message => _priceLookupChild.Tell(message)); Receive<UpdatedStockPriceMessage>(message => { _stockPrice = message.Price; var stockPriceMessage = new StockPriceMessage(_stockSymbol, _stockPrice, message.Date); foreach (var subscriber in _subscribers) { subscriber.Tell(stockPriceMessage); } }); }
public EchoConnectionHandler(EndPoint remote, IActorRef connection) { // we want to know when the connection dies (without using Tcp.ConnectionClosed) Context.Watch(connection); Receive<Tcp.Received>(received => { var text = Encoding.UTF8.GetString(received.Data.ToArray()).Trim(); Console.WriteLine("Received '{0}' from remote address [{1}]", text, remote); if (text == "exit") Context.Stop(Self); else Sender.Tell(Tcp.Write.Create(received.Data)); }); Receive<Tcp.ConnectionClosed>(closed => { Console.WriteLine("Stopped, remote connection [{0}] closed", remote); Context.Stop(Self); }); Receive<Terminated>(terminated => { Console.WriteLine("Stopped, remote connection [{0}] died", remote); Context.Stop(Self); }); }
protected override void PostStop() { Context.Stop(_notifierActor); _notifierActor = null; base.PostStop(); }
public RoomActor(long id, string name, IActorRef roomAccess, IActorRef messageAccess, ICanTell signalR) { _roomId =id; _name = name; _users = new Dictionary<long, User>(); _roomAccess = roomAccess; _messageAccess = messageAccess; _signalR = signalR; Receive<UsersInRoomMessage>(message => { message.Users.ForEach(user => { _users.Add(user.Id, user); }); _log.Info("RoomActor-" + _name + " established"); Become(Established); }); Receive<FailedToGetUsersInRoomMessage>(message => { _log.Error("FailedToGetUsersInRoomMessage-" + _roomId + ": " + message.Message); ScheduleUserLoading(TimeSpan.FromSeconds(30)); }); ReceiveAny(x => Stash.Stash()); }
static void Main(string[] args) { var section = (AkkaConfigurationSection)ConfigurationManager.GetSection("akka"); _system = ActorSystem.Create("test", section.AkkaConfig); _coordinator = _system.ActorOf(Props.Create(() => new IdentityActor()) .WithRouter(FromConfig.Instance), "fred"); //_coordinator = // _system.ActorOf(Props.Create(() => new IdentityActor()).WithRouter(new ConsistentHashingPool(5000)), // "fred2"); int routees = _coordinator.Ask<Routees>(new GetRoutees()).Result.Members.Count(); Console.WriteLine(routees); // Lazy wait for the co-ordinator to deploy. Thread.Sleep(5000); for (int i = 1; i <= 5000; i++) { for (int x = 1; x <= 4; x++) { _coordinator.Tell(new EntityMessage<long>(i)); } } Thread.Sleep(500); Console.ReadLine(); }
public API(IActorRef viewsRepo, IActorRef videoDetails) { _viewsRepo = viewsRepo; _videoDetails = videoDetails; Start(); }
public MailInActor(IActorRef commander) { this.commander = commander; Receive<CheckMail>(m => { Console.Write("[MailInActor ]: Checking e-mail inbox ..."); var ex = Helpers.GetRandomInt(CalcConfig.NetworkExceptionChance); if (ex == 2) { throw new SocketException(); } ex = Helpers.GetRandomInt(CalcConfig.FatalExceptionChance); if (ex == 5) { throw new ArgumentNullException(); } // emulate receiving n e-mails int n = Helpers.GetRandomInt(CalcConfig.MaxNumberEmailsReceived); Console.WriteLine(" {0} e-mails found.", n); for (int i = 0; i < n; i++) { var from = Helpers.GetRandomEmail(); var loanId = Helpers.GetRandomLoadId(); var calculationOrder = new CalculateLoan(from, loanId); this.commander.Tell(calculationOrder); } }); }
private void Main_Load(object sender, EventArgs e) { _chartActor = Program.ChartActors.ActorOf(Props.Create(() => new ChartingActor(sysChart, btnPauseResume)), "charting"); _chartActor.Tell(new ChartingActor.InitializeChart(null)); _coordinatorActor = Program.ChartActors.ActorOf(Props.Create(() => new PerformanceCounterCoordinatorActor(_chartActor)), "counters"); _toggleActors[CounterType.Cpu] = Program.ChartActors.ActorOf( Props.Create(() => new ButtonToggleActor(_coordinatorActor, btnCpu, CounterType.Cpu, false)) .WithDispatcher("akka.actor.synchronized-dispatcher")); _toggleActors[CounterType.Memory] = Program.ChartActors.ActorOf( Props.Create(() => new ButtonToggleActor(_coordinatorActor, btnMemory, CounterType.Memory, false)) .WithDispatcher("akka.actor.synchronized-dispatcher")); _toggleActors[CounterType.Disk] = Program.ChartActors.ActorOf( Props.Create(() => new ButtonToggleActor(_coordinatorActor, btnDisk, CounterType.Disk, false)) .WithDispatcher("akka.actor.synchronized-dispatcher")); _toggleActors[CounterType.Cpu].Tell(new ButtonToggleActor.Toggle()); }
/// <summary> /// Creates an instance of the screen. /// </summary> public ConversationViewModel(IActorRef vmActor, Guid id) { _vmActor = vmActor; Id = id; _vmActor.Tell(new ConversationViewModelActor.AssociateWithViewModel(this)); }
public ConnectionResponse(IActorRef activeClientsActor, IActorRef hearbeatReceiver, IEnumerable<ConnectedClient> connectedClients, IActorRef messageHandler) { ActiveClientsActor = activeClientsActor; HearbeatReceiver = hearbeatReceiver; ConnectedClients = connectedClients; MessageHandler = messageHandler; }
public Producer() { Context.System.Scheduler.ScheduleTellRepeatedly(1000, 1000, Self, "", Nobody.Instance); Receive<Signal.HubStarted>(started => _hub = started.Hub); Receive<string>(_ => _hub.Tell(DateTime.Now.ToLongTimeString())); }
public Master() { var layersCount = LayerDimentions.Count; var dataShards = Enumerable.Repeat(DataSet, DataPerReplica).ToList(); var parameterShardActors = new IActorRef[layersCount - 1]; for (int i = 0; i < layersCount -1; i++) { parameterShardActors[i] = Context.ActorOf(new Props(typeof(ParameterShard), new object[]{ new ParameterShard(i, LearningRate, new double[3,3])})); } var dataShardActors = new List<IActorRef>(); foreach (var dataShard in dataShards) { dataShardActors.Add(Context.ActorOf(new Props(typeof(DataShard), new []{new DataShard { } }))); } var shardsFinishedCount = 0; Receive<Start>(start => { foreach (var dataShardActor in dataShardActors) { dataShardActor.Tell(new ReadyToProcess()); } }); Receive<Done>(done => { shardsFinishedCount++; if (shardsFinishedCount == dataShards.Count) Console.WriteLine("Done"); }); }
public ClientReceiveActor(IActorRef actor, long repeat, TaskCompletionSource<bool> latch) { var received=0L; var sent=0L; Receive<Messages.Msg>(m => { received++; if(sent < repeat) { actor.Tell(m); sent++; } else if(received >= repeat) { latch.SetResult(true); } }); Receive<Messages.Run>(r => { var msg = new Messages.Msg(); for(int i = 0; i < Math.Min(1000, repeat); i++) { actor.Tell(msg); sent++; } }); Receive<Messages.Started>(s => Sender.Tell(s)); }
public GenericDBEntity(string entityType, long id) { _entityChangeNotificationActor = Context.System.ActorSelection($"/user/EntityChangeNotificationRootActor/{entityType}").ResolveOne(TimeSpan.FromSeconds(1)).Result; var entityAssembly = Assembly.GetAssembly(typeof(IModelObject)); // Removed DTOs - ModelObject = ef entity var allEntityTypes = entityAssembly.GetTypes().ToList(); EntityType = allEntityTypes.FirstOrDefault(t => t.Name == entityType); Id = id; _modelObject = LoadEntityFromDb(); Receive<UpdateEntityRequest>(message => { _undoStack.Push(_modelObject); _modelObject = message.GetModelObject(); SaveModelObject(); Sender.Tell(_modelObject); _entityChangeNotificationActor.Tell(new NotifySubscribersOfEntityChange(this.Id)); }); Receive<UndoRequest>(message => { if (_undoStack.Count > 0) { _modelObject = _undoStack.Pop(); SaveModelObject(); } Sender.Tell(_modelObject); }); }
private readonly Dictionary<int, IActorRef> _hospitalCoordinatorActors; // maps hospital id -> actor ref #endregion Fields #region Constructors public MediWatchCommanderActor( IEnumerable<Hospital> hospitals, IActorRef dashboardActor ) { _dashboardActor = dashboardActor; _hospitalCoordinatorActors = InitializeHospitalCoordinatorActors( hospitals ); Processing(); }
/// <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, IActorRef sender = null) { var cell = Cell; sender = sender.IsNobody() ? cell.System.DeadLetters : sender; var envelope = new Envelope { Message = message, Sender = sender }; cell.UseThreadContext(() => cell.ReceiveMessageForTest(envelope)); }
public LifeCycleTest2Actor(IActorRef testActor, string id, AtomicCounter generationProvider) { this.testActor = testActor; this.id = id; this.generationProvider = generationProvider; this.CurrentGeneration = generationProvider.Next(); }
protected override void PreStart() { base.PreStart(); _self = Self; _initiator.GatewayInitialized?.Invoke(_self); }
public ConnectionAssociationHandle(IActorRef connection, Address localAddress, Address remoteAddress) : base(localAddress, remoteAddress) { _connection = connection; ReadHandlerSource = new TaskCompletionSource<IHandleEventListener>(); ReadHandlerSource.Task.PipeTo(connection); }
public ConnectionRequest(Guid clientId, ClientStatus initialStatus, string username, IActorRef clientsActor) { ClientId = clientId; InitialStatus = initialStatus; Username = username; ClientsHandler = clientsActor; }
public static RequestDissolve Create(IActorRef target) { return(new RequestDissolve(target: target)); }
public static ResourceWillBeReady Create(IActorRef target) { return(new ResourceWillBeReady(message: null, target: target)); }
private AcknowledgeJob(object message, IActorRef target) : base(message: message, target: target) { }
public static AcknowledgeJob Create(FJobResourceConfirmation message, IActorRef target) { return(new AcknowledgeJob(message: message, target: target)); }
private StartRequeue(IActorRef target) : base(message: null, target: target) { }
public static StartRequeue Create(IActorRef target) { return(new StartRequeue(target: target)); }
private RequestDissolve(IActorRef target) : base(message: null, target: target) { }
public static AcknowledgeRevoke Create(IActorRef message, IActorRef target) { return(new AcknowledgeRevoke(message: message, target: target)); }
public TailActor(IActorRef reporterActor, string filePath) { _reporterActor = reporterActor; _filePath = filePath; }
private AcknowledgeRevoke(IActorRef message, IActorRef target) : base(message: message, target: target) { }
private Receive WaitChildTerminatedBeforeBackoff(IActorRef childRef) { return(message => WaitChildTerminatedBeforeBackoff(message, childRef) || HandleBackoff(message)); }
private RequestProcessingStart(object message, IActorRef target) : base(message: message, target: target) { }
public ConsoleReaderActor(IActorRef validationActor) { _validationActor = validationActor; }
/// <summary> /// Initializes a new instance of the <see cref="TestActorRef{TActor}"/> class. /// </summary> /// <param name="system">The system.</param> /// <param name="actorProps">The actor props.</param> /// <param name="supervisor">Optional: The supervisor.</param> /// <param name="name">Optional: The name.</param> public TestActorRef(ActorSystem system, Props actorProps, IActorRef supervisor = null, string name = null) : base(system, actorProps, supervisor, name) { }
public Found(string name, IActorRef @ref) { Name = name; Ref = @ref; }
public DistributedActorTable(string name, IActorRef clusterActorDiscovery) : this(name, clusterActorDiscovery, typeof(IncrementalIntegerIdGenerator), Array.Empty <object>()) { }
public static async Task <object> AskFo(this IActorRef actorRef, object message, int timeoutInSeconds = 120) { //https://stackoverflow.com/questions/17248680/await-works-but-calling-task-result-hangs-deadlocks#answer-32429753 return(await actorRef.Ask(message, TimeSpan.FromSeconds(timeoutInSeconds))); }
public StreamsAssociationHandle(Address localAddress, Address remoteAddress, IActorRef streamsRef, StreamsTransport transport) : base(localAddress, remoteAddress) { _streamsRef = streamsRef; _transport = transport; }
public NonPersistentMessage(object payload, IActorRef sender) { Payload = payload; Sender = sender; }
public Register(string name, IActorRef @ref) { Name = name; Ref = @ref; }
public IPersistentRepresentation Update(long sequenceNr, string persistenceId, bool isDeleted, IActorRef sender) { return(new Persistent(Payload, sequenceNr, persistenceId, isDeleted, sender)); }
public StartTail(string filePath, IActorRef reportActor) { FilePath = filePath; ReportActor = reportActor; }
public NotifyOnPersistenceEvents(IActorRef waiter) { Waiter = waiter; }
public IPersistentRepresentation PrepareWrite(IActorRef sender) { return(new Persistent(Payload, SequenceNr, PersistenceId, IsDeleted, sender)); }
/// <summary> /// Initializes a new instance of the <see cref="ActorSelection" /> class. /// </summary> /// <param name="anchor">The anchor.</param> /// <param name="path">The path.</param> public ActorSelection(IActorRef anchor, string path) : this(anchor, path == "" ? new string[] {} : path.Split('/')) { }
public Persistent(object payload, long sequenceNr = 0L, string persistenceId = null, bool isDeleted = false, IActorRef sender = null) { Payload = payload; SequenceNr = sequenceNr; IsDeleted = isDeleted; PersistenceId = persistenceId ?? string.Empty; Sender = sender; }
/// <summary> /// INTERNAL API /// Convenience method used by remoting when receiving <see cref="ActorSelectionMessage" /> from a remote /// actor. /// </summary> internal static void DeliverSelection(IInternalActorRef anchor, IActorRef sender, ActorSelectionMessage sel) { if (sel.Elements.IsNullOrEmpty()) { anchor.Tell(sel.Message, sender); } else { var iter = sel.Elements.Iterator(); Action <IInternalActorRef> rec = null; rec = @ref => @ref.Match() .With <ActorRefWithCell>(refWithCell => { var emptyRef = new EmptyLocalActorRef(refWithCell.Provider, anchor.Path / sel.Elements.Select(el => el.ToString()), refWithCell.Underlying.System.EventStream); iter.Next() .Match() .With <SelectParent>(_ => { var parent = @ref.Parent; if (iter.IsEmpty()) { parent.Tell(sel.Message, sender); } else { rec(parent); } }) .With <SelectChildName>(name => { var child = refWithCell.GetSingleChild(name.Name); if (child is Nobody) { if (!sel.WildCardFanOut) { emptyRef.Tell(sel, sender); } } else if (iter.IsEmpty()) { child.Tell(sel.Message, sender); } else { rec(child); } }) .With <SelectChildPattern>(p => { var children = refWithCell.Children; var matchingChildren = children .Where(c => c.Path.Name.Like(p.PatternStr)) .ToList(); if (iter.IsEmpty()) { if (matchingChildren.Count == 0 && !sel.WildCardFanOut) { emptyRef.Tell(sel, sender); } else { matchingChildren.ForEach(child => child.Tell(sel.Message, sender)); } } else { if (matchingChildren.Count == 0 && !sel.WildCardFanOut) { emptyRef.Tell(sel, sender); } else { var m = new ActorSelectionMessage(sel.Message, iter.ToVector().ToArray(), sel.WildCardFanOut || matchingChildren.Count > 1); matchingChildren.ForEach(child => DeliverSelection(child as IInternalActorRef, sender, m)); } } }); }) .Default(_ => @ref.Tell(new ActorSelectionMessage(sel.Message, iter.ToVector().ToArray()), sender)); rec(anchor); } }
public PlaybackActor() { _userCoordinator = Context.ActorOf(Props.Create <UserCoordinatorActor>(), "UserCoordinator"); _statistics = Context.ActorOf(Props.Create <PlaybackStatisticsActor>(), "PlaybackStatistics"); }
public ChannelInitializer(ActorSystem system, IActorRef server) { this.system = system; this.server = server; }
/// <summary> /// Initializes a new instance of the <see cref="ActorSelection" /> class. /// </summary> /// <param name="anchor">The anchor.</param> /// <param name="path">The path.</param> public ActorSelection(IActorRef anchor, SelectionPathElement[] path) { Anchor = anchor; Path = path; }