From f55c711601213597883bb8be4efdd70222152ca4 Mon Sep 17 00:00:00 2001 From: Martin Krasser Date: Wed, 11 Dec 2013 08:18:52 +0100 Subject: [PATCH] !per #3785 Change default implementation of processorId - also affects channel ids. --- akka-docs/rst/java/persistence.rst | 20 ++++++++----------- akka-docs/rst/scala/persistence.rst | 18 +++++++---------- .../scala/akka/persistence/Persistence.scala | 2 +- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/akka-docs/rst/java/persistence.rst b/akka-docs/rst/java/persistence.rst index c9cb76a610..f03032eddf 100644 --- a/akka-docs/rst/java/persistence.rst +++ b/akka-docs/rst/java/persistence.rst @@ -143,20 +143,17 @@ Identifiers ----------- A processor must have an identifier that doesn't change across different actor incarnations. It defaults to the -``String`` representation of processor's path and can be obtained via the ``processorId`` method. +``String`` representation of processor's path without the address part and can be obtained via the ``processorId`` +method. .. includecode:: code/docs/persistence/PersistenceDocTest.java#processor-id Applications can customize a processor's id by specifying an actor name during processor creation as shown in -section :ref:`processors-java`. This works well when using local actor references but may cause problems with remote -actor references because their paths also contain deployment information such as host and port (and actor deployments -are likely to change during the lifetime of an application). In this case, ``UntypedProcessor`` implementation classes -should override ``processorId``. +section :ref:`processors-java`. This changes that processor's name in its actor hierarchy and hence influences only +part of the processor id. To fully customize a processor's id, the ``processorId`` method should be overridden. .. includecode:: code/docs/persistence/PersistenceDocTest.java#processor-id-override -Later versions of Akka persistence will likely offer a possibility to migrate processor ids. - .. _channels-java: Channels @@ -299,11 +296,10 @@ Default is ``Resolve.off()`` which means no resolution. Find out more in the ``D Identifiers ----------- -In the same way as :ref:`processors-java`, channels also have an identifier that defaults to a channel's path. A channel -identifier can therefore be customized by using a custom actor name at channel creation. As already mentioned, this -works well when using local actor references but may cause problems with remote actor references. In this case, an -application-defined channel id should be provided as argument to ``Channel.props(String)`` or -``PersistentChannel.props(String)``. +In the same way as :ref:`processors`, channels also have an identifier that defaults to a channel's path. A channel +identifier can therefore be customized by using a custom actor name at channel creation. This changes that channel's +name in its actor hierarchy and hence influences only part of the channel identifier. To fully customize a channel +identifier, it should be provided as argument ``Channel.props(String)`` or ``PersistentChannel.props(String)``. .. includecode:: code/docs/persistence/PersistenceDocTest.java#channel-id-override diff --git a/akka-docs/rst/scala/persistence.rst b/akka-docs/rst/scala/persistence.rst index 6a7b965a30..e7a9edb23f 100644 --- a/akka-docs/rst/scala/persistence.rst +++ b/akka-docs/rst/scala/persistence.rst @@ -138,20 +138,17 @@ Identifiers ----------- A processor must have an identifier that doesn't change across different actor incarnations. It defaults to the -``String`` representation of processor's path and can be obtained via the ``processorId`` method. +``String`` representation of processor's path without the address part and can be obtained via the ``processorId`` +method. .. includecode:: code/docs/persistence/PersistenceDocSpec.scala#processor-id Applications can customize a processor's id by specifying an actor name during processor creation as shown in -section :ref:`processors`. This works well when using local actor references but may cause problems with remote -actor references because their paths also contain deployment information such as host and port (and actor deployments -are likely to change during the lifetime of an application). In this case, ``Processor`` implementation classes -should override ``processorId``. +section :ref:`processors`. This changes that processor's name in its actor hierarchy and hence influences only +part of the processor id. To fully customize a processor's id, the ``processorId`` method should be overridden. .. includecode:: code/docs/persistence/PersistenceDocSpec.scala#processor-id-override -Later versions of Akka persistence will likely offer a possibility to migrate processor ids. - .. _channels: Channels @@ -295,10 +292,9 @@ Identifiers ----------- In the same way as :ref:`processors`, channels also have an identifier that defaults to a channel's path. A channel -identifier can therefore be customized by using a custom actor name at channel creation. As already mentioned, this -works well when using local actor references but may cause problems with remote actor references. In this case, an -application-defined channel id should be provided as argument to ``Channel.props(String)`` or -``PersistentChannel.props(String)``. +identifier can therefore be customized by using a custom actor name at channel creation. This changes that channel's +name in its actor hierarchy and hence influences only part of the channel identifier. To fully customize a channel +identifier, it should be provided as argument ``Channel.props(String)`` or ``PersistentChannel.props(String)``. .. includecode:: code/docs/persistence/PersistenceDocSpec.scala#channel-id-override diff --git a/akka-persistence/src/main/scala/akka/persistence/Persistence.scala b/akka-persistence/src/main/scala/akka/persistence/Persistence.scala index f45ab66fa8..a7cd106646 100644 --- a/akka-persistence/src/main/scala/akka/persistence/Persistence.scala +++ b/akka-persistence/src/main/scala/akka/persistence/Persistence.scala @@ -86,5 +86,5 @@ class Persistence(val system: ExtendedActorSystem) extends Extension { system.asInstanceOf[ActorSystemImpl].systemActorOf(Props(pluginClass).withDispatcher(pluginDispatcherId), pluginType) } - private def id(ref: ActorRef) = ref.path.toStringWithAddress(system.provider.getDefaultAddress) + private def id(ref: ActorRef) = ref.path.elements.mkString("/", "/", "") }