2010-12-14 18:22:46 +01:00
|
|
|
|
/**
|
2011-07-14 16:03:08 +02:00
|
|
|
|
* Copyright (C) 2009-2010 Typesafe Inc. <http://www.typesafe.com>
|
2010-12-14 18:22:46 +01:00
|
|
|
|
*/
|
|
|
|
|
|
|
2011-09-20 21:44:50 +02:00
|
|
|
|
package akka.remote
|
2010-12-14 18:22:46 +01:00
|
|
|
|
|
2010-12-15 17:52:31 +01:00
|
|
|
|
import akka.actor._
|
2011-11-10 20:08:00 +01:00
|
|
|
|
import akka.AkkaException
|
2011-03-24 12:48:40 +01:00
|
|
|
|
import scala.reflect.BeanProperty
|
2011-11-10 17:39:04 +01:00
|
|
|
|
import java.io.{ PrintWriter, PrintStream }
|
2011-03-24 12:48:40 +01:00
|
|
|
|
import java.net.InetSocketAddress
|
2011-11-29 16:32:50 +01:00
|
|
|
|
import java.net.URI
|
|
|
|
|
|
import java.net.URISyntaxException
|
|
|
|
|
|
import java.net.InetAddress
|
2011-11-29 21:52:18 +01:00
|
|
|
|
import java.net.UnknownHostException
|
2011-12-11 20:00:26 +01:00
|
|
|
|
import java.net.UnknownServiceException
|
2011-12-19 13:35:10 +01:00
|
|
|
|
import akka.event.Logging
|
2011-11-10 17:39:04 +01:00
|
|
|
|
|
2011-12-11 20:00:26 +01:00
|
|
|
|
/**
|
|
|
|
|
|
* Interface for remote transports to encode their addresses. The three parts
|
|
|
|
|
|
* are named according to the URI spec (precisely java.net.URI) which is used
|
|
|
|
|
|
* for parsing. That means that the address’ parts must conform to what an
|
|
|
|
|
|
* URI expects, but otherwise each transport may assign a different meaning
|
|
|
|
|
|
* to these parts.
|
|
|
|
|
|
*/
|
|
|
|
|
|
trait RemoteTransportAddress {
|
|
|
|
|
|
def protocol: String
|
|
|
|
|
|
def host: String
|
|
|
|
|
|
def port: Int
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
trait ParsedTransportAddress extends RemoteTransportAddress
|
|
|
|
|
|
|
|
|
|
|
|
case class RemoteNettyAddress(host: String, ip: Option[InetAddress], port: Int) extends ParsedTransportAddress {
|
|
|
|
|
|
def protocol = "akka"
|
2011-12-17 15:54:09 +01:00
|
|
|
|
|
|
|
|
|
|
override def toString(): String = "akka://" + host + ":" + port
|
2011-12-11 20:00:26 +01:00
|
|
|
|
}
|
2011-11-10 17:39:04 +01:00
|
|
|
|
|
2011-12-11 20:00:26 +01:00
|
|
|
|
object RemoteNettyAddress {
|
|
|
|
|
|
def apply(host: String, port: Int): RemoteNettyAddress = {
|
2012-01-16 20:18:08 +01:00
|
|
|
|
// TODO ticket #1639
|
2011-12-11 20:00:26 +01:00
|
|
|
|
val ip = try Some(InetAddress.getByName(host)) catch { case _: UnknownHostException ⇒ None }
|
|
|
|
|
|
new RemoteNettyAddress(host, ip, port)
|
2011-11-29 21:52:18 +01:00
|
|
|
|
}
|
2011-12-11 20:00:26 +01:00
|
|
|
|
def apply(s: String): RemoteNettyAddress = {
|
|
|
|
|
|
val RE = """([^:]+):(\d+)""".r
|
|
|
|
|
|
s match {
|
|
|
|
|
|
case RE(h, p) ⇒ apply(h, Integer.parseInt(p))
|
|
|
|
|
|
case _ ⇒ throw new IllegalArgumentException("cannot parse " + s + " as <host:port>")
|
|
|
|
|
|
}
|
2011-11-25 12:02:25 +01:00
|
|
|
|
}
|
2011-12-11 20:00:26 +01:00
|
|
|
|
}
|
2011-12-09 20:19:59 +01:00
|
|
|
|
|
2011-12-11 20:00:26 +01:00
|
|
|
|
case class UnparsedTransportAddress(protocol: String, host: String, port: Int) extends RemoteTransportAddress {
|
|
|
|
|
|
def parse(transports: TransportsMap): RemoteTransportAddress =
|
|
|
|
|
|
transports.get(protocol)
|
|
|
|
|
|
.map(_(host, port))
|
|
|
|
|
|
.toRight("protocol " + protocol + " not known")
|
|
|
|
|
|
.joinRight.fold(UnparseableTransportAddress(protocol, host, port, _), identity)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case class UnparseableTransportAddress(protocol: String, host: String, port: Int, error: String) extends RemoteTransportAddress
|
|
|
|
|
|
|
|
|
|
|
|
case class RemoteSystemAddress[+T <: ParsedTransportAddress](system: String, transport: T) extends Address {
|
|
|
|
|
|
def protocol = transport.protocol
|
|
|
|
|
|
@transient
|
|
|
|
|
|
lazy val hostPort = system + "@" + transport.host + ":" + transport.port
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case class UnparsedSystemAddress[+T <: RemoteTransportAddress](system: Option[String], transport: T) {
|
|
|
|
|
|
def parse(transports: TransportsMap): Either[UnparsedSystemAddress[UnparseableTransportAddress], RemoteSystemAddress[ParsedTransportAddress]] =
|
|
|
|
|
|
system match {
|
|
|
|
|
|
case Some(sys) ⇒
|
|
|
|
|
|
transport match {
|
|
|
|
|
|
case x: ParsedTransportAddress ⇒ Right(RemoteSystemAddress(sys, x))
|
|
|
|
|
|
case y: UnparsedTransportAddress ⇒
|
|
|
|
|
|
y.parse(transports) match {
|
|
|
|
|
|
case x: ParsedTransportAddress ⇒ Right(RemoteSystemAddress(sys, x))
|
|
|
|
|
|
case y: UnparseableTransportAddress ⇒ Left(UnparsedSystemAddress(system, y))
|
|
|
|
|
|
case z ⇒ Left(UnparsedSystemAddress(system, UnparseableTransportAddress(z.protocol, z.host, z.port, "cannot parse " + z)))
|
|
|
|
|
|
}
|
|
|
|
|
|
case z ⇒ Left(UnparsedSystemAddress(system, UnparseableTransportAddress(z.protocol, z.host, z.port, "cannot parse " + z)))
|
|
|
|
|
|
}
|
|
|
|
|
|
case None ⇒ Left(UnparsedSystemAddress(None, UnparseableTransportAddress(transport.protocol, transport.host, transport.port, "no system name specified")))
|
|
|
|
|
|
}
|
2011-12-09 20:19:59 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
object RemoteAddressExtractor {
|
2011-12-11 20:00:26 +01:00
|
|
|
|
def unapply(s: String): Option[UnparsedSystemAddress[UnparsedTransportAddress]] = {
|
2011-12-09 20:19:59 +01:00
|
|
|
|
try {
|
2011-12-11 20:00:26 +01:00
|
|
|
|
val uri = new URI(s)
|
|
|
|
|
|
if (uri.getScheme == null || uri.getHost == null || uri.getPort == -1) None
|
|
|
|
|
|
else Some(UnparsedSystemAddress(Option(uri.getUserInfo), UnparsedTransportAddress(uri.getScheme, uri.getHost, uri.getPort)))
|
2011-12-09 20:19:59 +01:00
|
|
|
|
} catch {
|
|
|
|
|
|
case _: URISyntaxException ⇒ None
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2011-11-10 17:39:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2011-12-11 20:00:26 +01:00
|
|
|
|
object RemoteActorPath {
|
|
|
|
|
|
def unapply(addr: String): Option[(UnparsedSystemAddress[UnparsedTransportAddress], Iterable[String])] = {
|
|
|
|
|
|
try {
|
|
|
|
|
|
val uri = new URI(addr)
|
|
|
|
|
|
if (uri.getScheme == null || uri.getUserInfo == null || uri.getHost == null || uri.getPort == -1 || uri.getPath == null) None
|
|
|
|
|
|
else Some(UnparsedSystemAddress(Some(uri.getUserInfo), UnparsedTransportAddress(uri.getScheme, uri.getHost, uri.getPort)),
|
|
|
|
|
|
ActorPath.split(uri.getPath).drop(1))
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
case _: URISyntaxException ⇒ None
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2011-11-29 16:32:50 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2011-12-11 20:00:26 +01:00
|
|
|
|
object ParsedActorPath {
|
|
|
|
|
|
def unapply(addr: String)(implicit transports: TransportsMap): Option[(RemoteSystemAddress[ParsedTransportAddress], Iterable[String])] = {
|
2011-11-29 16:32:50 +01:00
|
|
|
|
try {
|
|
|
|
|
|
val uri = new URI(addr)
|
2011-12-11 20:00:26 +01:00
|
|
|
|
if (uri.getScheme == null || uri.getUserInfo == null || uri.getHost == null || uri.getPort == -1 || uri.getPath == null) None
|
|
|
|
|
|
else
|
|
|
|
|
|
UnparsedSystemAddress(Some(uri.getUserInfo), UnparsedTransportAddress(uri.getScheme, uri.getHost, uri.getPort)).parse(transports) match {
|
|
|
|
|
|
case Left(_) ⇒ None
|
|
|
|
|
|
case Right(x) ⇒ Some(x, ActorPath.split(uri.getPath).drop(1))
|
|
|
|
|
|
}
|
2011-11-29 16:32:50 +01:00
|
|
|
|
} catch {
|
|
|
|
|
|
case _: URISyntaxException ⇒ None
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2011-11-10 17:39:04 +01:00
|
|
|
|
}
|
2010-12-15 17:52:31 +01:00
|
|
|
|
|
2011-09-15 10:20:18 +02:00
|
|
|
|
class RemoteException(message: String) extends AkkaException(message)
|
|
|
|
|
|
|
2011-02-28 22:54:32 +01:00
|
|
|
|
trait RemoteModule {
|
2011-10-27 12:23:01 +02:00
|
|
|
|
protected[akka] def notifyListeners(message: RemoteLifeCycleEvent): Unit
|
2010-12-15 17:52:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2011-08-29 11:44:33 +02:00
|
|
|
|
/**
|
|
|
|
|
|
* Remote life-cycle events.
|
|
|
|
|
|
*/
|
2011-12-19 13:35:10 +01:00
|
|
|
|
sealed trait RemoteLifeCycleEvent {
|
|
|
|
|
|
def logLevel: Logging.LogLevel
|
|
|
|
|
|
}
|
2011-08-29 11:44:33 +02:00
|
|
|
|
|
2010-12-29 16:08:43 +01:00
|
|
|
|
/**
|
|
|
|
|
|
* Life-cycle events for RemoteClient.
|
|
|
|
|
|
*/
|
2011-08-29 11:44:33 +02:00
|
|
|
|
trait RemoteClientLifeCycleEvent extends RemoteLifeCycleEvent {
|
2011-12-11 20:00:26 +01:00
|
|
|
|
def remoteAddress: ParsedTransportAddress
|
2011-08-29 11:44:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2011-12-11 20:00:26 +01:00
|
|
|
|
case class RemoteClientError[T <: ParsedTransportAddress](
|
2010-12-30 14:59:00 +01:00
|
|
|
|
@BeanProperty cause: Throwable,
|
2011-12-11 20:00:26 +01:00
|
|
|
|
@BeanProperty remote: RemoteSupport[T],
|
2011-12-17 15:54:09 +01:00
|
|
|
|
@BeanProperty remoteAddress: T) extends RemoteClientLifeCycleEvent {
|
2011-12-19 13:35:10 +01:00
|
|
|
|
override def logLevel = Logging.ErrorLevel
|
2011-12-17 15:54:09 +01:00
|
|
|
|
override def toString =
|
|
|
|
|
|
"RemoteClientError@" +
|
|
|
|
|
|
remoteAddress +
|
2011-12-21 16:12:08 +01:00
|
|
|
|
": Error[" +
|
|
|
|
|
|
(if (cause ne null) cause.getClass.getName + ": " + cause.getMessage else "unknown") +
|
2011-12-17 15:54:09 +01:00
|
|
|
|
"]"
|
|
|
|
|
|
}
|
2011-09-08 19:45:16 +02:00
|
|
|
|
|
2011-12-11 20:00:26 +01:00
|
|
|
|
case class RemoteClientDisconnected[T <: ParsedTransportAddress](
|
|
|
|
|
|
@BeanProperty remote: RemoteSupport[T],
|
2011-12-17 15:54:09 +01:00
|
|
|
|
@BeanProperty remoteAddress: T) extends RemoteClientLifeCycleEvent {
|
2011-12-19 13:35:10 +01:00
|
|
|
|
override def logLevel = Logging.DebugLevel
|
2011-12-17 15:54:09 +01:00
|
|
|
|
override def toString =
|
|
|
|
|
|
"RemoteClientDisconnected@" + remoteAddress
|
|
|
|
|
|
}
|
2011-09-08 19:45:16 +02:00
|
|
|
|
|
2011-12-11 20:00:26 +01:00
|
|
|
|
case class RemoteClientConnected[T <: ParsedTransportAddress](
|
|
|
|
|
|
@BeanProperty remote: RemoteSupport[T],
|
2011-12-17 15:54:09 +01:00
|
|
|
|
@BeanProperty remoteAddress: T) extends RemoteClientLifeCycleEvent {
|
2011-12-19 13:35:10 +01:00
|
|
|
|
override def logLevel = Logging.DebugLevel
|
2011-12-17 15:54:09 +01:00
|
|
|
|
override def toString =
|
|
|
|
|
|
"RemoteClientConnected@" + remoteAddress
|
|
|
|
|
|
}
|
2011-09-08 19:45:16 +02:00
|
|
|
|
|
2011-12-11 20:00:26 +01:00
|
|
|
|
case class RemoteClientStarted[T <: ParsedTransportAddress](
|
|
|
|
|
|
@BeanProperty remote: RemoteSupport[T],
|
2011-12-17 15:54:09 +01:00
|
|
|
|
@BeanProperty remoteAddress: T) extends RemoteClientLifeCycleEvent {
|
2011-12-19 13:35:10 +01:00
|
|
|
|
override def logLevel = Logging.InfoLevel
|
2011-12-17 15:54:09 +01:00
|
|
|
|
override def toString =
|
|
|
|
|
|
"RemoteClientStarted@" + remoteAddress
|
|
|
|
|
|
}
|
2011-09-08 19:45:16 +02:00
|
|
|
|
|
2011-12-11 20:00:26 +01:00
|
|
|
|
case class RemoteClientShutdown[T <: ParsedTransportAddress](
|
|
|
|
|
|
@BeanProperty remote: RemoteSupport[T],
|
2011-12-17 15:54:09 +01:00
|
|
|
|
@BeanProperty remoteAddress: T) extends RemoteClientLifeCycleEvent {
|
2011-12-19 13:35:10 +01:00
|
|
|
|
override def logLevel = Logging.InfoLevel
|
2011-12-17 15:54:09 +01:00
|
|
|
|
override def toString =
|
|
|
|
|
|
"RemoteClientShutdown@" + remoteAddress
|
|
|
|
|
|
}
|
2011-09-08 19:45:16 +02:00
|
|
|
|
|
2011-12-11 20:00:26 +01:00
|
|
|
|
case class RemoteClientWriteFailed[T <: ParsedTransportAddress](
|
2010-12-30 14:59:00 +01:00
|
|
|
|
@BeanProperty request: AnyRef,
|
|
|
|
|
|
@BeanProperty cause: Throwable,
|
2011-12-11 20:00:26 +01:00
|
|
|
|
@BeanProperty remote: RemoteSupport[T],
|
2011-12-17 15:54:09 +01:00
|
|
|
|
@BeanProperty remoteAddress: T) extends RemoteClientLifeCycleEvent {
|
2011-12-19 13:35:10 +01:00
|
|
|
|
override def logLevel = Logging.WarningLevel
|
2011-12-17 15:54:09 +01:00
|
|
|
|
override def toString =
|
|
|
|
|
|
"RemoteClientWriteFailed@" +
|
|
|
|
|
|
remoteAddress +
|
|
|
|
|
|
": MessageClass[" +
|
|
|
|
|
|
(if (request ne null) request.getClass.getName else "no message") +
|
2011-12-21 16:12:08 +01:00
|
|
|
|
"] Error[" +
|
|
|
|
|
|
(if (cause ne null) cause.getClass.getName + ": " + cause.getMessage else "unknown") +
|
2011-12-17 15:54:09 +01:00
|
|
|
|
"]"
|
|
|
|
|
|
}
|
2010-12-29 16:08:43 +01:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Life-cycle events for RemoteServer.
|
|
|
|
|
|
*/
|
2011-08-29 11:44:33 +02:00
|
|
|
|
trait RemoteServerLifeCycleEvent extends RemoteLifeCycleEvent
|
|
|
|
|
|
|
2011-12-11 20:00:26 +01:00
|
|
|
|
case class RemoteServerStarted[T <: ParsedTransportAddress](
|
2011-12-17 15:54:09 +01:00
|
|
|
|
@BeanProperty remote: RemoteSupport[T]) extends RemoteServerLifeCycleEvent {
|
2011-12-19 13:35:10 +01:00
|
|
|
|
override def logLevel = Logging.InfoLevel
|
2011-12-17 15:54:09 +01:00
|
|
|
|
override def toString =
|
|
|
|
|
|
"RemoteServerStarted@" + remote.name
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2011-12-11 20:00:26 +01:00
|
|
|
|
case class RemoteServerShutdown[T <: ParsedTransportAddress](
|
2011-12-17 15:54:09 +01:00
|
|
|
|
@BeanProperty remote: RemoteSupport[T]) extends RemoteServerLifeCycleEvent {
|
2011-12-19 13:35:10 +01:00
|
|
|
|
override def logLevel = Logging.InfoLevel
|
2011-12-17 15:54:09 +01:00
|
|
|
|
override def toString =
|
|
|
|
|
|
"RemoteServerShutdown@" + remote.name
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2011-12-11 20:00:26 +01:00
|
|
|
|
case class RemoteServerError[T <: ParsedTransportAddress](
|
2010-12-29 16:08:43 +01:00
|
|
|
|
@BeanProperty val cause: Throwable,
|
2011-12-17 15:54:09 +01:00
|
|
|
|
@BeanProperty remote: RemoteSupport[T]) extends RemoteServerLifeCycleEvent {
|
2011-12-19 13:35:10 +01:00
|
|
|
|
override def logLevel = Logging.ErrorLevel
|
2011-12-17 15:54:09 +01:00
|
|
|
|
override def toString =
|
|
|
|
|
|
"RemoteServerError@" +
|
|
|
|
|
|
remote.name +
|
2011-12-21 16:12:08 +01:00
|
|
|
|
": Error[" +
|
|
|
|
|
|
(if (cause ne null) cause.getClass.getName + ": " + cause.getMessage else "unknown") +
|
2011-12-17 15:54:09 +01:00
|
|
|
|
"]"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2011-12-11 20:00:26 +01:00
|
|
|
|
case class RemoteServerClientConnected[T <: ParsedTransportAddress](
|
|
|
|
|
|
@BeanProperty remote: RemoteSupport[T],
|
2011-12-17 15:54:09 +01:00
|
|
|
|
@BeanProperty val clientAddress: Option[T]) extends RemoteServerLifeCycleEvent {
|
2011-12-19 13:35:10 +01:00
|
|
|
|
override def logLevel = Logging.DebugLevel
|
2011-12-17 15:54:09 +01:00
|
|
|
|
override def toString =
|
|
|
|
|
|
"RemoteServerClientConnected@" +
|
|
|
|
|
|
remote.name +
|
|
|
|
|
|
": Client[" +
|
|
|
|
|
|
(if (clientAddress.isDefined) clientAddress.get else "no address") +
|
|
|
|
|
|
"]"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2011-12-11 20:00:26 +01:00
|
|
|
|
case class RemoteServerClientDisconnected[T <: ParsedTransportAddress](
|
|
|
|
|
|
@BeanProperty remote: RemoteSupport[T],
|
2011-12-17 15:54:09 +01:00
|
|
|
|
@BeanProperty val clientAddress: Option[T]) extends RemoteServerLifeCycleEvent {
|
2011-12-19 13:35:10 +01:00
|
|
|
|
override def logLevel = Logging.DebugLevel
|
2011-12-17 15:54:09 +01:00
|
|
|
|
override def toString =
|
|
|
|
|
|
"RemoteServerClientDisconnected@" +
|
|
|
|
|
|
remote.name +
|
|
|
|
|
|
": Client[" +
|
|
|
|
|
|
(if (clientAddress.isDefined) clientAddress.get else "no address") +
|
|
|
|
|
|
"]"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2011-12-11 20:00:26 +01:00
|
|
|
|
case class RemoteServerClientClosed[T <: ParsedTransportAddress](
|
|
|
|
|
|
@BeanProperty remote: RemoteSupport[T],
|
2011-12-17 15:54:09 +01:00
|
|
|
|
@BeanProperty val clientAddress: Option[T]) extends RemoteServerLifeCycleEvent {
|
2011-12-19 13:35:10 +01:00
|
|
|
|
override def logLevel = Logging.DebugLevel
|
2011-12-17 15:54:09 +01:00
|
|
|
|
override def toString =
|
|
|
|
|
|
"RemoteServerClientClosed@" +
|
|
|
|
|
|
remote.name +
|
|
|
|
|
|
": Client[" +
|
|
|
|
|
|
(if (clientAddress.isDefined) clientAddress.get else "no address") +
|
|
|
|
|
|
"]"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2011-12-11 20:00:26 +01:00
|
|
|
|
case class RemoteServerWriteFailed[T <: ParsedTransportAddress](
|
2011-01-03 14:44:15 +01:00
|
|
|
|
@BeanProperty request: AnyRef,
|
|
|
|
|
|
@BeanProperty cause: Throwable,
|
2011-12-17 15:54:09 +01:00
|
|
|
|
@BeanProperty remote: RemoteSupport[T],
|
|
|
|
|
|
@BeanProperty remoteAddress: Option[T]) extends RemoteServerLifeCycleEvent {
|
2011-12-19 13:35:10 +01:00
|
|
|
|
override def logLevel = Logging.WarningLevel
|
2011-12-17 15:54:09 +01:00
|
|
|
|
override def toString =
|
|
|
|
|
|
"RemoteServerWriteFailed@" +
|
|
|
|
|
|
remote +
|
|
|
|
|
|
": ClientAddress[" +
|
|
|
|
|
|
remoteAddress +
|
|
|
|
|
|
"] MessageClass[" +
|
|
|
|
|
|
(if (request ne null) request.getClass.getName else "no message") +
|
2011-12-21 16:12:08 +01:00
|
|
|
|
"] Error[" +
|
|
|
|
|
|
(if (cause ne null) cause.getClass.getName + ": " + cause.getMessage else "unknown") +
|
2011-12-17 15:54:09 +01:00
|
|
|
|
"]"
|
|
|
|
|
|
}
|
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-12-11 20:00:26 +01:00
|
|
|
|
class RemoteClientException[T <: ParsedTransportAddress] private[akka] (
|
2011-03-24 16:23:37 +01:00
|
|
|
|
message: String,
|
2011-12-11 20:00:26 +01:00
|
|
|
|
@BeanProperty val client: RemoteSupport[T],
|
|
|
|
|
|
val remoteAddress: T, cause: Throwable = null) extends AkkaException(message, cause)
|
2010-12-29 16:08:43 +01:00
|
|
|
|
|
2011-12-11 20:00:26 +01:00
|
|
|
|
abstract class RemoteSupport[-T <: ParsedTransportAddress](val system: ActorSystemImpl) {
|
2010-12-14 18:22:46 +01:00
|
|
|
|
/**
|
2011-11-10 12:23:39 +01:00
|
|
|
|
* Shuts down the remoting
|
2010-12-14 18:22:46 +01:00
|
|
|
|
*/
|
2011-11-10 12:23:39 +01:00
|
|
|
|
def shutdown(): Unit
|
2010-12-14 18:22:46 +01:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Gets the name of the server instance
|
|
|
|
|
|
*/
|
|
|
|
|
|
def name: String
|
|
|
|
|
|
|
2011-01-05 17:03:40 +01:00
|
|
|
|
/**
|
2011-11-10 12:23:39 +01:00
|
|
|
|
* Starts up the remoting
|
2011-01-05 17:03:40 +01:00
|
|
|
|
*/
|
2011-11-10 12:23:39 +01:00
|
|
|
|
def start(loader: Option[ClassLoader]): Unit
|
2010-12-29 17:59:38 +01:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Shuts down a specific client connected to the supplied remote address returns true if successful
|
|
|
|
|
|
*/
|
2011-12-11 20:00:26 +01:00
|
|
|
|
def shutdownClientConnection(address: T): Boolean
|
2010-12-29 17:59:38 +01:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Restarts a specific client connected to the supplied remote address, but only if the client is not shut down
|
|
|
|
|
|
*/
|
2011-12-11 20:00:26 +01:00
|
|
|
|
def restartClientConnection(address: T): Boolean
|
2010-12-29 17:59:38 +01:00
|
|
|
|
|
|
|
|
|
|
/** Methods that needs to be implemented by a transport **/
|
2010-12-15 17:52:31 +01:00
|
|
|
|
|
2011-11-03 18:33:57 +01:00
|
|
|
|
protected[akka] def send(message: Any,
|
|
|
|
|
|
senderOption: Option[ActorRef],
|
2011-12-07 16:29:12 +01:00
|
|
|
|
recipient: RemoteActorRef,
|
2011-11-03 18:33:57 +01:00
|
|
|
|
loader: Option[ClassLoader]): Unit
|
2011-11-10 12:23:39 +01:00
|
|
|
|
|
2011-12-17 15:54:09 +01:00
|
|
|
|
protected[akka] def notifyListeners(message: RemoteLifeCycleEvent): Unit = {
|
|
|
|
|
|
system.eventStream.publish(message)
|
2011-12-19 13:35:10 +01:00
|
|
|
|
system.log.log(message.logLevel, "REMOTE: {}", message)
|
2011-12-17 15:54:09 +01:00
|
|
|
|
}
|
2011-11-10 12:23:39 +01:00
|
|
|
|
|
|
|
|
|
|
override def toString = name
|
2011-04-01 14:29:26 +02:00
|
|
|
|
}
|