2010-12-14 18:22:46 +01:00
|
|
|
/**
|
|
|
|
|
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package akka.remoteinterface
|
|
|
|
|
|
|
|
|
|
import akka.japi.Creator
|
2010-12-15 17:52:31 +01:00
|
|
|
import akka.actor._
|
|
|
|
|
import akka.util._
|
|
|
|
|
import akka.dispatch.CompletableFuture
|
2010-12-29 16:08:43 +01:00
|
|
|
import akka.AkkaException
|
2011-03-24 12:48:40 +01:00
|
|
|
|
|
|
|
|
import scala.reflect.BeanProperty
|
|
|
|
|
|
|
|
|
|
import java.net.InetSocketAddress
|
|
|
|
|
import java.util.concurrent.ConcurrentHashMap
|
2011-03-24 16:23:37 +01:00
|
|
|
import java.io.{PrintWriter, PrintStream}
|
2010-12-15 17:52:31 +01:00
|
|
|
|
2011-02-28 22:54:32 +01:00
|
|
|
trait RemoteModule {
|
2011-03-31 15:55:30 +02:00
|
|
|
val UUID_PREFIX = "uuid:".intern
|
2010-12-21 14:36:47 +01:00
|
|
|
|
2010-12-15 17:52:31 +01:00
|
|
|
def optimizeLocalScoped_?(): Boolean //Apply optimizations for remote operations in local scope
|
2011-04-07 22:37:36 +02:00
|
|
|
protected[akka] def notifyListeners(message: => Any): Unit
|
2010-12-17 16:09:21 +01:00
|
|
|
|
|
|
|
|
private[akka] def actors: ConcurrentHashMap[String, ActorRef]
|
|
|
|
|
private[akka] def actorsByUuid: ConcurrentHashMap[String, ActorRef]
|
|
|
|
|
private[akka] def actorsFactories: ConcurrentHashMap[String, () => ActorRef]
|
|
|
|
|
private[akka] def typedActors: ConcurrentHashMap[String, AnyRef]
|
|
|
|
|
private[akka] def typedActorsByUuid: ConcurrentHashMap[String, AnyRef]
|
|
|
|
|
private[akka] def typedActorsFactories: ConcurrentHashMap[String, () => AnyRef]
|
2010-12-21 14:36:47 +01:00
|
|
|
|
|
|
|
|
/** Lookup methods **/
|
|
|
|
|
|
2011-04-08 21:16:05 +02:00
|
|
|
private[akka] def findActorByAddress(address: String) : ActorRef = actors.get(address)
|
2010-12-21 14:36:47 +01:00
|
|
|
|
|
|
|
|
private[akka] def findActorByUuid(uuid: String) : ActorRef = actorsByUuid.get(uuid)
|
|
|
|
|
|
2011-04-08 21:16:05 +02:00
|
|
|
private[akka] def findActorFactory(address: String) : () => ActorRef = actorsFactories.get(address)
|
2010-12-21 14:36:47 +01:00
|
|
|
|
2011-04-08 21:16:05 +02:00
|
|
|
private[akka] def findTypedActorByAddress(address: String) : AnyRef = typedActors.get(address)
|
2010-12-21 14:36:47 +01:00
|
|
|
|
2011-04-08 21:16:05 +02:00
|
|
|
private[akka] def findTypedActorFactory(address: String) : () => AnyRef = typedActorsFactories.get(address)
|
2010-12-21 14:36:47 +01:00
|
|
|
|
|
|
|
|
private[akka] def findTypedActorByUuid(uuid: String) : AnyRef = typedActorsByUuid.get(uuid)
|
|
|
|
|
|
2011-04-08 21:16:05 +02:00
|
|
|
private[akka] def findActorByAddressOrUuid(address: String, uuid: String) : ActorRef = {
|
|
|
|
|
var actorRefOrNull = if (address.startsWith(UUID_PREFIX)) findActorByUuid(address.substring(UUID_PREFIX.length))
|
|
|
|
|
else findActorByAddress(address)
|
2010-12-21 14:36:47 +01:00
|
|
|
if (actorRefOrNull eq null) actorRefOrNull = findActorByUuid(uuid)
|
|
|
|
|
actorRefOrNull
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-08 21:16:05 +02:00
|
|
|
private[akka] def findTypedActorByAddressOrUuid(address: String, uuid: String) : AnyRef = {
|
|
|
|
|
var actorRefOrNull = if (address.startsWith(UUID_PREFIX)) findTypedActorByUuid(address.substring(UUID_PREFIX.length))
|
|
|
|
|
else findTypedActorByAddress(address)
|
2010-12-21 14:36:47 +01:00
|
|
|
if (actorRefOrNull eq null) actorRefOrNull = findTypedActorByUuid(uuid)
|
|
|
|
|
actorRefOrNull
|
|
|
|
|
}
|
2010-12-15 17:52:31 +01:00
|
|
|
}
|
|
|
|
|
|
2010-12-29 16:08:43 +01:00
|
|
|
/**
|
|
|
|
|
* Life-cycle events for RemoteClient.
|
|
|
|
|
*/
|
2011-01-05 17:03:40 +01:00
|
|
|
sealed trait RemoteClientLifeCycleEvent
|
2010-12-29 16:08:43 +01:00
|
|
|
case class RemoteClientError(
|
2010-12-30 14:59:00 +01:00
|
|
|
@BeanProperty cause: Throwable,
|
2011-01-05 17:03:40 +01:00
|
|
|
@BeanProperty client: RemoteClientModule,
|
|
|
|
|
@BeanProperty remoteAddress: InetSocketAddress) extends RemoteClientLifeCycleEvent
|
2010-12-29 16:08:43 +01:00
|
|
|
case class RemoteClientDisconnected(
|
2011-01-05 17:03:40 +01:00
|
|
|
@BeanProperty client: RemoteClientModule,
|
|
|
|
|
@BeanProperty remoteAddress: InetSocketAddress) extends RemoteClientLifeCycleEvent
|
2010-12-29 16:08:43 +01:00
|
|
|
case class RemoteClientConnected(
|
2011-01-05 17:03:40 +01:00
|
|
|
@BeanProperty client: RemoteClientModule,
|
|
|
|
|
@BeanProperty remoteAddress: InetSocketAddress) extends RemoteClientLifeCycleEvent
|
2010-12-29 16:08:43 +01:00
|
|
|
case class RemoteClientStarted(
|
2011-01-05 17:03:40 +01:00
|
|
|
@BeanProperty client: RemoteClientModule,
|
|
|
|
|
@BeanProperty remoteAddress: InetSocketAddress) extends RemoteClientLifeCycleEvent
|
2010-12-29 16:08:43 +01:00
|
|
|
case class RemoteClientShutdown(
|
2011-01-05 17:03:40 +01:00
|
|
|
@BeanProperty client: RemoteClientModule,
|
|
|
|
|
@BeanProperty remoteAddress: InetSocketAddress) extends RemoteClientLifeCycleEvent
|
2010-12-30 14:59:00 +01:00
|
|
|
case class RemoteClientWriteFailed(
|
|
|
|
|
@BeanProperty request: AnyRef,
|
|
|
|
|
@BeanProperty cause: Throwable,
|
2011-01-05 17:03:40 +01:00
|
|
|
@BeanProperty client: RemoteClientModule,
|
|
|
|
|
@BeanProperty remoteAddress: InetSocketAddress) extends RemoteClientLifeCycleEvent
|
2010-12-29 16:08:43 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Life-cycle events for RemoteServer.
|
|
|
|
|
*/
|
2011-01-05 17:03:40 +01:00
|
|
|
sealed trait RemoteServerLifeCycleEvent
|
2010-12-29 16:08:43 +01:00
|
|
|
case class RemoteServerStarted(
|
|
|
|
|
@BeanProperty val server: RemoteServerModule) extends RemoteServerLifeCycleEvent
|
|
|
|
|
case class RemoteServerShutdown(
|
|
|
|
|
@BeanProperty val server: RemoteServerModule) extends RemoteServerLifeCycleEvent
|
|
|
|
|
case class RemoteServerError(
|
|
|
|
|
@BeanProperty val cause: Throwable,
|
|
|
|
|
@BeanProperty val server: RemoteServerModule) extends RemoteServerLifeCycleEvent
|
|
|
|
|
case class RemoteServerClientConnected(
|
|
|
|
|
@BeanProperty val server: RemoteServerModule,
|
|
|
|
|
@BeanProperty val clientAddress: Option[InetSocketAddress]) extends RemoteServerLifeCycleEvent
|
|
|
|
|
case class RemoteServerClientDisconnected(
|
|
|
|
|
@BeanProperty val server: RemoteServerModule,
|
|
|
|
|
@BeanProperty val clientAddress: Option[InetSocketAddress]) extends RemoteServerLifeCycleEvent
|
|
|
|
|
case class RemoteServerClientClosed(
|
|
|
|
|
@BeanProperty val server: RemoteServerModule,
|
|
|
|
|
@BeanProperty val clientAddress: Option[InetSocketAddress]) extends RemoteServerLifeCycleEvent
|
2011-01-03 14:44:15 +01:00
|
|
|
case class RemoteServerWriteFailed(
|
|
|
|
|
@BeanProperty request: AnyRef,
|
|
|
|
|
@BeanProperty cause: Throwable,
|
2011-01-05 17:03:40 +01:00
|
|
|
@BeanProperty server: RemoteServerModule,
|
|
|
|
|
@BeanProperty clientAddress: Option[InetSocketAddress]) extends RemoteServerLifeCycleEvent
|
2010-12-29 16:08:43 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Thrown for example when trying to send a message using a RemoteClient that is either not started or shut down.
|
|
|
|
|
*/
|
2011-03-24 16:23:37 +01:00
|
|
|
class RemoteClientException private[akka] (
|
|
|
|
|
message: String,
|
|
|
|
|
@BeanProperty val client: RemoteClientModule,
|
|
|
|
|
val remoteAddress: InetSocketAddress) extends AkkaException(message)
|
2010-12-29 16:08:43 +01:00
|
|
|
|
|
|
|
|
/**
|
2011-03-31 15:55:30 +02:00
|
|
|
* Thrown when the remote server actor dispatching fails for some reason.
|
|
|
|
|
*/
|
|
|
|
|
class RemoteServerException private[akka] (message: String) extends AkkaException(message)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Thrown when a remote exception sent over the wire cannot be loaded and instantiated
|
2010-12-29 16:08:43 +01:00
|
|
|
*/
|
2011-03-25 16:25:36 +01:00
|
|
|
case class CannotInstantiateRemoteExceptionDueToRemoteProtocolParsingErrorException private[akka] (cause: Throwable, originalClassName: String, originalMessage: String)
|
2011-03-24 16:23:37 +01:00
|
|
|
extends AkkaException("\nParsingError[%s]\nOriginalException[%s]\nOriginalMessage[%s]"
|
|
|
|
|
.format(cause.toString, originalClassName, originalMessage)) {
|
|
|
|
|
override def printStackTrace = cause.printStackTrace
|
|
|
|
|
override def printStackTrace(printStream: PrintStream) = cause.printStackTrace(printStream)
|
|
|
|
|
override def printStackTrace(printWriter: PrintWriter) = cause.printStackTrace(printWriter)
|
|
|
|
|
}
|
2010-12-15 17:52:31 +01:00
|
|
|
|
|
|
|
|
abstract class RemoteSupport extends ListenerManagement with RemoteServerModule with RemoteClientModule {
|
2011-03-24 12:48:40 +01:00
|
|
|
|
2011-05-03 21:04:45 +02:00
|
|
|
val eventHandler: ActorRef = {
|
|
|
|
|
val handler = Actor.actorOf[RemoteEventHandler](classOf[RemoteEventHandler].getName).start()
|
2011-03-24 12:48:40 +01:00
|
|
|
// add the remote client and server listener that pipes the events to the event handler system
|
|
|
|
|
addListener(handler)
|
|
|
|
|
handler
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-15 17:52:31 +01:00
|
|
|
def shutdown {
|
2011-04-12 10:53:56 +02:00
|
|
|
eventHandler.stop()
|
2011-03-24 12:48:40 +01:00
|
|
|
removeListener(eventHandler)
|
2011-05-03 21:04:45 +02:00
|
|
|
this.shutdownClientModule()
|
|
|
|
|
this.shutdownServerModule()
|
2010-12-17 16:09:21 +01:00
|
|
|
clear
|
2010-12-15 17:52:31 +01:00
|
|
|
}
|
2010-12-22 10:10:04 +01:00
|
|
|
|
2010-12-15 17:52:31 +01:00
|
|
|
protected override def manageLifeCycleOfListeners = false
|
2011-04-07 22:37:36 +02:00
|
|
|
protected[akka] override def notifyListeners(message: => Any): Unit = super.notifyListeners(message)
|
2010-12-17 16:09:21 +01:00
|
|
|
|
2010-12-21 14:36:47 +01:00
|
|
|
private[akka] val actors = new ConcurrentHashMap[String, ActorRef]
|
|
|
|
|
private[akka] val actorsByUuid = new ConcurrentHashMap[String, ActorRef]
|
|
|
|
|
private[akka] val actorsFactories = new ConcurrentHashMap[String, () => ActorRef]
|
|
|
|
|
private[akka] val typedActors = new ConcurrentHashMap[String, AnyRef]
|
|
|
|
|
private[akka] val typedActorsByUuid = new ConcurrentHashMap[String, AnyRef]
|
2010-12-17 16:09:21 +01:00
|
|
|
private[akka] val typedActorsFactories = new ConcurrentHashMap[String, () => AnyRef]
|
|
|
|
|
|
|
|
|
|
def clear {
|
2011-03-08 11:46:03 +01:00
|
|
|
actors.clear
|
|
|
|
|
actorsByUuid.clear
|
|
|
|
|
typedActors.clear
|
|
|
|
|
typedActorsByUuid.clear
|
2011-03-07 21:54:00 +01:00
|
|
|
actorsFactories.clear
|
|
|
|
|
typedActorsFactories.clear
|
2010-12-17 16:09:21 +01:00
|
|
|
}
|
2010-12-15 17:52:31 +01:00
|
|
|
}
|
2010-12-14 18:22:46 +01:00
|
|
|
|
|
|
|
|
/**
|
2011-01-04 13:24:28 +01:00
|
|
|
* This is the interface for the RemoteServer functionality, it's used in Actor.remote
|
2010-12-14 18:22:46 +01:00
|
|
|
*/
|
2010-12-15 17:52:31 +01:00
|
|
|
trait RemoteServerModule extends RemoteModule {
|
2010-12-14 18:22:46 +01:00
|
|
|
protected val guard = new ReentrantGuard
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Signals whether the server is up and running or not
|
|
|
|
|
*/
|
|
|
|
|
def isRunning: Boolean
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the name of the server instance
|
|
|
|
|
*/
|
|
|
|
|
def name: String
|
|
|
|
|
|
|
|
|
|
/**
|
2010-12-21 14:36:47 +01:00
|
|
|
* Gets the address of the server instance
|
2010-12-14 18:22:46 +01:00
|
|
|
*/
|
2010-12-21 14:36:47 +01:00
|
|
|
def address: InetSocketAddress
|
2010-12-14 18:22:46 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Starts the server up
|
|
|
|
|
*/
|
2011-01-05 16:36:50 +01:00
|
|
|
def start(): RemoteServerModule =
|
2011-04-08 15:29:14 +02:00
|
|
|
start(ReflectiveAccess.RemoteModule.configDefaultAddress.getAddress.getHostAddress,
|
|
|
|
|
ReflectiveAccess.RemoteModule.configDefaultAddress.getPort,
|
2011-01-05 17:03:40 +01:00
|
|
|
None)
|
2011-01-05 16:36:50 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Starts the server up
|
|
|
|
|
*/
|
|
|
|
|
def start(loader: ClassLoader): RemoteServerModule =
|
2011-04-08 15:29:14 +02:00
|
|
|
start(ReflectiveAccess.RemoteModule.configDefaultAddress.getAddress.getHostAddress,
|
|
|
|
|
ReflectiveAccess.RemoteModule.configDefaultAddress.getPort,
|
2011-01-05 16:36:50 +01:00
|
|
|
Option(loader))
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Starts the server up
|
|
|
|
|
*/
|
2011-01-05 17:03:40 +01:00
|
|
|
def start(host: String, port: Int): RemoteServerModule =
|
|
|
|
|
start(host,port,None)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Starts the server up
|
|
|
|
|
*/
|
|
|
|
|
def start(host: String, port: Int, loader: ClassLoader): RemoteServerModule =
|
|
|
|
|
start(host,port,Option(loader))
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Starts the server up
|
|
|
|
|
*/
|
|
|
|
|
def start(host: String, port: Int, loader: Option[ClassLoader]): RemoteServerModule
|
2010-12-14 18:22:46 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Shuts the server down
|
|
|
|
|
*/
|
2011-01-05 16:36:50 +01:00
|
|
|
def shutdownServerModule(): Unit
|
2010-12-14 18:22:46 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Register typed actor by interface name.
|
|
|
|
|
*/
|
|
|
|
|
def registerTypedActor(intfClass: Class[_], typedActor: AnyRef) : Unit = registerTypedActor(intfClass.getName, typedActor)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Register remote typed actor by a specific id.
|
2011-04-08 21:16:05 +02:00
|
|
|
* @param address actor address
|
2010-12-14 18:22:46 +01:00
|
|
|
* @param typedActor typed actor to register
|
|
|
|
|
*/
|
2011-04-08 21:16:05 +02:00
|
|
|
def registerTypedActor(address: String, typedActor: AnyRef): Unit
|
2010-12-14 18:22:46 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Register typed actor by interface name.
|
|
|
|
|
*/
|
|
|
|
|
def registerTypedPerSessionActor(intfClass: Class[_], factory: => AnyRef) : Unit = registerTypedActor(intfClass.getName, factory)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Register typed actor by interface name.
|
|
|
|
|
* Java API
|
|
|
|
|
*/
|
|
|
|
|
def registerTypedPerSessionActor(intfClass: Class[_], factory: Creator[AnyRef]) : Unit = registerTypedActor(intfClass.getName, factory)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Register remote typed actor by a specific id.
|
2011-04-08 21:16:05 +02:00
|
|
|
* @param address actor address
|
2010-12-14 18:22:46 +01:00
|
|
|
* @param typedActor typed actor to register
|
|
|
|
|
*/
|
2011-04-08 21:16:05 +02:00
|
|
|
def registerTypedPerSessionActor(address: String, factory: => AnyRef): Unit
|
2010-12-14 18:22:46 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Register remote typed actor by a specific id.
|
2011-04-08 21:16:05 +02:00
|
|
|
* @param address actor address
|
2010-12-14 18:22:46 +01:00
|
|
|
* @param typedActor typed actor to register
|
|
|
|
|
* Java API
|
|
|
|
|
*/
|
2011-04-08 21:16:05 +02:00
|
|
|
def registerTypedPerSessionActor(address: String, factory: Creator[AnyRef]): Unit = registerTypedPerSessionActor(address, factory.create)
|
2010-12-14 18:22:46 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Register Remote Actor by the Actor's 'id' field. It starts the Actor if it is not started already.
|
|
|
|
|
*/
|
2011-04-08 21:16:05 +02:00
|
|
|
def register(actorRef: ActorRef): Unit = register(actorRef.address, actorRef)
|
2010-12-14 18:22:46 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Register Remote Actor by the Actor's uuid field. It starts the Actor if it is not started already.
|
|
|
|
|
*/
|
|
|
|
|
def registerByUuid(actorRef: ActorRef): Unit
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
2011-04-08 21:16:05 +02:00
|
|
|
def register(address: String, actorRef: ActorRef): Unit
|
2010-12-14 18:22:46 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Register Remote Session 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.
|
|
|
|
|
*/
|
2011-04-08 21:16:05 +02:00
|
|
|
def registerPerSession(address: String, factory: => ActorRef): Unit
|
2010-12-14 18:22:46 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Register Remote Session 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.
|
|
|
|
|
* Java API
|
|
|
|
|
*/
|
2011-04-08 21:16:05 +02:00
|
|
|
def registerPerSession(address: String, factory: Creator[ActorRef]): Unit = registerPerSession(address, factory.create)
|
2010-12-14 18:22:46 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Unregister Remote Actor that is registered using its 'id' field (not custom ID).
|
|
|
|
|
*/
|
|
|
|
|
def unregister(actorRef: ActorRef): Unit
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Unregister Remote Actor by specific 'id'.
|
|
|
|
|
* <p/>
|
|
|
|
|
* NOTE: You need to call this method if you have registered an actor by a custom ID.
|
|
|
|
|
*/
|
2011-04-08 21:16:05 +02:00
|
|
|
def unregister(address: String): Unit
|
2010-12-14 18:22:46 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Unregister Remote Actor by specific 'id'.
|
|
|
|
|
* <p/>
|
|
|
|
|
* NOTE: You need to call this method if you have registered an actor by a custom ID.
|
|
|
|
|
*/
|
2011-04-08 21:16:05 +02:00
|
|
|
def unregisterPerSession(address: String): Unit
|
2010-12-14 18:22:46 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Unregister Remote Typed Actor by specific 'id'.
|
|
|
|
|
* <p/>
|
|
|
|
|
* NOTE: You need to call this method if you have registered an actor by a custom ID.
|
|
|
|
|
*/
|
2011-04-08 21:16:05 +02:00
|
|
|
def unregisterTypedActor(address: String): Unit
|
2010-12-14 18:22:46 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Unregister Remote Typed Actor by specific 'id'.
|
|
|
|
|
* <p/>
|
|
|
|
|
* NOTE: You need to call this method if you have registered an actor by a custom ID.
|
|
|
|
|
*/
|
2011-04-08 21:16:05 +02:00
|
|
|
def unregisterTypedPerSessionActor(address: String): Unit
|
2010-12-15 17:52:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
trait RemoteClientModule extends RemoteModule { self: RemoteModule =>
|
|
|
|
|
|
2011-04-29 15:47:56 +02:00
|
|
|
def actorFor(address: String, hostname: String, port: Int): ActorRef =
|
|
|
|
|
actorFor(address, Actor.TIMEOUT, hostname, port, None)
|
2010-12-15 17:52:31 +01:00
|
|
|
|
2011-04-29 15:47:56 +02:00
|
|
|
def actorFor(address: String, hostname: String, port: Int, loader: ClassLoader): ActorRef =
|
|
|
|
|
actorFor(address, Actor.TIMEOUT, hostname, port, Some(loader))
|
2010-12-15 17:52:31 +01:00
|
|
|
|
2011-04-29 15:47:56 +02:00
|
|
|
def actorFor(address: String, timeout: Long, hostname: String, port: Int): ActorRef =
|
|
|
|
|
actorFor(address, timeout, hostname, port, None)
|
2010-12-15 17:52:31 +01:00
|
|
|
|
2011-04-29 15:47:56 +02:00
|
|
|
def actorFor(address: String, timeout: Long, hostname: String, port: Int, loader: ClassLoader): ActorRef =
|
|
|
|
|
actorFor(address, timeout, hostname, port, Some(loader))
|
2010-12-15 17:52:31 +01:00
|
|
|
|
|
|
|
|
def typedActorFor[T](intfClass: Class[T], serviceIdOrClassName: String, hostname: String, port: Int): T =
|
2011-04-29 15:47:56 +02:00
|
|
|
typedActorFor(intfClass, serviceIdOrClassName, Actor.TIMEOUT, hostname, port, None)
|
2010-12-15 17:52:31 +01:00
|
|
|
|
|
|
|
|
def typedActorFor[T](intfClass: Class[T], serviceIdOrClassName: String, timeout: Long, hostname: String, port: Int): T =
|
2011-04-29 15:47:56 +02:00
|
|
|
typedActorFor(intfClass, serviceIdOrClassName, timeout, hostname, port, None)
|
2010-12-15 17:52:31 +01:00
|
|
|
|
|
|
|
|
def typedActorFor[T](intfClass: Class[T], serviceIdOrClassName: String, timeout: Long, hostname: String, port: Int, loader: ClassLoader): T =
|
2011-04-29 15:47:56 +02:00
|
|
|
typedActorFor(intfClass, serviceIdOrClassName, timeout, hostname, port, Some(loader))
|
2010-12-15 17:52:31 +01:00
|
|
|
|
2010-12-29 17:59:38 +01:00
|
|
|
/**
|
|
|
|
|
* Clean-up all open connections.
|
|
|
|
|
*/
|
2011-01-05 16:36:50 +01:00
|
|
|
def shutdownClientModule(): Unit
|
2010-12-29 17:59:38 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Shuts down a specific client connected to the supplied remote address returns true if successful
|
|
|
|
|
*/
|
|
|
|
|
def shutdownClientConnection(address: InetSocketAddress): Boolean
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Restarts a specific client connected to the supplied remote address, but only if the client is not shut down
|
|
|
|
|
*/
|
|
|
|
|
def restartClientConnection(address: InetSocketAddress): Boolean
|
|
|
|
|
|
|
|
|
|
/** Methods that needs to be implemented by a transport **/
|
2010-12-15 17:52:31 +01:00
|
|
|
|
2011-04-29 15:47:56 +02:00
|
|
|
protected[akka] def typedActorFor[T](intfClass: Class[T], serviceaddress: String, timeout: Long, host: String, port: Int, loader: Option[ClassLoader]): T
|
2010-12-15 17:52:31 +01:00
|
|
|
|
2011-04-29 15:47:56 +02:00
|
|
|
protected[akka] def actorFor(address: String, timeout: Long, hostname: String, port: Int, loader: Option[ClassLoader]): ActorRef
|
2010-12-15 17:52:31 +01:00
|
|
|
|
2010-12-29 17:59:38 +01:00
|
|
|
protected[akka] def send[T](message: Any,
|
|
|
|
|
senderOption: Option[ActorRef],
|
|
|
|
|
senderFuture: Option[CompletableFuture[T]],
|
2011-04-18 13:18:47 +02:00
|
|
|
remoteAddress: InetSocketAddress,
|
2010-12-29 17:59:38 +01:00
|
|
|
timeout: Long,
|
|
|
|
|
isOneWay: Boolean,
|
|
|
|
|
actorRef: ActorRef,
|
|
|
|
|
typedActorInfo: Option[Tuple2[String, String]],
|
|
|
|
|
actorType: ActorType,
|
|
|
|
|
loader: Option[ClassLoader]): Option[CompletableFuture[T]]
|
2011-04-01 14:29:26 +02:00
|
|
|
}
|