rename AddressExtractor to AddressFromURIString, see #1865
This commit is contained in:
parent
762c60d486
commit
5fe27b523b
11 changed files with 24 additions and 24 deletions
|
|
@ -61,7 +61,7 @@ object RelativeActorPath {
|
|||
/**
|
||||
* This object serves as extractor for Scala and as address parser for Java.
|
||||
*/
|
||||
object AddressExtractor {
|
||||
object AddressFromURIString {
|
||||
def unapply(addr: String): Option[Address] =
|
||||
try {
|
||||
val uri = new URI(addr)
|
||||
|
|
@ -87,8 +87,8 @@ object AddressExtractor {
|
|||
* Try to construct an Address from the given String or throw a java.net.MalformedURLException.
|
||||
*/
|
||||
def apply(addr: String): Address = addr match {
|
||||
case AddressExtractor(address) ⇒ address
|
||||
case _ ⇒ throw new MalformedURLException
|
||||
case AddressFromURIString(address) ⇒ address
|
||||
case _ ⇒ throw new MalformedURLException
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -102,7 +102,7 @@ object ActorPathExtractor {
|
|||
try {
|
||||
val uri = new URI(addr)
|
||||
if (uri.getPath == null) None
|
||||
else AddressExtractor.unapply(uri) match {
|
||||
else AddressFromURIString.unapply(uri) match {
|
||||
case None ⇒ None
|
||||
case Some(addr) ⇒ Some((addr, ActorPath.split(uri.getPath).drop(1)))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import java.util.concurrent.TimeUnit.MILLISECONDS
|
|||
import akka.config.ConfigurationException
|
||||
import scala.collection.JavaConverters._
|
||||
import akka.actor.Address
|
||||
import akka.actor.AddressExtractor
|
||||
import akka.actor.AddressFromURIString
|
||||
|
||||
class ClusterSettings(val config: Config, val systemName: String) {
|
||||
import config._
|
||||
|
|
@ -21,6 +21,6 @@ class ClusterSettings(val config: Config, val systemName: String) {
|
|||
val InitialDelayForGossip = Duration(getMilliseconds("akka.cluster.gossip.initial-delay"), MILLISECONDS)
|
||||
val GossipFrequency = Duration(getMilliseconds("akka.cluster.gossip.frequency"), MILLISECONDS)
|
||||
val SeedNodes = Set.empty[Address] ++ getStringList("akka.cluster.seed-nodes").asScala.collect {
|
||||
case AddressExtractor(addr) ⇒ addr
|
||||
case AddressFromURIString(addr) ⇒ addr
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import akka.actor.Props;
|
|||
import akka.actor.UntypedActor;
|
||||
import akka.actor.ActorSystem;
|
||||
import akka.actor.Address;
|
||||
import akka.actor.AddressExtractor;
|
||||
import akka.actor.AddressFromURIString;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class RouterViaProgramExample {
|
||||
|
|
@ -73,7 +73,7 @@ public class RouterViaProgramExample {
|
|||
|
||||
//#remoteRoutees
|
||||
Address addr1 = new Address("akka", "remotesys", "otherhost", 1234);
|
||||
Address addr2 = AddressExtractor.parse("akka://othersys@anotherhost:1234");
|
||||
Address addr2 = AddressFromURIString.parse("akka://othersys@anotherhost:1234");
|
||||
Address[] addresses = new Address[] { addr1, addr2 };
|
||||
ActorRef routerRemote = system.actorOf(new Props(ExampleActor.class)
|
||||
.withRouter(new RemoteRouterConfig(new RoundRobinRouter(5), addresses)));
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import org.junit.Test;
|
|||
//#import
|
||||
import akka.actor.ActorRef;
|
||||
import akka.actor.Address;
|
||||
import akka.actor.AddressExtractor;
|
||||
import akka.actor.AddressFromURIString;
|
||||
import akka.actor.Deploy;
|
||||
import akka.actor.Props;
|
||||
import akka.actor.ActorSystem;
|
||||
|
|
@ -35,7 +35,7 @@ public class RemoteDeploymentDocTestBase {
|
|||
public void demonstrateDeployment() {
|
||||
//#make-address
|
||||
Address addr = new Address("akka", "sys", "host", 1234);
|
||||
addr = AddressExtractor.parse("akka://sys@host:1234"); // the same
|
||||
addr = AddressFromURIString.parse("akka://sys@host:1234"); // the same
|
||||
//#make-address
|
||||
//#deploy
|
||||
ActorRef ref = system.actorOf(new Props(RemoteDeploymentDocSpec.Echo.class).withDeploy(new Deploy(new RemoteScope(addr))));
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ package akka.docs.remoting
|
|||
import akka.actor.{ ExtendedActorSystem, ActorSystem, Actor, ActorRef }
|
||||
import akka.testkit.{ AkkaSpec, ImplicitSender }
|
||||
//#import
|
||||
import akka.actor.{ Props, Deploy, Address, AddressExtractor }
|
||||
import akka.actor.{ Props, Deploy, Address, AddressFromURIString }
|
||||
import akka.remote.RemoteScope
|
||||
//#import
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ class RemoteDeploymentDocSpec extends AkkaSpec("""
|
|||
|
||||
"demonstrate address extractor" in {
|
||||
//#make-address
|
||||
val one = AddressExtractor("akka://sys@host:1234")
|
||||
val one = AddressFromURIString("akka://sys@host:1234")
|
||||
val two = Address("akka", "sys", "host", 1234) // this gives the same
|
||||
//#make-address
|
||||
one must be === two
|
||||
|
|
|
|||
|
|
@ -42,10 +42,10 @@ object RoutingProgrammaticallyExample extends App {
|
|||
1 to 6 foreach { i ⇒ router3 ! Message1(i) }
|
||||
|
||||
//#remoteRoutees
|
||||
import akka.actor.{ Address, AddressExtractor }
|
||||
import akka.actor.{ Address, AddressFromURIString }
|
||||
val addresses = Seq(
|
||||
Address("akka", "remotesys", "otherhost", 1234),
|
||||
AddressExtractor("akka://othersys@anotherhost:1234"))
|
||||
AddressFromURIString("akka://othersys@anotherhost:1234"))
|
||||
val routerRemote = system.actorOf(Props[ExampleActor1].withRouter(
|
||||
RemoteRouterConfig(RoundRobinRouter(5), addresses)))
|
||||
//#remoteRoutees
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ class RemoteDeployer(_settings: ActorSystem.Settings, _pm: DynamicAccess) extend
|
|||
super.parseConfig(path, config) match {
|
||||
case d @ Some(deploy) ⇒
|
||||
deploy.config.getString("remote") match {
|
||||
case AddressExtractor(r) ⇒ Some(deploy.copy(scope = RemoteScope(r)))
|
||||
case AddressFromURIString(r) ⇒ Some(deploy.copy(scope = RemoteScope(r)))
|
||||
case str ⇒
|
||||
if (!str.isEmpty) throw new ConfigurationException("unparseable remote node name " + str)
|
||||
val nodes = deploy.config.getStringList("target.nodes").asScala map (AddressExtractor(_))
|
||||
val nodes = deploy.config.getStringList("target.nodes").asScala map (AddressFromURIString(_))
|
||||
if (nodes.isEmpty || deploy.routerConfig == NoRouter) d
|
||||
else Some(deploy.copy(routerConfig = RemoteRouterConfig(deploy.routerConfig, nodes)))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import java.net.InetAddress
|
|||
import akka.config.ConfigurationException
|
||||
import scala.collection.JavaConverters._
|
||||
import akka.actor.Address
|
||||
import akka.actor.AddressExtractor
|
||||
import akka.actor.AddressFromURIString
|
||||
|
||||
class RemoteSettings(val config: Config, val systemName: String) {
|
||||
import config._
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
package akka.remote
|
||||
|
||||
import scala.reflect.BeanProperty
|
||||
import akka.actor.{ Terminated, LocalRef, InternalActorRef, AutoReceivedMessage, AddressExtractor, Address, ActorSystemImpl, ActorSystem, ActorRef }
|
||||
import akka.actor.{ Terminated, LocalRef, InternalActorRef, AutoReceivedMessage, AddressFromURIString, Address, ActorSystemImpl, ActorSystem, ActorRef }
|
||||
import akka.dispatch.SystemMessage
|
||||
import akka.event.{ LoggingAdapter, Logging }
|
||||
import akka.AkkaException
|
||||
|
|
@ -284,7 +284,7 @@ trait RemoteMarshallingOps {
|
|||
case r: RemoteRef ⇒
|
||||
if (provider.remoteSettings.LogReceive) log.debug("received remote-destined message {}", remoteMessage)
|
||||
remoteMessage.originalReceiver match {
|
||||
case AddressExtractor(address) if address == provider.transport.address ⇒
|
||||
case AddressFromURIString(address) if address == provider.transport.address ⇒
|
||||
// if it was originally addressed to us but is in fact remote from our point of view (i.e. remote-deployed)
|
||||
r.!(remoteMessage.payload)(remoteMessage.sender)
|
||||
case r ⇒ log.error("dropping message {} for non-local recipient {} at {} local is {}", remoteMessage.payload, r, address, provider.transport.address)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import akka.actor.InternalActorRef
|
|||
import akka.actor.Props
|
||||
import akka.config.ConfigurationException
|
||||
import akka.remote.RemoteScope
|
||||
import akka.actor.AddressExtractor
|
||||
import akka.actor.AddressFromURIString
|
||||
import akka.actor.SupervisorStrategy
|
||||
import akka.actor.Address
|
||||
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ akka.actor.deployment {
|
|||
|
||||
"deploy remote routers based on explicit deployment" in {
|
||||
val router = system.actorOf(Props[Echo].withRouter(RoundRobinRouter(2))
|
||||
.withDeploy(Deploy(scope = RemoteScope(AddressExtractor("akka://remote_sys@localhost:12347")))), "remote-blub2")
|
||||
.withDeploy(Deploy(scope = RemoteScope(AddressFromURIString("akka://remote_sys@localhost:12347")))), "remote-blub2")
|
||||
router.path.address.toString must be("akka://remote_sys@localhost:12347")
|
||||
val replies = for (i ← 1 to 5) yield {
|
||||
router ! ""
|
||||
|
|
@ -150,7 +150,7 @@ akka.actor.deployment {
|
|||
|
||||
"let remote deployment be overridden by local configuration" in {
|
||||
val router = system.actorOf(Props[Echo].withRouter(RoundRobinRouter(2))
|
||||
.withDeploy(Deploy(scope = RemoteScope(AddressExtractor("akka://remote_sys@localhost:12347")))), "local-blub")
|
||||
.withDeploy(Deploy(scope = RemoteScope(AddressFromURIString("akka://remote_sys@localhost:12347")))), "local-blub")
|
||||
router.path.address.toString must be("akka://RemoteRouterSpec")
|
||||
val replies = for (i ← 1 to 5) yield {
|
||||
router ! ""
|
||||
|
|
@ -167,7 +167,7 @@ akka.actor.deployment {
|
|||
|
||||
"let remote deployment router be overridden by local configuration" in {
|
||||
val router = system.actorOf(Props[Echo].withRouter(RoundRobinRouter(2))
|
||||
.withDeploy(Deploy(scope = RemoteScope(AddressExtractor("akka://remote_sys@localhost:12347")))), "local-blub2")
|
||||
.withDeploy(Deploy(scope = RemoteScope(AddressFromURIString("akka://remote_sys@localhost:12347")))), "local-blub2")
|
||||
router.path.address.toString must be("akka://remote_sys@localhost:12347")
|
||||
val replies = for (i ← 1 to 5) yield {
|
||||
router ! ""
|
||||
|
|
@ -184,7 +184,7 @@ akka.actor.deployment {
|
|||
|
||||
"let remote deployment be overridden by remote configuration" in {
|
||||
val router = system.actorOf(Props[Echo].withRouter(RoundRobinRouter(2))
|
||||
.withDeploy(Deploy(scope = RemoteScope(AddressExtractor("akka://remote_sys@localhost:12347")))), "remote-override")
|
||||
.withDeploy(Deploy(scope = RemoteScope(AddressFromURIString("akka://remote_sys@localhost:12347")))), "remote-override")
|
||||
router.path.address.toString must be("akka://remote_sys@localhost:12347")
|
||||
val replies = for (i ← 1 to 5) yield {
|
||||
router ! ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue