Improve logging in DistributedData extension (#27051)
* and don't load extension from ClusterReceptionist since that will trigger the warning logging if role is defined
This commit is contained in:
parent
c5e9b5918c
commit
375228273f
4 changed files with 26 additions and 6 deletions
|
|
@ -23,6 +23,8 @@ akka.cluster.typed.receptionist {
|
|||
# Settings for the Distributed Data replicator used by Receptionist.
|
||||
# Same layout as akka.cluster.distributed-data.
|
||||
distributed-data = ${akka.cluster.distributed-data}
|
||||
# make sure that by default it's for all roles (Play loads config in different way)
|
||||
distributed-data.role = ""
|
||||
}
|
||||
|
||||
akka {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ package akka.cluster.ddata.typed.scaladsl
|
|||
|
||||
import akka.actor.typed.{ ActorRef, ActorSystem, Extension, ExtensionId, Props }
|
||||
import akka.actor.ExtendedActorSystem
|
||||
import akka.cluster.Cluster
|
||||
import akka.cluster.{ ddata => dd }
|
||||
import akka.cluster.ddata.SelfUniqueAddress
|
||||
|
||||
|
|
@ -39,8 +40,15 @@ class DistributedData(system: ActorSystem[_]) extends Extension {
|
|||
*/
|
||||
val replicator: ActorRef[Replicator.Command] =
|
||||
if (isTerminated) {
|
||||
system.log.warning(
|
||||
"Replicator points to dead letters: Make sure the cluster node is not terminated and has the proper role!")
|
||||
val log = system.log.withLoggerClass(getClass)
|
||||
if (Cluster(untypedSystem).isTerminated)
|
||||
log.warning("Replicator points to dead letters, because Cluster is terminated.")
|
||||
else
|
||||
log.warning(
|
||||
"Replicator points to dead letters. Make sure the cluster node has the proper role. " +
|
||||
"Node has roles [], Distributed Data is configured for roles []",
|
||||
Cluster(untypedSystem).selfRoles.mkString(","),
|
||||
settings.roles.mkString(","))
|
||||
system.deadLetters
|
||||
} else {
|
||||
val underlyingReplicator = dd.DistributedData(untypedSystem).replicator
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import akka.actor.typed.scaladsl.{ ActorContext, Behaviors }
|
|||
import akka.actor.typed.{ ActorRef, Behavior, Terminated }
|
||||
import akka.annotation.InternalApi
|
||||
import akka.cluster.ClusterEvent.MemberRemoved
|
||||
import akka.cluster.ddata.typed.scaladsl.DistributedData
|
||||
import akka.cluster.ddata.{ ORMultiMap, ORMultiMapKey, Replicator }
|
||||
import akka.cluster.{ Cluster, ClusterEvent, UniqueAddress }
|
||||
import akka.remote.AddressUidExtension
|
||||
|
|
@ -25,6 +24,7 @@ import akka.cluster.ClusterEvent.ClusterShuttingDown
|
|||
import akka.cluster.ClusterEvent.MemberJoined
|
||||
import akka.cluster.ClusterEvent.MemberUp
|
||||
import akka.cluster.ClusterEvent.MemberWeaklyUp
|
||||
import akka.cluster.ddata.SelfUniqueAddress
|
||||
|
||||
// just to provide a log class
|
||||
/** INTERNAL API */
|
||||
|
|
@ -75,7 +75,9 @@ private[typed] object ClusterReceptionist extends ReceptionistBehaviorProvider {
|
|||
case _ => throw new IllegalStateException("Cannot actually happen")
|
||||
}
|
||||
val cluster = Cluster(untypedSystem)
|
||||
implicit val selfNodeAddress = DistributedData(ctx.system).selfUniqueAddress
|
||||
// don't use DistributedData.selfUniqueAddress here, because that will initialize extension, which
|
||||
// isn't used otherwise by the ClusterReceptionist
|
||||
implicit val selfNodeAddress = SelfUniqueAddress(cluster.selfUniqueAddress)
|
||||
|
||||
val replicator = ctx.actorOf(Replicator.props(settings.replicatorSettings), "replicator")
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import akka.actor.Extension
|
|||
import akka.actor.ExtensionId
|
||||
import akka.actor.ExtensionIdProvider
|
||||
import akka.cluster.{ Cluster, UniqueAddress }
|
||||
import akka.event.Logging
|
||||
|
||||
object DistributedData extends ExtensionId[DistributedData] with ExtensionIdProvider {
|
||||
override def get(system: ActorSystem): DistributedData = super.get(system)
|
||||
|
|
@ -37,8 +38,15 @@ class DistributedData(system: ExtendedActorSystem) extends Extension {
|
|||
*/
|
||||
val replicator: ActorRef =
|
||||
if (isTerminated) {
|
||||
system.log.warning(
|
||||
"Replicator points to dead letters: Make sure the cluster node is not terminated and has the proper role!")
|
||||
val log = Logging(system, getClass)
|
||||
if (Cluster(system).isTerminated)
|
||||
log.warning("Replicator points to dead letters, because Cluster is terminated.")
|
||||
else
|
||||
log.warning(
|
||||
"Replicator points to dead letters. Make sure the cluster node has the proper role. " +
|
||||
"Node has roles [], Distributed Data is configured for roles []",
|
||||
Cluster(system).selfRoles.mkString(","),
|
||||
settings.roles.mkString(","))
|
||||
system.deadLetters
|
||||
} else {
|
||||
system.systemActorOf(Replicator.props(settings), ReplicatorSettings.name(system, None))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue