actor

Akka actor lookup or dependency injection

懵懂的女人 提交于 2020-01-02 02:32:09
问题 I'm just starting to work with Akka and I can't decide if I should use dependency injection (like cake pattern) or actor lookup in order to decouple the actors from each others. What is the preferred method? 回答1: You should prefer to introduce actors to each other, which means to send an ActorRef in or with a message or to pass it into a constructor. The latter may involve the cake pattern of you so choose, but lookup is much more expensive and therefore you should use real ActorRef whenever

From where we get sender actor when a particular message is received?

三世轮回 提交于 2020-01-01 05:25:05
问题 Whenever an actor receives a message in scala, we can access the sender of the actor by using a keyword 'sender' which is an an object of trait AbstractActor. My question how is this 'sender' becoming accessible whenever a message is received.? and also, can we override this implementation where along with sender some other data is also accessible such as ipaddress, port from where the data came . As far as i know, there is no way you can get ipaddress and port from where the message has come

Akka Actor ask and Type Safety

随声附和 提交于 2019-12-31 19:38:48
问题 How can I use Akka Actor ask and maintain type safety? or avoid using ask in favour of tells? When calling ? or ask on an Akka Actor, a Future[Any] is returned and I have to do an explicit cast via future.mapTo[MyType] . I don't like losing this type safety. If I use Futures directly (with no actors) I can explicitly return Future[MyType] and maintain type safety. My specific use case involves an actor delegating it's message to two child actors and then aggregating the results from those

Result of task invocation on a grain in Orleans

拥有回忆 提交于 2019-12-31 05:38:08
问题 I apologize for the long question. I have been experimenting with Orleans to know about its various properties and these questions are logically under one umbrella. The first test involved making request from client to a specific grain every 1 second while the grain takes 10 seconds to execute the requests. The code is this: // client code while (1) { Console.WriteLine("Client giving another request"); double temperature = random.NextDouble() * 40; var sensor = client.GetGrain

UML Diagrams: Can I use same actor on one diagram couple of times?

纵饮孤独 提交于 2019-12-31 02:45:07
问题 I am drawing some diagram, and I am wondering if it is acceptable for the actor to be in diagram more than once (for better transparency of the diagram)? Thanks 回答1: UMLDiagram is a composition of UMLDiagramElement s, however Actor is NOT UmlDiagramElement , it is an Element . The UMLDiagramElement counterpart for Actor is either UMLShape (when shown as icon/figure) or UMLClassifierShape (when shown as a class box). You have to keep the concepts of "UML Model" and "UML Diagram" separate.

mysql------explain工具

余生长醉 提交于 2019-12-30 01:46:39
基于mysql5.7,innodb存储引擎 使用explain关键字可以模拟优化器执行SQL语句,分析你的查询语句或是结构的性能瓶颈 在 select 语句之前增加 explain 关键字,MySQL 会在查询上设置一个标记,执行查询会返 回执行计划的信息,而不是执行这条SQL ,如果 from 中包含子查询,仍会执行该子查询,将结果放入临时表中 使用到的建表语句文末 explain select * from actor; 在查询中的每个表会输出一行,如果有两个表通过 join 连接查询,那么会输出两行 explain结果字段说明 1. id列 id列的编号是 select 的序列号,有几个 select 就有几个id,并且id的顺序是按 select 出现的 顺序增长的。 id列越大执行优先级越高,id相同则从上往下执行,id为NULL最后执行。 2. select_type列 select_type 表示对应行是简单还是复杂的查询。 1)simple:简单查询。查询不包含子查询和union 2)primary:复杂查询中最外层的 select 3)subquery:包含在 select 中的子查询(不在 from 子句中) 4)derived:包含在 from 子句中的子查询。MySQL会将结果存放在一个临时表中,也称为 派生表(derived的英文含义) 5)union:在

How to designate a thread pool for actors

大憨熊 提交于 2019-12-29 04:19:34
问题 I have an existing java/scala application using a global thread pool. I would like to start using actors in the project but would like everything in the app using the same pool. I know I can set the maximum number of threads that actors use but would prefer sharing the thread pool. Is this necessary/reasonable, and is it possible to designate the actor's thread pool? If it is not possible/recommended, are there any rules of thumb when integrating actors in apps that are already using threads?

Soft Actor-Critic(论文笔记)

懵懂的女人 提交于 2019-12-28 03:07:18
Soft Actor-Critic SAC跟soft Q Learning一样在目标函数中引入熵,其目的是希望actor估计得动作在能够完成任务的基础上尽可能随机化。使得actor可以探索更多可能性,以达到近似最优(原文是near-optimal)的多种选择。假设有多个动作差不多一样好,policy应该设置每个动作有差不多一样的概率来选择他们。 本文的关键点: Off-policy方式更新,可以使用以前采样数据。 最大化熵可以提高稳定性及探索能力。 算法更新过程为policy iteration:评估policy->计算这个policy的value(使用 value function)->提升policy,使用value function来得到更好的policy(意思是说找到一个新的policy,使其value更大) 目标函数: 在原始的目标函数基础上增加了熵的部分,α控制熵的权重。 这个目标函数有几点好处: 激励policy更广阔地探索(熵项),并且放弃无意义没前途的行为(reward项) policy的行为是near-optimal的,意思是多个行为都可以达到optimal。如果多个行为同样好,应该设置多个行为一样的概率。 可以提高学习速度。 本文是第一篇在actor-critic上使用最大化熵的RL算法。 对于一个固定的policy,其soft Q

scala之Akka的Actor模型(下)

余生颓废 提交于 2019-12-26 09:07:02
原文地址:http://my.oschina.net/jingxing05/blog/287462 ActorSystem(“companyname”) 相当于注册一家公司一样,负责: 通用配置 如:dispatchers, deployments, remote capabilities and addresses 创建Actor和搜索actor 通常一个应用一个Actorsystem ActorRef actOf会异步的启动一个Actor,并返回这个Actor的ActorRef,作为消息目的地,ActorRef的特征: immutable 与Actor是一对一关系 可序列化和网络传输,以实现远程透明性 启动Actor actor_system.actorOf(Props(new HelloActor("jingxing05")), name = "helloactor") 如果一个Actor有多个属性,可以通过如下方式设置其值: 发送适当的消息 放到构造函数中 重写preStart方法 Actor交互消息 消息必须是immutable的 通过 ! 给Actor发送消息 Actor的消息处理方式 def receive = { // 接受消息时隐式的传入了 发送者的 ActorRef 名为 sender case "hello" => println("hello back to

How to periodically check an actor mailbox and alter variables in scala

こ雲淡風輕ζ 提交于 2019-12-25 09:17:39
问题 I am using akka actors in Scala. I would like to know if there is a way to have an actor, which while processing a message received can periodically check its mailbox for other messages and following this messages can alter its variables. A scheme like: class Actor1 (constructors){ def receive={ case "go" => run() //the actor starts case "alter variables" // a new message is stashed in mailbox } def run={ //do stuff check(mailbox) //while the porocessing of the "go" message // is not finished