Guess we could detect it and do it automatically in this simple case, but what if the actorref is part of case class ? Should we do reflection? Static analysis?
--
Jonas Bonér
Specialist at Large
work: http://scalablesolutions.se
code: http://akka.io
twtr: @jboner
"√iktor Klang" <viktor...@gmail.com> wrote:
>Work: Scalable Solutions <http://www.scalablesolutions.se>
We never magically serialize anything. You need to serialize it first then send it as a message.
Guess we could detect it and do it automatically in this simple case, but what if the actorref is part of case class ?
Should we do reflection? Static analysis?
For the 'sender' reference we automatically do serialization to RemoteActorRef. Since we have control over it.I can't see how we can solve the 'send-arbitrary-message-with-some-actorref-somewhere-in-the-message-problem' generically.The docs state this clearly if I'm not mistaken.What is the real problem here?
On Mon, Nov 8, 2010 at 4:33 PM, Jonas Bonér <jo...@jonasboner.com> wrote:For the 'sender' reference we automatically do serialization to RemoteActorRef. Since we have control over it.I can't see how we can solve the 'send-arbitrary-message-with-some-actorref-somewhere-in-the-message-problem' generically.The docs state this clearly if I'm not mistaken.What is the real problem here?
I think that ActorRef should be serializable, just like sender, we can add readObject and writeObject to translate automatically, and we can decide if it should rematerialize as a Local or Remote ref.
Then we can add support in SJSON and Java-JSON as well since we basically control them.
The "real" problem is that it's not obvious that you need to promote your refs to another form if you want to make sure your messages don't barf when crossing VM boundraries. (i.e. being sent to an actor with a durable mailbox (which demands serialization) or crossing over the network, perhaps as a load-balancing action).
On 8 November 2010 16:44, √iktor Klang <viktor...@gmail.com> wrote:On Mon, Nov 8, 2010 at 4:33 PM, Jonas Bonér <jo...@jonasboner.com> wrote:For the 'sender' reference we automatically do serialization to RemoteActorRef. Since we have control over it.I can't see how we can solve the 'send-arbitrary-message-with-some-actorref-somewhere-in-the-message-problem' generically.The docs state this clearly if I'm not mistaken.What is the real problem here?
I think that ActorRef should be serializable, just like sender, we can add readObject and writeObject to translate automatically, and we can decide if it should rematerialize as a Local or Remote ref.
They are already serializable using Protobuf.Then we can add support in SJSON and Java-JSON as well since we basically control them.I don't like that. We will get into maintenance hell, we need to add this whenever we add a new protocol, and what if the user uses some protocol not "supported". Then its inconsistent. We have a one "right" way of serializing these now already, just one line of code.
The "real" problem is that it's not obvious that you need to promote your refs to another form if you want to make sure your messages don't barf when crossing VM boundraries. (i.e. being sent to an actor with a durable mailbox (which demands serialization) or crossing over the network, perhaps as a load-balancing action).
Sending messages over the network is *never* transparent.
Should not be. You always need to think about a protocol.The user can add the standard way of serializing (e.g. a solved problem) to his custom serialization protocol if he wants.I can't see how you can do this "magic" in a generally applicable way. Prove me wrong :-)
On Mon, Nov 8, 2010 at 5:01 PM, Jonas Bonér <jo...@jonasboner.com> wrote:On 8 November 2010 16:44, √iktor Klang <viktor...@gmail.com> wrote:On Mon, Nov 8, 2010 at 4:33 PM, Jonas Bonér <jo...@jonasboner.com> wrote:For the 'sender' reference we automatically do serialization to RemoteActorRef. Since we have control over it.I can't see how we can solve the 'send-arbitrary-message-with-some-actorref-somewhere-in-the-message-problem' generically.The docs state this clearly if I'm not mistaken.What is the real problem here?
I think that ActorRef should be serializable, just like sender, we can add readObject and writeObject to translate automatically, and we can decide if it should rematerialize as a Local or Remote ref.
They are already serializable using Protobuf.Then we can add support in SJSON and Java-JSON as well since we basically control them.I don't like that. We will get into maintenance hell, we need to add this whenever we add a new protocol, and what if the user uses some protocol not "supported". Then its inconsistent. We have a one "right" way of serializing these now already, just one line of code.
Hmm, not sure I follow, an example of the oneliner?
The "real" problem is that it's not obvious that you need to promote your refs to another form if you want to make sure your messages don't barf when crossing VM boundraries. (i.e. being sent to an actor with a durable mailbox (which demands serialization) or crossing over the network, perhaps as a load-balancing action).
Sending messages over the network is *never* transparent.
actorOf( new Actor {
def receive = {
case msg => self.reply("foo") //if self is a remote actor ref, this is a transparent network send
}
})
Should not be. You always need to think about a protocol.The user can add the standard way of serializing (e.g. a solved problem) to his custom serialization protocol if he wants.I can't see how you can do this "magic" in a generally applicable way. Prove me wrong :-)
What you can do is to have a shared unit test contract for all serialization schemes, that enforces promotion on ActorRefs in messages to be serialized correctly.
For Java-serialization it's just implementing writeObject and readObject on ActorRef, for the others it may, or may not be harder.
On 8 November 2010 17:18, √iktor Klang <viktor...@gmail.com> wrote:On Mon, Nov 8, 2010 at 5:01 PM, Jonas Bonér <jo...@jonasboner.com> wrote:On 8 November 2010 16:44, √iktor Klang <viktor...@gmail.com> wrote:On Mon, Nov 8, 2010 at 4:33 PM, Jonas Bonér <jo...@jonasboner.com> wrote:For the 'sender' reference we automatically do serialization to RemoteActorRef. Since we have control over it.I can't see how we can solve the 'send-arbitrary-message-with-some-actorref-somewhere-in-the-message-problem' generically.The docs state this clearly if I'm not mistaken.What is the real problem here?
I think that ActorRef should be serializable, just like sender, we can add readObject and writeObject to translate automatically, and we can decide if it should rematerialize as a Local or Remote ref.
They are already serializable using Protobuf.Then we can add support in SJSON and Java-JSON as well since we basically control them.I don't like that. We will get into maintenance hell, we need to add this whenever we add a new protocol, and what if the user uses some protocol not "supported". Then its inconsistent. We have a one "right" way of serializing these now already, just one line of code.
Hmm, not sure I follow, an example of the oneliner?
The "real" problem is that it's not obvious that you need to promote your refs to another form if you want to make sure your messages don't barf when crossing VM boundraries. (i.e. being sent to an actor with a durable mailbox (which demands serialization) or crossing over the network, perhaps as a load-balancing action).
Sending messages over the network is *never* transparent.
actorOf( new Actor {
def receive = {
case msg => self.reply("foo") //if self is a remote actor ref, this is a transparent network send
}
})An actor can't just magically become remote, so it is not transparent.
Should not be. You always need to think about a protocol.The user can add the standard way of serializing (e.g. a solved problem) to his custom serialization protocol if he wants.I can't see how you can do this "magic" in a generally applicable way. Prove me wrong :-)
What you can do is to have a shared unit test contract for all serialization schemes, that enforces promotion on ActorRefs in messages to be serialized correctly.
But this is a solved problem. We have correct and efficient serialization for ActorRef already.
For Java-serialization it's just implementing writeObject and readObject on ActorRef, for the others it may, or may not be harder.That would be a no-brainer, we could just delegate to standard ActorRef serialization, so could be useful.
Please also note that this is *only* for serialization to RemoteActorRef, serialization to LocalActorRef requires (for stateful actors) user specific coding to serialize the Actor instance.
On Mon, Nov 8, 2010 at 5:30 PM, Jonas Bonér <jo...@jonasboner.com> wrote:On 8 November 2010 17:18, √iktor Klang <viktor...@gmail.com> wrote:On Mon, Nov 8, 2010 at 5:01 PM, Jonas Bonér <jo...@jonasboner.com> wrote:On 8 November 2010 16:44, √iktor Klang <viktor...@gmail.com> wrote:On Mon, Nov 8, 2010 at 4:33 PM, Jonas Bonér <jo...@jonasboner.com> wrote:For the 'sender' reference we automatically do serialization to RemoteActorRef. Since we have control over it.I can't see how we can solve the 'send-arbitrary-message-with-some-actorref-somewhere-in-the-message-problem' generically.The docs state this clearly if I'm not mistaken.What is the real problem here?
I think that ActorRef should be serializable, just like sender, we can add readObject and writeObject to translate automatically, and we can decide if it should rematerialize as a Local or Remote ref.
They are already serializable using Protobuf.Then we can add support in SJSON and Java-JSON as well since we basically control them.I don't like that. We will get into maintenance hell, we need to add this whenever we add a new protocol, and what if the user uses some protocol not "supported". Then its inconsistent. We have a one "right" way of serializing these now already, just one line of code.
Hmm, not sure I follow, an example of the oneliner?
The "real" problem is that it's not obvious that you need to promote your refs to another form if you want to make sure your messages don't barf when crossing VM boundraries. (i.e. being sent to an actor with a durable mailbox (which demands serialization) or crossing over the network, perhaps as a load-balancing action).
Sending messages over the network is *never* transparent.
actorOf( new Actor {
def receive = {
case msg => self.reply("foo") //if self is a remote actor ref, this is a transparent network send
}
})An actor can't just magically become remote, so it is not transparent.
No, of course not, but the guy writing the code above does not know whether he's going to receive a message from a remote actor or not. Also, if he assumes he's only going to reply to local actors and then somewhere down the line he starts using remote actors, he'll be pretty surprised to see that the code goes through the compiler and tests and then it fails runtime.
Should not be. You always need to think about a protocol.The user can add the standard way of serializing (e.g. a solved problem) to his custom serialization protocol if he wants.I can't see how you can do this "magic" in a generally applicable way. Prove me wrong :-)
What you can do is to have a shared unit test contract for all serialization schemes, that enforces promotion on ActorRefs in messages to be serialized correctly.
But this is a solved problem. We have correct and efficient serialization for ActorRef already.
We have the serialization, but not the materialize-as-Local-or-Remote yet. But we do have a ticket for that.
For Java-serialization it's just implementing writeObject and readObject on ActorRef, for the others it may, or may not be harder.That would be a no-brainer, we could just delegate to standard ActorRef serialization, so could be useful.
Indeed.
Should not be. You always need to think about a protocol.The user can add the standard way of serializing (e.g. a solved problem) to his custom serialization protocol if he wants.I can't see how you can do this "magic" in a generally applicable way. Prove me wrong :-)
What you can do is to have a shared unit test contract for all serialization schemes, that enforces promotion on ActorRefs in messages to be serialized correctly.
But this is a solved problem. We have correct and efficient serialization for ActorRef already.
We have the serialization, but not the materialize-as-Local-or-Remote yet. But we do have a ticket for that.
For Java-serialization it's just implementing writeObject and readObject on ActorRef, for the others it may, or may not be harder.That would be a no-brainer, we could just delegate to standard ActorRef serialization, so could be useful.
Indeed.Add this. And sketch up a design how you would solve it generically across all serialization schemes.
Take a stab at it. But is this high prio really, e.g. needed for 1.0?
No clue. Will take a stab at it soon.
On Nov 8, 2010 6:35 PM, "Jonas Bonér" <jo...@jonasboner.com> wrote:
Depends on how much work it is. Don't want to slow down the release. How fast can you do it?
On 8 November 2010 18:02, √iktor Klang <viktor...@gmail.com> wrote:
>
>
>
> On Mon, Nov 8, 2010...