Fixing a boot sequence issue with RemoteNode

This commit is contained in:
Viktor Klang 2010-08-09 19:35:07 +02:00
parent 3ad5f34ff7
commit d62fdcd4d6
3 changed files with 13 additions and 15 deletions

View file

@ -83,12 +83,15 @@ trait BootableActorLoaderService extends Bootable with Logging {
} else Thread.currentThread.getContextClassLoader)
}
abstract override def onLoad = {
abstract override def onLoad = {
applicationLoader.foreach(_ => log.info("Creating /deploy class-loader"))
super.onLoad
for (loader <- applicationLoader; clazz <- BOOT_CLASSES) {
log.info("Loading boot class [%s]", clazz)
loader.loadClass(clazz).newInstance
}
super.onLoad
}
abstract override def onUnload = {

View file

@ -25,14 +25,14 @@ trait BootableRemoteActorService extends Bootable with Logging {
def startRemoteService = remoteServerThread.start
abstract override def onLoad = {
super.onLoad //Initialize BootableActorLoaderService before remote service
abstract override def onLoad = {
if (config.getBool("akka.remote.server.service", true)) {
if (config.getBool("akka.remote.cluster.service", true)) Cluster.start(self.applicationLoader)
log.info("Initializing Remote Actors Service...")
startRemoteService
log.info("Remote Actors Service initialized")
}
super.onLoad
}
abstract override def onUnload = {

View file

@ -261,20 +261,14 @@ class RemoteServer extends Logging {
/**
* Register Remote Actor by the Actor's 'id' field. It starts the Actor if it is not started already.
*/
def register(actorRef: ActorRef) = synchronized {
if (_isRunning) {
if (!actorRef.isRunning) actorRef.start
log.info("Registering server side remote actor [%s] with id [%s]", actorRef.actorClass.getName, actorRef.id)
RemoteServer.actorsFor(RemoteServer.Address(hostname, port)).actors.put(actorRef.id, actorRef)
}
}
def register(actorRef: ActorRef): Unit = register(actorRef.id,actorRef)
/**
* Register Remote Actor by a specific 'id' passed as argument.
* <p/>
* NOTE: If you use this method to register your remote actor then you must unregister the actor by this ID yourself.
*/
def register(id: String, actorRef: ActorRef) = synchronized {
def register(id: String, actorRef: ActorRef): Unit = synchronized {
if (_isRunning) {
if (!actorRef.isRunning) actorRef.start
log.info("Registering server side remote actor [%s] with id [%s]", actorRef.actorClass.getName, id)
@ -285,7 +279,7 @@ class RemoteServer extends Logging {
/**
* Unregister Remote Actor that is registered using its 'id' field (not custom ID).
*/
def unregister(actorRef: ActorRef) = synchronized {
def unregister(actorRef: ActorRef):Unit = synchronized {
if (_isRunning) {
log.info("Unregistering server side remote actor [%s] with id [%s]", actorRef.actorClass.getName, actorRef.id)
val server = RemoteServer.actorsFor(RemoteServer.Address(hostname, port))
@ -299,7 +293,7 @@ class RemoteServer extends Logging {
* <p/>
* NOTE: You need to call this method if you have registered an actor by a custom ID.
*/
def unregister(id: String) = synchronized {
def unregister(id: String):Unit = synchronized {
if (_isRunning) {
log.info("Unregistering server side remote actor with id [%s]", id)
val server = RemoteServer.actorsFor(RemoteServer.Address(hostname, port))
@ -509,7 +503,8 @@ class RemoteServerHandler(
val uuid = actorInfo.getUuid
val timeout = actorInfo.getTimeout
val actorRefOrNull = actors.get(uuid)
val actorRefOrNull = actors get uuid
if (actorRefOrNull eq null) {
try {
log.info("Creating a new remote actor [%s:%s]", name, uuid)