akka-core now compiles

This commit is contained in:
Jonas Bonér 2010-05-01 12:59:24 +02:00
parent 803838d315
commit 22116b922a
52 changed files with 755 additions and 1100 deletions

View file

@ -198,7 +198,7 @@ class RemoteServer extends Logging {
/**
* Register Remote Actor by the Actor's 'id' field.
*/
def register(actor: Actor) = synchronized {
def register(actor: ActorID) = synchronized {
if (_isRunning) {
log.info("Registering server side remote actor [%s] with id [%s]", actor.getClass.getName, actor.getId)
RemoteServer.actorsFor(RemoteServer.Address(hostname, port)).actors.put(actor.getId, actor)
@ -208,7 +208,7 @@ class RemoteServer extends Logging {
/**
* Register Remote Actor by a specific 'id' passed as argument.
*/
def register(id: String, actor: Actor) = synchronized {
def register(id: String, actor: ActorID) = synchronized {
if (_isRunning) {
log.info("Registering server side remote actor [%s] with id [%s]", actor.getClass.getName, id)
RemoteServer.actorsFor(RemoteServer.Address(hostname, port)).actors.put(id, actor)
@ -225,7 +225,7 @@ class RemoteServerPipelineFactory(
val name: String,
val openChannels: ChannelGroup,
val loader: Option[ClassLoader],
val actors: JMap[String, Actor],
val actors: JMap[String, ActorID],
val activeObjects: JMap[String, AnyRef]) extends ChannelPipelineFactory {
import RemoteServer._
@ -256,7 +256,7 @@ class RemoteServerHandler(
val name: String,
val openChannels: ChannelGroup,
val applicationLoader: Option[ClassLoader],
val actors: JMap[String, Actor],
val actors: JMap[String, ActorID],
val activeObjects: JMap[String, AnyRef]) extends SimpleChannelUpstreamHandler with Logging {
val AW_PROXY_PREFIX = "$$ProxiedByAW".intern
@ -300,8 +300,8 @@ class RemoteServerHandler(
private def dispatchToActor(request: RemoteRequest, channel: Channel) = {
log.debug("Dispatching to remote actor [%s]", request.getTarget)
val actor = createActor(request.getTarget, request.getUuid, request.getTimeout)
actor.start
val actorId = createActor(request.getTarget, request.getUuid, request.getTimeout)
actorId.start
val message = RemoteProtocolBuilder.getMessage(request)
if (request.getIsOneWay) {
@ -310,19 +310,19 @@ class RemoteServerHandler(
val targetClass = if (request.hasSourceTarget) request.getSourceTarget
else request.getTarget
val remoteActor = createActor(targetClass, request.getSourceUuid, request.getTimeout)
if (!remoteActor.isRunning) {
remoteActor.makeRemote(request.getSourceHostname, request.getSourcePort)
remoteActor.start
val remoteActorId = createActor(targetClass, request.getSourceUuid, request.getTimeout)
if (!remoteActorId.isRunning) {
remoteActorId.makeRemote(request.getSourceHostname, request.getSourcePort)
remoteActorId.start
}
actor.!(message)(Some(remoteActor))
actorId.!(message)(Some(remoteActorId))
} else {
// couldn't find a way to reply, send the message without a source/sender
actor ! message
actorId ! message
}
} else {
try {
val resultOrNone = actor !! message
val resultOrNone = actorId !! message
val result: AnyRef = if (resultOrNone.isDefined) resultOrNone.get else null
log.debug("Returning result from actor invocation [%s]", result)
val replyBuilder = RemoteReply.newBuilder
@ -440,9 +440,9 @@ class RemoteServerHandler(
* If actor already created then just return it from the registry.
* Does not start the actor.
*/
private def createActor(name: String, uuid: String, timeout: Long): Actor = {
val actorOrNull = actors.get(uuid)
if (actorOrNull eq null) {
private def createActor(name: String, uuid: String, timeout: Long): ActorID = {
val actorIdOrNull = actors.get(uuid)
if (actorIdOrNull eq null) {
try {
log.info("Creating a new remote actor [%s:%s]", name, uuid)
val clazz = if (applicationLoader.isDefined) applicationLoader.get.loadClass(name)
@ -451,13 +451,14 @@ class RemoteServerHandler(
newInstance._uuid = uuid
newInstance.timeout = timeout
newInstance._remoteAddress = None
actors.put(uuid, newInstance)
newInstance
val actorId = new ActorID(() => newInstance)
actors.put(uuid, actorId)
actorId
} catch {
case e =>
log.error(e, "Could not create remote actor instance")
throw e
}
} else actorOrNull
} else actorIdOrNull
}
}