Removing registeredInRemoteNodeDuringSerialization

This commit is contained in:
Viktor Klang 2010-09-23 14:50:11 +02:00
parent 893f62117c
commit 3016cf69c8
3 changed files with 8 additions and 14 deletions

View file

@ -82,7 +82,6 @@ trait ActorRef extends
@volatile protected[this] var _status: ActorRefStatus.StatusType = ActorRefStatus.UNSTARTED @volatile protected[this] var _status: ActorRefStatus.StatusType = ActorRefStatus.UNSTARTED
@volatile protected[akka] var _homeAddress = new InetSocketAddress(RemoteServerModule.HOSTNAME, RemoteServerModule.PORT) @volatile protected[akka] var _homeAddress = new InetSocketAddress(RemoteServerModule.HOSTNAME, RemoteServerModule.PORT)
@volatile protected[akka] var _futureTimeout: Option[ScheduledFuture[AnyRef]] = None @volatile protected[akka] var _futureTimeout: Option[ScheduledFuture[AnyRef]] = None
@volatile protected[akka] var registeredInRemoteNodeDuringSerialization = false
protected[akka] val guard = new ReentrantGuard protected[akka] val guard = new ReentrantGuard
/** /**

View file

@ -337,8 +337,8 @@ class RemoteServer extends Logging with ListenerManagement {
def unregister(actorRef: ActorRef):Unit = synchronized { def unregister(actorRef: ActorRef):Unit = synchronized {
if (_isRunning) { if (_isRunning) {
log.debug("Unregistering server side remote actor [%s] with id [%s:%s]", actorRef.actorClass.getName, actorRef.id, actorRef.uuid) log.debug("Unregistering server side remote actor [%s] with id [%s:%s]", actorRef.actorClass.getName, actorRef.id, actorRef.uuid)
actors() remove actorRef.id actors().remove(actorRef.id,actorRef)
if (actorRef.registeredInRemoteNodeDuringSerialization) actorsByUuid() remove actorRef.uuid actorsByUuid().remove(actorRef.uuid,actorRef)
} }
} }
@ -353,11 +353,9 @@ class RemoteServer extends Logging with ListenerManagement {
if (id.startsWith(UUID_PREFIX)) { if (id.startsWith(UUID_PREFIX)) {
actorsByUuid().remove(id.substring(UUID_PREFIX.length)) actorsByUuid().remove(id.substring(UUID_PREFIX.length))
} else { } else {
val actorRef = actors().get(id) val actorRef = actors() get id
if (actorRef.registeredInRemoteNodeDuringSerialization) { actorsByUuid().remove(actorRef.uuid,actorRef)
actorsByUuid() remove actorRef.uuid actors().remove(id,actorRef)
}
actors() remove id
} }
} }
} }

View file

@ -249,12 +249,9 @@ object RemoteActorSerialization {
val host = homeAddress.getHostName val host = homeAddress.getHostName
val port = homeAddress.getPort val port = homeAddress.getPort
if (!registeredInRemoteNodeDuringSerialization) { Actor.log.debug("Register serialized Actor [%s] as remote @ [%s:%s]", actorClass.getName, host, port)
Actor.log.debug("Register serialized Actor [%s] as remote @ [%s:%s]", actorClass.getName, host, port) RemoteServer.getOrCreateServer(homeAddress)
RemoteServer.getOrCreateServer(homeAddress) RemoteServer.registerActorByUuid(homeAddress, uuid.toString, ar)
RemoteServer.registerActorByUuid(homeAddress, uuid.toString, ar)
registeredInRemoteNodeDuringSerialization = true
}
RemoteActorRefProtocol.newBuilder RemoteActorRefProtocol.newBuilder
.setClassOrServiceName(uuid.toString) .setClassOrServiceName(uuid.toString)