Akka remote serialization should support ActorRef
All different message serialization options should support serialization and deserialization of ActorRefs (that will be RemoteActorRefs on the receiving end)
One thing to do is to add readResolve and writeReplace to ActorRef to make LocalActorRefs RemoteActorRefs if materialized on other node.
One thing to do is to add readResolve and writeReplace to ActorRef to make LocalActorRefs RemoteActorRefs if materialized on other node.
Leave a comment
on 2011-03-08 17:12 *
By viktorklang
Description changed from All different message seria... to All different message seria...
on 2011-03-08 17:32 *
By viktorklang
For the audience: http://download.oracle.com/javase/6/docs/api/java/io/Serializable.html
on 2011-03-09 18:52 *
By viktorklang
Something building on this perhaps?
class SerializedActorRef(val uuid: Uuid,
val classOrServiceName: String,
val actorClassName: String,
val hostname: String,
val port: Int,
val timeout: Long) extends java.io.Serializable {
import java.io.ObjectStreamException
@throws(classOf[ObjectStreamException])
def readResolve(): AnyRef = {
val address = Actor.remote.address
if ((hostname == address.getAddress.getHostAddress || hostname == address.getHostName) && port == address.getPort) {
val actorOrNull = Actor.remote.findActorByIdOrUuid(classOrServiceName, uuid.toString)
if ( actorOrNull eq null) Actor.registry.actorFor(uuid).getOrElse(null) else actorOrNull
} else {
RemoteActorRef(classOrServiceName, actorClassname, hostname, port, timeout, None)
}
}
}
class SerializedActorRef(val uuid: Uuid,
val classOrServiceName: String,
val actorClassName: String,
val hostname: String,
val port: Int,
val timeout: Long) extends java.io.Serializable {
import java.io.ObjectStreamException
@throws(classOf[ObjectStreamException])
def readResolve(): AnyRef = {
val address = Actor.remote.address
if ((hostname == address.getAddress.getHostAddress || hostname == address.getHostName) && port == address.getPort) {
val actorOrNull = Actor.remote.findActorByIdOrUuid(classOrServiceName, uuid.toString)
if ( actorOrNull eq null) Actor.registry.actorFor(uuid).getOrElse(null) else actorOrNull
} else {
RemoteActorRef(classOrServiceName, actorClassname, hostname, port, timeout, None)
}
}
}
Postponing this to 1.2
Fixed in master, could be optimized.