merged with upstream
This commit is contained in:
commit
0b2508b7a5
10 changed files with 48 additions and 151 deletions
|
|
@ -23,14 +23,13 @@ import java.net.{InetAddress, UnknownHostException}
|
|||
import AkkaException._
|
||||
val exceptionName = getClass.getName
|
||||
|
||||
val uuid = "%s_%s".format(hostname, newUuid)
|
||||
lazy val uuid = "%s_%s".format(hostname, newUuid)
|
||||
|
||||
override val toString = "%s\n\t[%s]\n\t%s\n\t%s".format(exceptionName, uuid, message, stackTrace)
|
||||
override lazy val toString = "%s\n\t[%s]\n\t%s\n\t%s".format(exceptionName, uuid, message, stackTrace)
|
||||
|
||||
val stackTrace = {
|
||||
lazy val stackTrace = {
|
||||
val sw = new StringWriter
|
||||
val pw = new PrintWriter(sw)
|
||||
printStackTrace(pw)
|
||||
printStackTrace(new PrintWriter(sw))
|
||||
sw.toString
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -481,6 +481,19 @@ trait ActorRef extends ActorRefShared with java.lang.Comparable[ActorRef] { scal
|
|||
*/
|
||||
def getSupervisor(): ActorRef = supervisor getOrElse null
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable Java Map containing the linked actors,
|
||||
* please note that the backing map is thread-safe but not immutable
|
||||
*/
|
||||
def linkedActors: JMap[Uuid, ActorRef]
|
||||
|
||||
/**
|
||||
* Java API
|
||||
* Returns an unmodifiable Java Map containing the linked actors,
|
||||
* please note that the backing map is thread-safe but not immutable
|
||||
*/
|
||||
def getLinkedActors(): JMap[Uuid, ActorRef] = linkedActors
|
||||
|
||||
protected[akka] def invoke(messageHandle: MessageInvocation): Unit
|
||||
|
||||
protected[akka] def postMessageToMailbox(message: Any, senderOption: Option[ActorRef]): Unit
|
||||
|
|
@ -508,8 +521,6 @@ trait ActorRef extends ActorRefShared with java.lang.Comparable[ActorRef] { scal
|
|||
|
||||
protected[akka] def registerSupervisorAsRemoteActor: Option[Uuid]
|
||||
|
||||
protected[akka] def linkedActors: JMap[Uuid, ActorRef]
|
||||
|
||||
override def hashCode: Int = HashCode.hash(HashCode.SEED, uuid)
|
||||
|
||||
override def equals(that: Any): Boolean = {
|
||||
|
|
@ -535,7 +546,7 @@ trait ActorRef extends ActorRefShared with java.lang.Comparable[ActorRef] { scal
|
|||
}
|
||||
|
||||
/**
|
||||
* Local (serializable) ActorRef that is used when referencing the Actor on its "home" node.
|
||||
* Local (serializable) ActorRef that is used when referencing the Actor on its "home" node.
|
||||
*
|
||||
* @author <a href="http://jonasboner.com">Jonas Bonér</a>
|
||||
*/
|
||||
|
|
@ -679,7 +690,7 @@ class LocalActorRef private[akka] (
|
|||
def link(actorRef: ActorRef) = guard.withGuard {
|
||||
if (actorRef.supervisor.isDefined) throw new IllegalActorStateException(
|
||||
"Actor can only have one supervisor [" + actorRef + "], e.g. link(actor) fails")
|
||||
linkedActors.put(actorRef.uuid, actorRef)
|
||||
_linkedActors.put(actorRef.uuid, actorRef)
|
||||
actorRef.supervisor = Some(this)
|
||||
}
|
||||
|
||||
|
|
@ -689,9 +700,9 @@ class LocalActorRef private[akka] (
|
|||
* To be invoked from within the actor itself.
|
||||
*/
|
||||
def unlink(actorRef: ActorRef) = guard.withGuard {
|
||||
if (!linkedActors.containsKey(actorRef.uuid)) throw new IllegalActorStateException(
|
||||
"Actor [" + actorRef + "] is not a linked actor, can't unlink")
|
||||
linkedActors.remove(actorRef.uuid)
|
||||
if(_linkedActors.remove(actorRef.uuid) eq null)
|
||||
throw new IllegalActorStateException("Actor [" + actorRef + "] is not a linked actor, can't unlink")
|
||||
|
||||
actorRef.supervisor = None
|
||||
}
|
||||
|
||||
|
|
@ -758,17 +769,6 @@ class LocalActorRef private[akka] (
|
|||
|
||||
protected[akka] def mailbox_=(value: AnyRef): AnyRef = { _mailbox = value; value }
|
||||
|
||||
/**
|
||||
* Shuts down and removes all linked actors.
|
||||
*/
|
||||
def shutdownLinkedActors() {
|
||||
val i = linkedActors.values.iterator
|
||||
while(i.hasNext) {
|
||||
i.next.stop
|
||||
i.remove
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the supervisor, if there is one.
|
||||
*/
|
||||
|
|
@ -946,8 +946,9 @@ class LocalActorRef private[akka] (
|
|||
}
|
||||
|
||||
protected[akka] def restartLinkedActors(reason: Throwable, maxNrOfRetries: Option[Int], withinTimeRange: Option[Int]) = {
|
||||
import scala.collection.JavaConversions._
|
||||
linkedActors.values foreach { actorRef =>
|
||||
val i = _linkedActors.values.iterator
|
||||
while(i.hasNext) {
|
||||
val actorRef = i.next
|
||||
actorRef.lifeCycle match {
|
||||
// either permanent or none where default is permanent
|
||||
case Temporary => shutDownTemporaryActor(actorRef)
|
||||
|
|
@ -965,7 +966,7 @@ class LocalActorRef private[akka] (
|
|||
} else None
|
||||
}
|
||||
|
||||
protected[akka] def linkedActors: JMap[Uuid, ActorRef] = _linkedActors
|
||||
def linkedActors: JMap[Uuid, ActorRef] = java.util.Collections.unmodifiableMap(_linkedActors)
|
||||
|
||||
// ========= PRIVATE FUNCTIONS =========
|
||||
|
||||
|
|
@ -977,11 +978,11 @@ class LocalActorRef private[akka] (
|
|||
|
||||
private def shutDownTemporaryActor(temporaryActor: ActorRef) {
|
||||
temporaryActor.stop
|
||||
linkedActors.remove(temporaryActor.uuid) // remove the temporary actor
|
||||
_linkedActors.remove(temporaryActor.uuid) // remove the temporary actor
|
||||
// if last temporary actor is gone, then unlink me from supervisor
|
||||
if (linkedActors.isEmpty) {
|
||||
if (_linkedActors.isEmpty)
|
||||
notifySupervisorWithMessage(UnlinkAndStop(this))
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
|
|
@ -1006,7 +1007,15 @@ class LocalActorRef private[akka] (
|
|||
// FIXME to fix supervisor restart of remote actor for oneway calls, inject a supervisor proxy that can send notification back to client
|
||||
_supervisor.foreach { sup =>
|
||||
if (sup.isShutdown) { // if supervisor is shut down, game over for all linked actors
|
||||
shutdownLinkedActors
|
||||
//Scoped stop all linked actors, to avoid leaking the 'i' val
|
||||
{
|
||||
val i = _linkedActors.values.iterator
|
||||
while(i.hasNext) {
|
||||
i.next.stop
|
||||
i.remove
|
||||
}
|
||||
}
|
||||
//Stop the actor itself
|
||||
stop
|
||||
} else sup ! notification // else notify supervisor
|
||||
}
|
||||
|
|
@ -1121,13 +1130,12 @@ private[akka] case class RemoteActorRef private[akka] (
|
|||
def spawnLink(clazz: Class[_ <: Actor]): ActorRef = unsupported
|
||||
def spawnLinkRemote(clazz: Class[_ <: Actor], hostname: String, port: Int, timeout: Long): ActorRef = unsupported
|
||||
def supervisor: Option[ActorRef] = unsupported
|
||||
def shutdownLinkedActors: Unit = unsupported
|
||||
def linkedActors: JMap[Uuid, ActorRef] = unsupported
|
||||
protected[akka] def mailbox: AnyRef = unsupported
|
||||
protected[akka] def mailbox_=(value: AnyRef): AnyRef = unsupported
|
||||
protected[akka] def handleTrapExit(dead: ActorRef, reason: Throwable): Unit = unsupported
|
||||
protected[akka] def restart(reason: Throwable, maxNrOfRetries: Option[Int], withinTimeRange: Option[Int]): Unit = unsupported
|
||||
protected[akka] def restartLinkedActors(reason: Throwable, maxNrOfRetries: Option[Int], withinTimeRange: Option[Int]): Unit = unsupported
|
||||
protected[akka] def linkedActors: JMap[Uuid, ActorRef] = unsupported
|
||||
protected[akka] def invoke(messageHandle: MessageInvocation): Unit = unsupported
|
||||
protected[akka] def supervisor_=(sup: Option[ActorRef]): Unit = unsupported
|
||||
protected[akka] def actorInstance: AtomicReference[Actor] = unsupported
|
||||
|
|
@ -1149,11 +1157,6 @@ trait ActorRefShared {
|
|||
* Returns the uuid for the actor.
|
||||
*/
|
||||
def uuid: Uuid
|
||||
|
||||
/**
|
||||
* Shuts down and removes all linked actors.
|
||||
*/
|
||||
def shutdownLinkedActors(): Unit
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -157,10 +157,16 @@ sealed class Supervisor(handler: FaultHandlingStrategy) {
|
|||
* @author <a href="http://jonasboner.com">Jonas Bonér</a>
|
||||
*/
|
||||
final class SupervisorActor private[akka] (handler: FaultHandlingStrategy) extends Actor {
|
||||
import self._
|
||||
faultHandler = handler
|
||||
self.faultHandler = handler
|
||||
|
||||
override def postStop(): Unit = shutdownLinkedActors
|
||||
override def postStop(): Unit = {
|
||||
val i = self.linkedActors.values.iterator
|
||||
while(i.hasNext) {
|
||||
val ref = i.next
|
||||
ref.stop
|
||||
self.unlink(ref)
|
||||
}
|
||||
}
|
||||
|
||||
def receive = {
|
||||
// FIXME add a way to respond to MaximumNumberOfRestartsWithinTimeRangeReached in declaratively configured Supervisor
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.facebook</groupId>
|
||||
<artifactId>thrift</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
</project>
|
||||
Binary file not shown.
|
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.facebook</groupId>
|
||||
<artifactId>thrift</artifactId>
|
||||
<version>r917130</version>
|
||||
<packaging>jar</packaging>
|
||||
</project>
|
||||
Binary file not shown.
|
|
@ -1,83 +0,0 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.lag</groupId>
|
||||
<artifactId>configgy</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>2.0.2-nologgy</version>
|
||||
<name>Configgy</name>
|
||||
<description>Configgy logging removed</description>
|
||||
<url>http://github.com/derekjw/configgy</url>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache 2</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.scala-lang</groupId>
|
||||
<artifactId>scala-library</artifactId>
|
||||
<version>2.8.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>scalatoolsorg</id>
|
||||
<name>scala-tools.org</name>
|
||||
<url>http://scala-tools.org/repo-releases/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>atlassian</id>
|
||||
<name>atlassian</name>
|
||||
<url>https://m2proxy.atlassian.com/repository/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>lagnet</id>
|
||||
<name>lag.net</name>
|
||||
<url>http://www.lag.net/repo/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>testingscalatoolsorg</id>
|
||||
<name>testing.scala-tools.org</name>
|
||||
<url>http://scala-tools.org/repo-releases/testing/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>oauthnet</id>
|
||||
<name>oauth.net</name>
|
||||
<url>http://oauth.googlecode.com/svn/code/maven/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>downloadjavanet</id>
|
||||
<name>download.java.net</name>
|
||||
<url>http://download.java.net/maven/2/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>oldtwittercom</id>
|
||||
<name>old.twitter.com</name>
|
||||
<url>http://www.lag.net/nest/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>twittercom</id>
|
||||
<name>twitter.com</name>
|
||||
<url>http://maven.twttr.com/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>powermockapi</id>
|
||||
<name>powermock-api</name>
|
||||
<url>http://powermock.googlecode.com/svn/repo/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>ibiblio</id>
|
||||
<name>ibiblio</name>
|
||||
<url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>ScalaToolsMaven2Repository</id>
|
||||
<name>Scala-Tools Maven2 Repository</name>
|
||||
<url>http://scala-tools.org/repo-releases/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
</project>
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<groupId>net.lag</groupId>
|
||||
<artifactId>configgy</artifactId>
|
||||
<version>2.8.0.RC2-1.5.2-SNAPSHOT</version>
|
||||
<versioning>
|
||||
<versions>
|
||||
<version>2.8.0.RC2-1.5.2-SNAPSHOT</version>
|
||||
</versions>
|
||||
<lastUpdated>20100519155407</lastUpdated>
|
||||
</versioning>
|
||||
</metadata>
|
||||
Loading…
Add table
Add a link
Reference in a new issue