rename AddressExtractor to AddressFromURIString, see #1865

This commit is contained in:
Roland 2012-02-27 10:28:20 +01:00
parent 762c60d486
commit 5fe27b523b
11 changed files with 24 additions and 24 deletions

View file

@ -61,7 +61,7 @@ object RelativeActorPath {
/** /**
* This object serves as extractor for Scala and as address parser for Java. * This object serves as extractor for Scala and as address parser for Java.
*/ */
object AddressExtractor { object AddressFromURIString {
def unapply(addr: String): Option[Address] = def unapply(addr: String): Option[Address] =
try { try {
val uri = new URI(addr) val uri = new URI(addr)
@ -87,7 +87,7 @@ object AddressExtractor {
* Try to construct an Address from the given String or throw a java.net.MalformedURLException. * Try to construct an Address from the given String or throw a java.net.MalformedURLException.
*/ */
def apply(addr: String): Address = addr match { def apply(addr: String): Address = addr match {
case AddressExtractor(address) address case AddressFromURIString(address) address
case _ throw new MalformedURLException case _ throw new MalformedURLException
} }
@ -102,7 +102,7 @@ object ActorPathExtractor {
try { try {
val uri = new URI(addr) val uri = new URI(addr)
if (uri.getPath == null) None if (uri.getPath == null) None
else AddressExtractor.unapply(uri) match { else AddressFromURIString.unapply(uri) match {
case None None case None None
case Some(addr) Some((addr, ActorPath.split(uri.getPath).drop(1))) case Some(addr) Some((addr, ActorPath.split(uri.getPath).drop(1)))
} }

View file

@ -9,7 +9,7 @@ import java.util.concurrent.TimeUnit.MILLISECONDS
import akka.config.ConfigurationException import akka.config.ConfigurationException
import scala.collection.JavaConverters._ import scala.collection.JavaConverters._
import akka.actor.Address import akka.actor.Address
import akka.actor.AddressExtractor import akka.actor.AddressFromURIString
class ClusterSettings(val config: Config, val systemName: String) { class ClusterSettings(val config: Config, val systemName: String) {
import config._ 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 InitialDelayForGossip = Duration(getMilliseconds("akka.cluster.gossip.initial-delay"), MILLISECONDS)
val GossipFrequency = Duration(getMilliseconds("akka.cluster.gossip.frequency"), MILLISECONDS) val GossipFrequency = Duration(getMilliseconds("akka.cluster.gossip.frequency"), MILLISECONDS)
val SeedNodes = Set.empty[Address] ++ getStringList("akka.cluster.seed-nodes").asScala.collect { val SeedNodes = Set.empty[Address] ++ getStringList("akka.cluster.seed-nodes").asScala.collect {
case AddressExtractor(addr) addr case AddressFromURIString(addr) addr
} }
} }

View file

@ -11,7 +11,7 @@ import akka.actor.Props;
import akka.actor.UntypedActor; import akka.actor.UntypedActor;
import akka.actor.ActorSystem; import akka.actor.ActorSystem;
import akka.actor.Address; import akka.actor.Address;
import akka.actor.AddressExtractor; import akka.actor.AddressFromURIString;
import java.util.Arrays; import java.util.Arrays;
public class RouterViaProgramExample { public class RouterViaProgramExample {
@ -73,7 +73,7 @@ public class RouterViaProgramExample {
//#remoteRoutees //#remoteRoutees
Address addr1 = new Address("akka", "remotesys", "otherhost", 1234); 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 }; Address[] addresses = new Address[] { addr1, addr2 };
ActorRef routerRemote = system.actorOf(new Props(ExampleActor.class) ActorRef routerRemote = system.actorOf(new Props(ExampleActor.class)
.withRouter(new RemoteRouterConfig(new RoundRobinRouter(5), addresses))); .withRouter(new RemoteRouterConfig(new RoundRobinRouter(5), addresses)));

View file

@ -10,7 +10,7 @@ import org.junit.Test;
//#import //#import
import akka.actor.ActorRef; import akka.actor.ActorRef;
import akka.actor.Address; import akka.actor.Address;
import akka.actor.AddressExtractor; import akka.actor.AddressFromURIString;
import akka.actor.Deploy; import akka.actor.Deploy;
import akka.actor.Props; import akka.actor.Props;
import akka.actor.ActorSystem; import akka.actor.ActorSystem;
@ -35,7 +35,7 @@ public class RemoteDeploymentDocTestBase {
public void demonstrateDeployment() { public void demonstrateDeployment() {
//#make-address //#make-address
Address addr = new Address("akka", "sys", "host", 1234); 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 //#make-address
//#deploy //#deploy
ActorRef ref = system.actorOf(new Props(RemoteDeploymentDocSpec.Echo.class).withDeploy(new Deploy(new RemoteScope(addr)))); ActorRef ref = system.actorOf(new Props(RemoteDeploymentDocSpec.Echo.class).withDeploy(new Deploy(new RemoteScope(addr))));

View file

@ -6,7 +6,7 @@ package akka.docs.remoting
import akka.actor.{ ExtendedActorSystem, ActorSystem, Actor, ActorRef } import akka.actor.{ ExtendedActorSystem, ActorSystem, Actor, ActorRef }
import akka.testkit.{ AkkaSpec, ImplicitSender } import akka.testkit.{ AkkaSpec, ImplicitSender }
//#import //#import
import akka.actor.{ Props, Deploy, Address, AddressExtractor } import akka.actor.{ Props, Deploy, Address, AddressFromURIString }
import akka.remote.RemoteScope import akka.remote.RemoteScope
//#import //#import
@ -43,7 +43,7 @@ class RemoteDeploymentDocSpec extends AkkaSpec("""
"demonstrate address extractor" in { "demonstrate address extractor" in {
//#make-address //#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 val two = Address("akka", "sys", "host", 1234) // this gives the same
//#make-address //#make-address
one must be === two one must be === two

View file

@ -42,10 +42,10 @@ object RoutingProgrammaticallyExample extends App {
1 to 6 foreach { i router3 ! Message1(i) } 1 to 6 foreach { i router3 ! Message1(i) }
//#remoteRoutees //#remoteRoutees
import akka.actor.{ Address, AddressExtractor } import akka.actor.{ Address, AddressFromURIString }
val addresses = Seq( val addresses = Seq(
Address("akka", "remotesys", "otherhost", 1234), Address("akka", "remotesys", "otherhost", 1234),
AddressExtractor("akka://othersys@anotherhost:1234")) AddressFromURIString("akka://othersys@anotherhost:1234"))
val routerRemote = system.actorOf(Props[ExampleActor1].withRouter( val routerRemote = system.actorOf(Props[ExampleActor1].withRouter(
RemoteRouterConfig(RoundRobinRouter(5), addresses))) RemoteRouterConfig(RoundRobinRouter(5), addresses)))
//#remoteRoutees //#remoteRoutees

View file

@ -20,10 +20,10 @@ class RemoteDeployer(_settings: ActorSystem.Settings, _pm: DynamicAccess) extend
super.parseConfig(path, config) match { super.parseConfig(path, config) match {
case d @ Some(deploy) case d @ Some(deploy)
deploy.config.getString("remote") match { 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 case str
if (!str.isEmpty) throw new ConfigurationException("unparseable remote node name " + 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 if (nodes.isEmpty || deploy.routerConfig == NoRouter) d
else Some(deploy.copy(routerConfig = RemoteRouterConfig(deploy.routerConfig, nodes))) else Some(deploy.copy(routerConfig = RemoteRouterConfig(deploy.routerConfig, nodes)))
} }

View file

@ -10,7 +10,7 @@ import java.net.InetAddress
import akka.config.ConfigurationException import akka.config.ConfigurationException
import scala.collection.JavaConverters._ import scala.collection.JavaConverters._
import akka.actor.Address import akka.actor.Address
import akka.actor.AddressExtractor import akka.actor.AddressFromURIString
class RemoteSettings(val config: Config, val systemName: String) { class RemoteSettings(val config: Config, val systemName: String) {
import config._ import config._

View file

@ -5,7 +5,7 @@
package akka.remote package akka.remote
import scala.reflect.BeanProperty 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.dispatch.SystemMessage
import akka.event.{ LoggingAdapter, Logging } import akka.event.{ LoggingAdapter, Logging }
import akka.AkkaException import akka.AkkaException
@ -284,7 +284,7 @@ trait RemoteMarshallingOps {
case r: RemoteRef case r: RemoteRef
if (provider.remoteSettings.LogReceive) log.debug("received remote-destined message {}", remoteMessage) if (provider.remoteSettings.LogReceive) log.debug("received remote-destined message {}", remoteMessage)
remoteMessage.originalReceiver match { 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) // 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) 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) case r log.error("dropping message {} for non-local recipient {} at {} local is {}", remoteMessage.payload, r, address, provider.transport.address)

View file

@ -12,7 +12,7 @@ import akka.actor.InternalActorRef
import akka.actor.Props import akka.actor.Props
import akka.config.ConfigurationException import akka.config.ConfigurationException
import akka.remote.RemoteScope import akka.remote.RemoteScope
import akka.actor.AddressExtractor import akka.actor.AddressFromURIString
import akka.actor.SupervisorStrategy import akka.actor.SupervisorStrategy
import akka.actor.Address import akka.actor.Address

View file

@ -133,7 +133,7 @@ akka.actor.deployment {
"deploy remote routers based on explicit deployment" in { "deploy remote routers based on explicit deployment" in {
val router = system.actorOf(Props[Echo].withRouter(RoundRobinRouter(2)) 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") router.path.address.toString must be("akka://remote_sys@localhost:12347")
val replies = for (i 1 to 5) yield { val replies = for (i 1 to 5) yield {
router ! "" router ! ""
@ -150,7 +150,7 @@ akka.actor.deployment {
"let remote deployment be overridden by local configuration" in { "let remote deployment be overridden by local configuration" in {
val router = system.actorOf(Props[Echo].withRouter(RoundRobinRouter(2)) 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") router.path.address.toString must be("akka://RemoteRouterSpec")
val replies = for (i 1 to 5) yield { val replies = for (i 1 to 5) yield {
router ! "" router ! ""
@ -167,7 +167,7 @@ akka.actor.deployment {
"let remote deployment router be overridden by local configuration" in { "let remote deployment router be overridden by local configuration" in {
val router = system.actorOf(Props[Echo].withRouter(RoundRobinRouter(2)) 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") router.path.address.toString must be("akka://remote_sys@localhost:12347")
val replies = for (i 1 to 5) yield { val replies = for (i 1 to 5) yield {
router ! "" router ! ""
@ -184,7 +184,7 @@ akka.actor.deployment {
"let remote deployment be overridden by remote configuration" in { "let remote deployment be overridden by remote configuration" in {
val router = system.actorOf(Props[Echo].withRouter(RoundRobinRouter(2)) 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") router.path.address.toString must be("akka://remote_sys@localhost:12347")
val replies = for (i 1 to 5) yield { val replies = for (i 1 to 5) yield {
router ! "" router ! ""