Change RemoteActorRef to not start before it's been published. #2575
This commit is contained in:
parent
4d003c50e7
commit
1d578a9aa2
3 changed files with 12 additions and 15 deletions
|
|
@ -270,14 +270,10 @@ private[akka] class LocalActorRef private[akka] (
|
||||||
*/
|
*/
|
||||||
private val actorCell: ActorCell = newActorCell(_system, this, _props, _supervisor)
|
private val actorCell: ActorCell = newActorCell(_system, this, _props, _supervisor)
|
||||||
actorCell.init(ThreadLocalRandom.current.nextInt(), sendSupervise = true)
|
actorCell.init(ThreadLocalRandom.current.nextInt(), sendSupervise = true)
|
||||||
if (actorCellShouldStart)
|
|
||||||
actorCell.start()
|
|
||||||
|
|
||||||
protected def newActorCell(system: ActorSystemImpl, ref: InternalActorRef, props: Props, supervisor: InternalActorRef): ActorCell =
|
protected def newActorCell(system: ActorSystemImpl, ref: InternalActorRef, props: Props, supervisor: InternalActorRef): ActorCell =
|
||||||
new ActorCell(system, ref, props, supervisor)
|
new ActorCell(system, ref, props, supervisor)
|
||||||
|
|
||||||
protected def actorCellShouldStart(): Boolean = false
|
|
||||||
|
|
||||||
protected def actorContext: ActorContext = actorCell
|
protected def actorContext: ActorContext = actorCell
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -158,8 +158,7 @@ class RemoteActorRefProvider(
|
||||||
local.actorOf(system, props, supervisor, path, false, deployment.headOption, false, async)
|
local.actorOf(system, props, supervisor, path, false, deployment.headOption, false, async)
|
||||||
} else {
|
} else {
|
||||||
val rpath = RootActorPath(addr) / "remote" / transport.address.hostPort / path.elements
|
val rpath = RootActorPath(addr) / "remote" / transport.address.hostPort / path.elements
|
||||||
useActorOnNode(rpath, props, d, supervisor)
|
new RemoteActorRef(this, transport, rpath, supervisor, Some(props), Some(d))
|
||||||
new RemoteActorRef(this, transport, rpath, supervisor)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case _ ⇒ local.actorOf(system, props, supervisor, path, systemService, deployment.headOption, false, async)
|
case _ ⇒ local.actorOf(system, props, supervisor, path, systemService, deployment.headOption, false, async)
|
||||||
|
|
@ -169,12 +168,12 @@ class RemoteActorRefProvider(
|
||||||
|
|
||||||
def actorFor(path: ActorPath): InternalActorRef =
|
def actorFor(path: ActorPath): InternalActorRef =
|
||||||
if (path.address == rootPath.address || path.address == transport.address) actorFor(rootGuardian, path.elements)
|
if (path.address == rootPath.address || path.address == transport.address) actorFor(rootGuardian, path.elements)
|
||||||
else new RemoteActorRef(this, transport, path, Nobody)
|
else new RemoteActorRef(this, transport, path, Nobody, props = None, deploy = None)
|
||||||
|
|
||||||
def actorFor(ref: InternalActorRef, path: String): InternalActorRef = path match {
|
def actorFor(ref: InternalActorRef, path: String): InternalActorRef = path match {
|
||||||
case ActorPathExtractor(address, elems) ⇒
|
case ActorPathExtractor(address, elems) ⇒
|
||||||
if (address == rootPath.address || address == transport.address) actorFor(rootGuardian, elems)
|
if (address == rootPath.address || address == transport.address) actorFor(rootGuardian, elems)
|
||||||
else new RemoteActorRef(this, transport, new RootActorPath(address) / elems, Nobody)
|
else new RemoteActorRef(this, transport, new RootActorPath(address) / elems, Nobody, props = None, deploy = None)
|
||||||
case _ ⇒ local.actorFor(ref, path)
|
case _ ⇒ local.actorFor(ref, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -213,7 +212,9 @@ private[akka] class RemoteActorRef private[akka] (
|
||||||
val provider: RemoteActorRefProvider,
|
val provider: RemoteActorRefProvider,
|
||||||
remote: RemoteTransport,
|
remote: RemoteTransport,
|
||||||
val path: ActorPath,
|
val path: ActorPath,
|
||||||
val getParent: InternalActorRef)
|
val getParent: InternalActorRef,
|
||||||
|
props: Option[Props],
|
||||||
|
deploy: Option[Deploy])
|
||||||
extends InternalActorRef with RemoteRef {
|
extends InternalActorRef with RemoteRef {
|
||||||
|
|
||||||
def getChild(name: Iterator[String]): InternalActorRef = {
|
def getChild(name: Iterator[String]): InternalActorRef = {
|
||||||
|
|
@ -221,7 +222,7 @@ private[akka] class RemoteActorRef private[akka] (
|
||||||
s.headOption match {
|
s.headOption match {
|
||||||
case None ⇒ this
|
case None ⇒ this
|
||||||
case Some("..") ⇒ getParent getChild name
|
case Some("..") ⇒ getParent getChild name
|
||||||
case _ ⇒ new RemoteActorRef(provider, remote, path / s, Nobody)
|
case _ ⇒ new RemoteActorRef(provider, remote, path / s, Nobody, props = None, deploy = None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -243,7 +244,7 @@ private[akka] class RemoteActorRef private[akka] (
|
||||||
provider.deadLetters ! message
|
provider.deadLetters ! message
|
||||||
}
|
}
|
||||||
|
|
||||||
def start(): Unit = ()
|
def start(): Unit = if (props.isDefined && deploy.isDefined) provider.useActorOnNode(path, props.get, deploy.get, getParent)
|
||||||
|
|
||||||
def suspend(): Unit = sendSystemMessage(Suspend())
|
def suspend(): Unit = sendSystemMessage(Suspend())
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,9 @@ class TestActorRef[T <: Actor](
|
||||||
_supervisor,
|
_supervisor,
|
||||||
_supervisor.path / name) {
|
_supervisor.path / name) {
|
||||||
|
|
||||||
|
// we need to start ourselves since the creation of an actor has been split into initialization and starting
|
||||||
|
underlying.start()
|
||||||
|
|
||||||
import TestActorRef.InternalGetActor
|
import TestActorRef.InternalGetActor
|
||||||
|
|
||||||
override def newActorCell(system: ActorSystemImpl, ref: InternalActorRef, props: Props, supervisor: InternalActorRef): ActorCell =
|
override def newActorCell(system: ActorSystemImpl, ref: InternalActorRef, props: Props, supervisor: InternalActorRef): ActorCell =
|
||||||
|
|
@ -54,9 +57,6 @@ class TestActorRef[T <: Actor](
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// we need to start ourselves since the creation of an actor has been split into initialization and starting
|
|
||||||
override def actorCellShouldStart(): Boolean = true
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Directly inject messages into actor receive behavior. Any exceptions
|
* Directly inject messages into actor receive behavior. Any exceptions
|
||||||
* thrown will be available to you, while still being able to use
|
* thrown will be available to you, while still being able to use
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue