actor

UML基础之图

为君一笑 提交于 2019-12-06 22:51:42
UML——United Modeling Language, 统一建模语言——是一种面向对象的可视化建模语言。UML 采用了一组形象化的图形(如类图)符号作为建模语言, 使用这些符号可以形象地描述系统的各个方面。UML 通过建立图形之间的各种关系(如类与类之间的关系)来描述模型。 UML 中一共有 5类(9种)图,包括 用例图、静态图( 类图、对象图 )、行为图( 状态图、活动图 )、交互图( 时序图、协作图 )、实现图( 组件图、部署图 ) 。其中的类图是最重要的,还有就是用例图和时序图也是要求要掌握的。UML 中的关系主要包括 4 种:关联关系(association)、依赖关系(dependency)、泛化关系(generalization)、实现关系(realization)。 1、用例图 首先了解一下关于用例图,用例图(Use Case Diagram): 也称为用户模型图, 是从软件需求分析到最终实现的第一步, 它是从用户的角度来描述系统功能。并指出各功能的执行者。用例图包含 3 个基本组件: 参与者(Actor), 用例(Use Case), 关系。 1.1参与者(Actor): 与系统交互的人或其他系统,即使用该系统的人或事物,在 UML 中参与者用人形图标表示。 1.2用例(Use Case): 代表系统的某项完整的功能. 在 UML 中使用一个椭圆来表示。 1

Akka Typed系列:协议&行为

为君一笑 提交于 2019-12-06 20:24:37
引言 2019年11月6号LightBend公司发布了AKKA 2.6版本,带来了类型安全的actor,新的Akka Cluster底层通信设施——Artery,带来了更好的稳定性,使用Jackson进行消息序列化,支持SLF4J日志接口。Akka Typed与之前的经典actor编程模式有较大的不同,本文翻译自Manuel Bernhardt——Akka技术推广大使,在2019年7月发布的系列文章:Tour of Akka Typed: Protocols and Behaviors,文中的示例代码原是scala,考虑到scala普及程度不高,译文全部转成java代码。 本系列课程我们一起来探索Akka Typed,新的Akka Actor API显著优于经典的Actor API。其实Akka Typed早在4月份就已经可以用于生产环境了,但是API还是被标记为可能会改变,随着2.6正式版发布日期的临近,抢先看一下带来了哪些新的变化。 如果你对之前的Akka不熟悉,不用担心,保证你能看懂;如果你对Akka很熟悉,也不要飘飘然,本课程可以帮助你在实际工作中更好的掌握Akka Typed。 为什么使用Akka Typed actor编程模型是一个强有力的抽象模型,尤其擅长解决真实世界建模,容错、并发、分布式系统问题

Scala Actors: if react never returns, why does it need to be in a loop{}, and why doesn't while(true) work?

爱⌒轻易说出口 提交于 2019-12-06 18:40:52
问题 Just getting started on Scala Actors. The Scala website says: Thread-blocking operations can be avoided by using react to wait for new messages (the event-based pendant of receive ). However, there is a (usually small) price to pay: react never returns. ... Note that using react inside a while loop does not work! However, since loops are common there is special library support for it in form of a loop function. It can be used like this: loop { react { case A => ... case B => ... } } I'm now

Scala program exiting before the execution and completion of all Scala Actor messages being sent. How to stop this?

萝らか妹 提交于 2019-12-06 16:32:12
I am sending my Scala Actor its messages from a for loop. The scala actor is receiving the messages and getting to the job of processing them. The actors are processing cpu and disk intensive tasks such as unzipping and storing files. I deduced that the Actor part is working fine by putting in a delay Thread.sleep(200) in my message passing code in the for loop. for ( val e <- entries ) { MyActor ! new MyJob(e) Thread.sleep(100) } Now, my problem is that the program exits with a code 0 as soon as the for loop finishes execution. Thus preventing my Actors to finish there jobs. How do I get over

Use case diagram: of several actors of a use case, only some have access to an extending use case

跟風遠走 提交于 2019-12-06 16:10:41
How can I represent a diagram in which several actors have access to the same function, or "use case" but some of them have additional functions or "extends" (if im right) inside it, if i just extend on the main "use case" that would mean its accessible by everyone right? When a use case extends the main use case, extension points at the main use case, can have conditions. As a condition you could specify a specific actor. If the actors can be generalized, I have seen this solution too. But I prefer the first one because I am not sure if it is technically correct (As you noted, extend use case

Discard all messages except the last one in a Scala actor

夙愿已清 提交于 2019-12-06 15:26:38
I have a SwingWorker actor which computes a plot for display from a parameters object it gets send; then draws the plot on the EDT thread. Some GUI elements can tweak parameters for this plot. When they change I generate a new parameter object and send it to the worker. This works so far. Now when moving a slider many events are created and queue up in the worker's mailbox. But I only need to compute the plot for the very last set of parameters. Is there a way to drop all messages from the inbox; keep the last one and process only that? Currently the code looks like this val worker = new

RemoteActor.select - result deterministic?

北城以北 提交于 2019-12-06 14:29:18
问题 I wonder if there is any determinism when calling val delegate = RemoteActor.select(). I'm asking this, because I noticed that the program doesn't terminate, when I'm sending delegates over the net. Are there any other side effects, which depend on the delegate? Are there any rules, when RemoteActor.select will return the same delegate for the same arguments? Here's some example code which demonstrates the RemoteActor.select problem: package test import scala.actors.Actor, Actor._ import

Create an Akka actor remotely without a new ActorSystem

浪尽此生 提交于 2019-12-06 14:12:37
I've been over the documentation several times now ( http://doc.akka.io/docs/akka/2.1.4/scala/remoting.html ) and through the example here ( https://github.com/akka/akka/tree/master/akka-samples/akka-sample-remote ) and through others, and I still can't figure out how to do what I want to do. The closest answer I've found is this: how to start remote actors in scala , but it seems much more inconvenient than I'd think it would be. I have a cluster of 12 machines to work on. I would like to something along the lines of: val system = ActorSystem("DistributedSystem", ConfigFactor.load.getConfig(

Handling database-backed async callbacks in Grails

懵懂的女人 提交于 2019-12-06 13:23:32
问题 I've been working on implementing an automated trading system in Grails based on Interactive Brokers' API (brief overview here: Grails - asynchronous communication with 3rd party API) for longer than I care to admit. This is a high-frequency trading strategy, so it's not as simple as placing an order for 100 shares and getting filled. There's a lot of R&D involved, so my architecture and design have been and continue to morph and evolve over time. What has become clear over the past month or

Scala学习二十——Actor

空扰寡人 提交于 2019-12-06 12:53:30
一.本章要点 每个actor都要扩展Actor类并提供act方法 要往actor发送消息,可以用actor!message 消息发送是异步的:”发完就忘“ 要接受消息,actor可以调用receive或react,通常是在循环中这样做 receive/react的参数是有case语句组成的代码块(偏函数) 不同actor之间不应该共享状态。总是使用消息来发送数据 不要直接调用actor的方法,通过消息进行通信 避免同步消息——将发送消息和等待响应分开 不同actor可以通过react而不是receive来共享线程,前提是消息处理器的控制流转足够简单 让actor挂掉是OK的,前提是你有其他actor监控着actor的生死。用链接来设置监控关系 二.创建和启动Actor   actor是扩展自Antor特质的类。该特质有一个抽象方法act。可以重写这个方法指定avtor的行为。act方法带有一个消息循环,例: import scala.actors.Actor class HiActor extends Actor{ def act(){while(true){ receive{ case "Hi"=>println("Hello")} }} }//调用start方法执行val actor1=new HiActoractor1.start()