Pushing the memory per actor down to 464 bytes. Returning None for the Deploy if there is no config
This commit is contained in:
parent
304d39d839
commit
6150beb333
6 changed files with 28 additions and 35 deletions
|
|
@ -217,7 +217,7 @@ trait Actor {
|
|||
/**
|
||||
* The default timeout, based on the config setting 'akka.actor.timeout'
|
||||
*/
|
||||
implicit val defaultTimeout = config.ActorTimeout
|
||||
implicit def defaultTimeout = config.ActorTimeout
|
||||
|
||||
/**
|
||||
* Wrap a Receive partial function in a logging enclosure, which sends a
|
||||
|
|
@ -419,7 +419,7 @@ trait Actor {
|
|||
|
||||
private[akka] final def apply(msg: Any) = {
|
||||
if (msg.isInstanceOf[AnyRef] && (msg.asInstanceOf[AnyRef] eq null))
|
||||
throw new InvalidMessageException("Message from [" + channel + "] to [" + self.toString + "] is null")
|
||||
throw new InvalidMessageException("Message from [" + channel + "] to [" + self + "] is null")
|
||||
|
||||
def autoReceiveMessage(msg: AutoReceivedMessage) {
|
||||
if (config.DebugAutoReceive) app.eventHandler.debug(this, "received AutoReceiveMessage " + msg)
|
||||
|
|
@ -449,7 +449,7 @@ trait Actor {
|
|||
}
|
||||
}
|
||||
|
||||
private lazy val processingBehavior = receive //ProcessingBehavior is the original behavior
|
||||
private val processingBehavior = receive //ProcessingBehavior is the original behavior
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -6,14 +6,9 @@ package akka.actor
|
|||
|
||||
import akka.dispatch._
|
||||
import akka.util._
|
||||
import akka.serialization.{ Serializer, Serialization }
|
||||
import java.net.InetSocketAddress
|
||||
import scala.collection.immutable.Stack
|
||||
import java.lang.{ UnsupportedOperationException, IllegalStateException }
|
||||
import akka.AkkaApplication
|
||||
import akka.remote.RemoteSupport
|
||||
import scala.util.DynamicVariable
|
||||
import akka.event.{ EventHandler }
|
||||
|
||||
/**
|
||||
* ActorRef is an immutable and serializable handle to an Actor.
|
||||
|
|
@ -49,7 +44,7 @@ abstract class ActorRef extends ActorRefShared with UntypedChannel with ReplyCha
|
|||
scalaRef: ScalaActorRef ⇒
|
||||
// Only mutable for RemoteServer in order to maintain identity across nodes
|
||||
|
||||
private[akka] val uuid = newUuid
|
||||
private[akka] def uuid: Uuid
|
||||
|
||||
def address: String
|
||||
|
||||
|
|
@ -155,7 +150,7 @@ class LocalActorRef private[akka] (
|
|||
props: Props,
|
||||
givenAddress: String,
|
||||
val systemService: Boolean = false,
|
||||
override private[akka] val uuid: Uuid = newUuid,
|
||||
private[akka] val uuid: Uuid = newUuid,
|
||||
receiveTimeout: Option[Long] = None,
|
||||
hotswap: Stack[PartialFunction[Any, Unit]] = Props.noHotSwap)
|
||||
extends ActorRef with ScalaActorRef {
|
||||
|
|
@ -351,6 +346,8 @@ class DeadLetterActorRef(app: AkkaApplication) extends UnsupportedActorRef {
|
|||
val brokenPromise = new KeptPromise[Any](Left(new ActorKilledException("In DeadLetterActorRef, promises are always broken.")))(app.dispatcher)
|
||||
val address: String = "akka:internal:DeadLetterActorRef"
|
||||
|
||||
private[akka] val uuid: akka.actor.Uuid = new com.eaio.uuid.UUID(0L, 0L) //Nil UUID
|
||||
|
||||
override def startsMonitoring(actorRef: ActorRef): ActorRef = actorRef
|
||||
|
||||
override def stopsMonitoring(actorRef: ActorRef): ActorRef = actorRef
|
||||
|
|
|
|||
|
|
@ -34,11 +34,7 @@ class Deployer(val app: AkkaApplication) extends ActorDeployer {
|
|||
// val defaultAddress = Node(Config.nodename)
|
||||
|
||||
lazy val instance: ActorDeployer = {
|
||||
val deployer = if (app.reflective.ClusterModule.isEnabled) {
|
||||
app.reflective.ClusterModule.clusterDeployer
|
||||
} else {
|
||||
LocalDeployer
|
||||
}
|
||||
val deployer = if (app.reflective.ClusterModule.isEnabled) app.reflective.ClusterModule.clusterDeployer else LocalDeployer
|
||||
deployer.init(deploymentsInConfig)
|
||||
deployer
|
||||
}
|
||||
|
|
@ -47,7 +43,7 @@ class Deployer(val app: AkkaApplication) extends ActorDeployer {
|
|||
|
||||
private[akka] def init(deployments: Seq[Deploy]) = instance.init(deployments)
|
||||
|
||||
def shutdown(): Unit = instance.shutdown() //TODO Why should we have "shutdown", should be crash only?
|
||||
def shutdown(): Unit = instance.shutdown() //TODO FIXME Why should we have "shutdown", should be crash only?
|
||||
|
||||
def deploy(deployment: Deploy): Unit = instance.deploy(deployment)
|
||||
|
||||
|
|
@ -81,20 +77,14 @@ class Deployer(val app: AkkaApplication) extends ActorDeployer {
|
|||
lookupInConfig(address)
|
||||
} catch {
|
||||
case e: ConfigurationException ⇒
|
||||
app.eventHandler.error(e, this, e.getMessage)
|
||||
app.eventHandler.error(e, this, e.getMessage) //TODO FIXME I do not condone log AND rethrow
|
||||
throw e
|
||||
}
|
||||
|
||||
newDeployment foreach { d ⇒
|
||||
if (d eq null) {
|
||||
val e = new IllegalStateException("Deployment for address [" + address + "] is null")
|
||||
app.eventHandler.error(e, this, e.getMessage)
|
||||
throw e
|
||||
}
|
||||
deploy(d) // deploy and cache it
|
||||
newDeployment match {
|
||||
case None | Some(null) ⇒ None
|
||||
case Some(d) ⇒ deploy(d); newDeployment // deploy and cache it
|
||||
}
|
||||
|
||||
newDeployment
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -127,9 +117,7 @@ class Deployer(val app: AkkaApplication) extends ActorDeployer {
|
|||
// --------------------------------
|
||||
val addressPath = "akka.actor.deployment." + address
|
||||
configuration.getSection(addressPath) match {
|
||||
case None ⇒
|
||||
Some(Deploy(address, None, Direct, NrOfInstances(1), NoOpFailureDetector, LocalScope))
|
||||
|
||||
case None ⇒ None
|
||||
case Some(addressConfig) ⇒
|
||||
|
||||
// --------------------------------
|
||||
|
|
@ -150,11 +138,11 @@ class Deployer(val app: AkkaApplication) extends ActorDeployer {
|
|||
// akka.actor.deployment.<address>.nr-of-instances
|
||||
// --------------------------------
|
||||
val nrOfInstances = {
|
||||
if (router == Direct) NrOfInstances(1)
|
||||
if (router == Direct) OneNrOfInstances
|
||||
else {
|
||||
addressConfig.getAny("nr-of-instances", "1") match {
|
||||
case "auto" ⇒ AutoNrOfInstances
|
||||
case "1" ⇒ NrOfInstances(1)
|
||||
case "1" ⇒ OneNrOfInstances
|
||||
case "0" ⇒ ZeroNrOfInstances
|
||||
case nrOfReplicas: String ⇒
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -103,7 +103,12 @@ object DeploymentConfig {
|
|||
}
|
||||
|
||||
object NrOfInstances {
|
||||
def apply(factor: Int): NrOfInstances = new NrOfInstances(factor)
|
||||
def apply(factor: Int): NrOfInstances = factor match {
|
||||
case -1 ⇒ AutoNrOfInstances
|
||||
case 0 ⇒ ZeroNrOfInstances
|
||||
case 1 ⇒ OneNrOfInstances
|
||||
case x ⇒ new NrOfInstances(x)
|
||||
}
|
||||
def unapply(other: Any) = other match {
|
||||
case x: NrOfInstances ⇒ import x._; Some(factor)
|
||||
case _ ⇒ None
|
||||
|
|
@ -113,10 +118,12 @@ object DeploymentConfig {
|
|||
// For Java API
|
||||
class AutoNrOfInstances extends NrOfInstances(-1)
|
||||
class ZeroNrOfInstances extends NrOfInstances(0)
|
||||
class OneNrOfInstances extends NrOfInstances(0)
|
||||
|
||||
// For Scala API
|
||||
case object AutoNrOfInstances extends AutoNrOfInstances
|
||||
case object ZeroNrOfInstances extends ZeroNrOfInstances
|
||||
case object OneNrOfInstances extends OneNrOfInstances
|
||||
|
||||
// --------------------------------
|
||||
// --- Replication
|
||||
|
|
@ -252,9 +259,7 @@ class DeploymentConfig(val app: AkkaApplication) {
|
|||
|
||||
import DeploymentConfig._
|
||||
|
||||
case class ClusterScope(
|
||||
preferredNodes: Iterable[Home] = Vector(Node(app.nodename)),
|
||||
replication: ReplicationScheme = Transient) extends Scope
|
||||
case class ClusterScope(preferredNodes: Iterable[Home] = Vector(Node(app.nodename)), replication: ReplicationScheme = Transient) extends Scope
|
||||
|
||||
def isHomeNode(homes: Iterable[Home]): Boolean = homes exists (home ⇒ nodeNameFor(home) == app.nodename)
|
||||
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ object Routing {
|
|||
* An Abstract convenience implementation for building an ActorReference that uses a Router.
|
||||
*/
|
||||
abstract private[akka] class AbstractRoutedActorRef(val props: RoutedProps) extends UnsupportedActorRef {
|
||||
private[akka] val uuid: Uuid = newUuid
|
||||
|
||||
val router = props.routerFactory()
|
||||
|
||||
|
|
|
|||
|
|
@ -237,6 +237,8 @@ private[akka] case class RemoteActorRef private[akka] (
|
|||
loader: Option[ClassLoader])
|
||||
extends ActorRef with ScalaActorRef {
|
||||
|
||||
private[akka] val uuid: Uuid = newUuid
|
||||
|
||||
@volatile
|
||||
private var running: Boolean = true
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue