第90讲:基于Scala的Actor之上的分布式并发消息驱动框架Akka初体验学习笔记
来源:互联网 发布:转换成淘宝客链接 编辑:程序博客网 时间:2024/05/18 22:41
第90讲:基于Scala的Actor之上的分布式并发消息驱动框架Akka初体验学习笔记
akka在业界使用非常广泛
spark背后就是由akka驱动的
要写消息驱动的编程模型都首推akka
下面将用30讲讲解akka
本讲主要讲两部分内容:
1.akka的重大意义
2.akka与scala的actor
Spark源码中使用akka使用鉴赏:
在spark中有200行左右代码封装了akka的使用
spark是分布式的计算框架,有master和slave主从节点通信时都是使用akka。
客户端提交程序时也是使用akka。所以如果要掌握spark必须要理解和掌握akka。
private def initializeEventProcessActor(){
//blocking the thread until supervisor is started,
//which ensures eventProcessActor is not null before any job is submitted
implicit val timeout = Timeout(30 seconds)
val initEventActorReply =
dagSchedulerActorSupervisor ? Props(new DAGSchedulerEventProcessActor(this))
eventProcessActor = Await.result(initEventActorReply,timeout.duration).asInstanceOf[ActorRef]
//用问号等待另一个actor的执行结果。!是立即发送消息。
}
initializeEventProcessActor()
//called by TashScheduler to report task's starting.
def taskStarted(task: Task[_],taskInfo: TaskInfo) {
eventProcessActor ! BeginEvent(task,taskInfo)
}
//Called to report that a task has completed and results are being fetched remotely.
def taskGettingResult(taskInf: TaskInfo){
eventProcessActor ! GettingResultEvent(taskInfo)
}
Scalable real-time transaction processing
//transaction processing:支持分布式事务
We believe that writing correct concurrent, fault-tolerant and scalable applications is too hard. Most of the time it's
because we are using the wrong tools and the wrong level of abstraction. Akka is here to change that. Using the Actor Model
we raise the abstraction level and provide a better platform to build scalable,resilient and responsive
applications-see the Reactive Manifesto for more details.For fault-tolerance we adopt the "let it crash" model
which the telecom industry has used with great success to build applications that self-heal and systems that never stop.
Actors also provide the abstaction for transparent distribution and the basis for truly scalable and fault-tolerant applications.
Akka is Open Source and available under the Apache 2 License.
spark广泛运用在金融,实时在线交易等场合。
transparent distribution:位置透明
Akka provides scalable real-time transaction processing.
Akka is an unified runtime and programming model for:
Scale up (Concurrency)
Scale out (Remoting)
Fault tolerance
One thing to learn and admin, with high cohesion and coherent semantics.
Akka is a very scalable piece of software, not only in the context
of performance but also in the size of applications it is useful for.
The core of Akka, akka-actor, is very small and easily dropped into
an existing project where you need asynchronicity and lockless
concurrency without hassle.
You can choose to include only the parts of akka you need in your
application and then there's the whole package, the Akka
Microkernel, which is a standalone container to deploy your Akka
application in. With CPUs growing more and more cores every cycle,
Akka is the alternative that provides outstanding performance
even if you're only running it on one machine. Akka also
supplies a wide array of concurrency-paradigms, allowing users
to choose the right tool for the job.
What's a good use-case for Akka?
We see Akka being adopted by many large organizations in a big range of industries:
Investment and Merchant Banking
Retail
Social Media
Simulation
Gaming and Betting
Automobile and Traffic Systems
Health Care
Data Analytics
and much more. Any system with the need for high-throughput and
low latency is a good candidate for using Akka.
Actors let you manage service failures (Supervisors),
load management (back-off strategies, timeouts and
processing-isolation), as well as both horizontal and vertical
scalability (add more cores and/or add more machines).
Here's what some of the Akka users have to say about how
they are using Akka:
http://stackoverflow.com/questions/4493001/good-use-case-for-akka
All this in the ApacheV2-licensed open source project.
akka的每个actor有自己的状态和行为。就是属性和方法
不断循环自己的邮箱,启动后就循环。
其他actor就可以给他发消息,他就可以处理邮件。
akka基于actor,本身有ActorSystem,actor交互时用ActorRef是代理模式。
本讲只是预览一下akka的内容。
以上内容是从王家林老师DT大数据课程第90讲的学习笔记。
DT大数据微信公众账号:DT_Spark
王家林老师QQ:1740415547
王家林老师微信号:18610086859
scala第90讲视频观看链接:
http://yun.baidu.com/s/1Ffqe6
我的百度网盘共享的DT大数据梦工厂王家林老师第1-90讲的视频内容:http://pan.baidu.com/s/1qWK9CMo
今日【DT大数据梦工厂视频】《第90讲:基于Scala的Actor之上的分布式并发消息驱动框架Akka初体验》
土豆视频:http://www.tudou.com/programs/view/wMRFwzk3u4Q/
优酷视频:http://v.youku.com/v_show/id_XMTMxMzkyODE1Mg==.html?from=y1.7-1.2
腾讯视频:http://v.qq.com/page/k/x/2/k0163ov8kx2.html
(DT大数据梦工厂scala的所有视频、PPT和代码在百度云盘的链接:http://url.cn/fSFPjS)
- 第90讲:基于Scala的Actor之上的分布式并发消息驱动框架Akka初体验学习笔记
- 第90讲:基于Scala的Actor之上的分布式并发消息驱动框架Akka初体验
- 第108讲:Akka中的Actor消息的处理、消息回复、消息转发学习笔记
- Akka学习笔记06--Actor的消息
- Akka学习笔记06--Actor的消息
- 第102讲:通过案例解析Akka中的Actor运行机制以及Actor的生命周期学习笔记
- 第104讲:通过案例解析Akka中的Actor的不同类型的Constructor学习笔记
- 第103讲:通过案例解析Akka中的Actor的定义和创建学习笔记
- 第110讲:Akka中的Actor的Monitoring初步解析学习笔记
- 第68讲 scala并发编程原生线程actor、class class 下的消息传递和偏函数
- 第68讲:Scala并发编程原生线程Actor、Cass Class下的消息传递和偏函数实战解析及其在Spark中的应用源码解析学习笔记
- 第111讲:Akka中的Actor中用become和unbecome动态切换receive的具体处理逻辑实战学习笔记
- Scala基于Akka的Remote Actor实现的简单RPC
- Akka学习笔记05--Actor的创建
- Akka学习笔记05--Actor的创建
- 第67讲:Scala并发编程匿名Actor、消息传递、偏函数实战解析及其在Spark源码中的应用解析学习笔记
- 第106讲:解析Akka中的消息的不同发送方式方式详解学习笔记
- Akka学习笔记:Actor消息传递(1)
- 电脑反应慢的原因
- 拆分整数
- Hibernate 所有缓存机制详解
- 2015年8月20日21:03:18 firstNotRepeatingChar 哈希表实现O(n)
- android 添加视频、图片、录音上传(二)
- 第90讲:基于Scala的Actor之上的分布式并发消息驱动框架Akka初体验学习笔记
- mapreduce查询mysql表中记录数
- POJ 题目3237 Tree(Link Cut Tree边权变相反数,求两点最大值)
- 排序算法(Java语言)——希尔排序
- studio 2010快捷键
- 强名称程序集(strong name assembly)——为程序集赋予强名称
- Perfection
- hdu5407数学
- 02-线性结构4. Pop Sequence (25)