actor

Hive基础练习一

微笑、不失礼 提交于 2019-12-04 18:39:42
下面是hive基本练习,持续补充中。 简述Hive工作原理 hive是基于hadoop,可以管理hdfs上的数据的工具,它本质上是执行MapReduce程序,只是使用了类sql语句更加方便开发,hive驱动器会将类sql语句转换成MapReduce的task来执行,因此执行速度会比较慢。 hive的核心是驱动器,它可以连接sql和hdfs,将sql转换成了MapReduce任务,驱动器主要包括: (1)解析器:解析sql语句,划分为不同的stage (2)编译器:将不同阶段的stage编译,变成一个个的MR任务 (3)优化器:对逻辑执行进行优化 (4)执行器:将sql里的逻辑任务转换为hdfs的物理任务,hive的执行器就是MapReduce hive 内部表和外部表区别 内部表:主要用在数据仓库层(DW层),为个人独自占有,如果删除表格,对应的原始数据也将删除,但是对其他人没有影响。 外部表:主要用在源数据层(ODS层),删除表格不会删除对应的数据。 在建表时,如果是内部表,不需要使用external关键字,外部表需要使用external关键字。 创建表格导入数据练习1 战狼2,吴京:吴刚:卢婧姗,2017-08-16 大话西游,周星驰:吴孟达,1995-09-01 哪吒,吕艳婷:瀚墨,2019-07-26 使徒行者2,张家辉:古天乐:吴镇宇,2019-08-07 鼠胆英雄

Akka 2: How to pause processing of messages?

懵懂的女人 提交于 2019-12-04 18:35:13
问题 On my journey to grasp the Actor model using Akka many questions pop up. Here is another one. Say we have an Actor which has to stop processing messages for a given time because of some business logic or available resources. Cases where this might occur could be: Throttling. There might be an Actor which sends e-mails but is restricted to sent only one e-mail per second. The Actor might employ some system which can only process x-messages simultaneity. This could be an AsyncHttpClient which

How do I create a TestActorRef in Scala for an Actor with constructor params?

梦想的初衷 提交于 2019-12-04 16:40:38
问题 The Akka Testing docs give the following way to create a TestActorRef: import akka.testkit.TestActorRef val actorRef = TestActorRef[MyActor] How do I extend this for testing an existing actor that takes constructor arguments? When I try running this as is, substituting in my actor class, I get the following error: "error while creating actor akka.actor.ActorInitializationException:Could not instantiate Actor Make sure Actor is NOT defined inside a class/trait, if so put it outside the class

Waiting for multiple results in Akka

丶灬走出姿态 提交于 2019-12-04 13:05:15
问题 What is the proper way to wait for the result of multiple actors in Akka? The Principles of Reactive Programming Coursera course had an exercise with a replicated key-value store. Without going into the details of the assignment, it required waiting on the acknowledgement of multiple actors before it could indicate the replication was complete. I implemented the assignment using a mutable map containing the outstanding requests, but I felt the solution had a 'bad smell'. I hoped there was a

Howto design a clock driven multi-agent simulation

筅森魡賤 提交于 2019-12-04 13:00:41
I want to create a multi-agent simulation model for a real word manufacturing process to evaluate some dispatching rules. The simulation needs to produce event logs to evaluate time effect of the dispatching rules compared to the real manufacturing event logs. How can I incorporate the 'current simulation time' into this kind of multi-agent, message passing intensive simulation? Background: The classical discrete event simulation (which handles the time-advancement nicely) cannot be applied here, as the agents in the system represent relatively complex behavior and routing requirements plus

RemoteActor unregister actor

倾然丶 夕夏残阳落幕 提交于 2019-12-04 12:15:24
I'm playing with RemoteActors. Now I wonder, what happens if I shut down an RemoteActor. The actor was made available with RemoteActor.alive and RemoteActor.register. I can't find the inverse of either of both: alive and register. How do I properly shut down an RemoteActor? Update To make it more obvious, I made a 'small' example. Neither of the following 2 programs terminate, the JVM keeps running. All user created actors and main are finished. package test import scala.actors.{OutputChannel, AbstractActor, Actor} , Actor._ import scala.actors.remote.RemoteActor , RemoteActor._ object

Actors Mailbox Overflow. Scala

蹲街弑〆低调 提交于 2019-12-04 11:32:54
Im currently working with two actors in scala. One, the producer , produces some data and sends it to a parcer . The producer sends a HashMap[String,HashMap[Object,List[Int]]] through a message (along with this to mark the sender): parcer ! (this,data) The parser is constantly waiting for messages like so: def act(){ loop{ react{ case (producer, data)=> parse(data); } } } The program runs perfectly in normal circunstances. The problem comes with big volumes of data and many messages sent (The hash has about 10^4 elements, the inner hash about 100 elements and the list is 100 long), the program

How many actors can be launched in scala?

假如想象 提交于 2019-12-04 09:43:46
I tried this code import scala.actors.Actor class MyActor(val id:Int) extends Actor { def act() { println (" ****************** starting actor: " + id) while (true) { Thread.sleep(1000); println ("I'm actor " + id) } } } object Main { def main(args:Array[String]) { val N = 5 for (i leftArrow 1 to N) { val a = new MyActor(i) println (" ++++++++++ about to start actor " + a.id) a.start } println (N + " actors launched?") } } and got this output ++++++++++ about to start actor 1 ++++++++++ about to start actor 2 ++++++++++ about to start actor 3 ++++++++++ about to start actor 4 ++++++++++ about

The actor model: Why is erlang special? Or, why do you need another language for it?

安稳与你 提交于 2019-12-04 07:26:12
问题 I've been looking into learning erlang, and as a result, have been reading (okay, skimming) about the actor model. From what I understand, the actor model is simply a set of functions (run within lightweight threads called "processes" in erlang), which communicate with each other only via message passing. This seems fairly trivial to implement in C++, or any other language: class BaseActor { std::queue<BaseMessage*> messages; CriticalSection messagecs; BaseMessage* Pop(); public: void Push

Get or create child Akka actor and ensure liveness

孤街浪徒 提交于 2019-12-04 07:17:16
I am trying to use a hierarchy of Akka actors to handle per user state. There is a parent actor that owns all the children, and handles the get-or-create in the correct way (see a1 , a2 ): class UserActorRegistry extends Actor { override def Receive = { case msg@ DoPerUserWork(userId, _) => val perUserActor = getOrCreateUserActor(userId) // perUserActor is live now, but will it receive "msg"? perUserActor.forward(msg) } def getOrCreateUserActor(userId: UserId): ActorRef = { val childName = userId.toActorName context.child(childName) match { case Some(child) => child case None => context