阿卡:"尝试反序列化序列化ActorRef没有范围&QUOT的ActorSystem;错误 [英] Akka: "Trying to deserialize a serialized ActorRef without an ActorSystem in scope" error

查看:363
本文介绍了阿卡:"尝试反序列化序列化ActorRef没有范围&QUOT的ActorSystem;错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我整合利用阿卡演员和星火以下列方式:当一个任务是星火节点之间分配,而处理的任务,每个节点还定期发送指标数据到不同的收集过程中,坐在别的地方上网络通过使用阿卡演员(通过阿卡远程连接到远程进程)中。

I am integrating the use of Akka actors and Spark in the following way: when a task is distributed among the Spark nodes, while processing that tasks, each node also periodically sends metrics data to a different collector process that sits somewhere else on the network through the use of an Akka actor (connecting to the remote process through akka-remote).

基于角色的度量发送/接收功能的工作原理就好了:

The actor-based metrics sending/receiving functionality works just fine when used in standalone mode, but when integrated in a Spark task the following error is thrown:

java.lang.IllegalStateException: Trying to deserialize a serialized ActorRef without an ActorSystem in scope. Use 'akka.serialization.Serialization.currentSystem.withValue(system) { ... }'
at akka.actor.SerializedActorRef.readResolve(ActorRef.scala:407) ~[akka-actor_2.10-2.3.11.jar:na]

如果我理解正确的话,问题的来源是星火节点无法反序列化的 ActorRef 的,因为它没有这样做所需要的全部信息。据我了解,把一个ActorSystem的范围将修复它,但我不知道如何使用建议 akka.serialization.Serialization.currentSystem.withValue(系统){...}

If I understood it correctly, the source of the problem is the Spark node being unable to deserialize the ActorRef because it does not have the full information required to do it. I understand that putting an ActorSystem in scope would fix it, but I am not sure how to use the suggested akka.serialization.Serialization.currentSystem.withValue(system) { ... }

在阿卡官方的文档在pretty多,他们涵盖了所有的主题非常好。不幸的是,专门用来序列化的章节,可以恕我直言改善。

The Akka official docs are very good in pretty much all topics they cover. Unfortunately, the chapter devoted to Serialization could be improved IMHO.

请注意:有一个类似SO质疑<一个href=\"http://stackoverflow.com/questions/28639618/unable-to-deserialize-actorref-to-send-result-to-different-actor\">here但接受的解决方案是太具体,因此不真正有用在一般情况下

Note: there is a similar SO question here but the accepted solution is too specific and thus not really useful in the general case

推荐答案

这是 ActorSystem 负责所有的参与 ActorRef 的对象。

An ActorSystem is responsible for all of the functionality involved with ActorRef objects.

在你的程序是这样

actorRef ! message

您实际上是调用ActorSystem,而不是ActorRef,内一堆工作将消息在正确的邮箱,放球的演员来运行接收线程池中的方法,等等...从<一href=\"http://doc.akka.io/docs/akka/2.4.0/general/actor-systems.html#What_you_should_not_concern_yourself_with\"相对=nofollow>文档:

You're actually invoking a bunch of work within the ActorSystem, not the ActorRef, to put the message in the right mailbox, tee-up the Actor to run the receive method within the thread pool, etc... From the documentation:

这是演员系统管理它被配置以使用的资源
  来运行,它包含演员。有可能是数以百万计的演员
  一个这样的系统中,所有的咒语之后将其视为
  丰富,他们在大约只有300个字节的开销权衡
  每个实例。当然,确切顺序消息
  在大的系统处理的是没有被应用可控
  笔者

An actor system manages the resources it is configured to use in order to run the actors which it contains. There may be millions of actors within one such system, after all the mantra is to view them as abundant and they weigh in at an overhead of only roughly 300 bytes per instance. Naturally, the exact order in which messages are processed in large systems is not controllable by the application author

这就是为什么你的code工作,但不是在星火精独立。您的每一个星火节点缺少ActorSystem机械,因此,即使你可以在一个节点反序列化ActorRef就没有ActorSystem处理在您的节点功能

That is why your code works fine "standalone", but not in Spark. Each of your Spark nodes is missing the ActorSystem machinery, therefore even if you could de-serialize the ActorRef in a node there would be no ActorSystem to process the ! in your node function.

您可以在每个节点内建立一个ActorSystem和使用(我)的远程通过的 actorSelection 或(ii)您所提到的序列化方法,其中每个节点的ActorSystem将是系统在你所引用的例子。

You can establish an ActorSystem within each node and use (i) remoting to send messages to your ActorRef in the "master" ActorSystem via actorSelection or (ii) the serialization method you mentioned where each node's ActorSystem would be the system in the example you quoted.

这篇关于阿卡:&QUOT;尝试反序列化序列化ActorRef没有范围&QUOT的ActorSystem;错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆