Merge pull request #20264 from akka/wip-20263-npe-chr-patriknw
lazy usage of defaultAddress in ConsistentHashingRouter, #20263
This commit is contained in:
commit
08ec7d0f06
1 changed files with 11 additions and 2 deletions
|
|
@ -149,7 +149,17 @@ final case class ConsistentHashingRoutingLogic(
|
||||||
def this(system: ActorSystem) =
|
def this(system: ActorSystem) =
|
||||||
this(system, virtualNodesFactor = 0, hashMapping = ConsistentHashingRouter.emptyConsistentHashMapping)
|
this(system, virtualNodesFactor = 0, hashMapping = ConsistentHashingRouter.emptyConsistentHashMapping)
|
||||||
|
|
||||||
private val selfAddress = system.asInstanceOf[ExtendedActorSystem].provider.getDefaultAddress
|
private lazy val selfAddress = {
|
||||||
|
// Important that this is lazy, because consistent hashing routing pool is used by SimpleDnsManager
|
||||||
|
// that can be activated early, before the transport defaultAddress is set in the startup.
|
||||||
|
// See issue #20263.
|
||||||
|
// If defaultAddress is not available the message will not be routed, but new attempt
|
||||||
|
// is performed for next message.
|
||||||
|
val a = ConsistentHashingRoutingLogic.defaultAddress(system)
|
||||||
|
if (a == null)
|
||||||
|
throw new IllegalStateException("defaultAddress not available yet")
|
||||||
|
a
|
||||||
|
}
|
||||||
val vnodes =
|
val vnodes =
|
||||||
if (virtualNodesFactor == 0) system.settings.DefaultVirtualNodesFactor
|
if (virtualNodesFactor == 0) system.settings.DefaultVirtualNodesFactor
|
||||||
else virtualNodesFactor
|
else virtualNodesFactor
|
||||||
|
|
@ -201,7 +211,6 @@ final case class ConsistentHashingRoutingLogic(
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
case NonFatal(e) ⇒
|
case NonFatal(e) ⇒
|
||||||
// serialization failed
|
|
||||||
log.warning("Couldn't route message with consistent hash key [{}] due to [{}]", hashData, e.getMessage)
|
log.warning("Couldn't route message with consistent hash key [{}] due to [{}]", hashData, e.getMessage)
|
||||||
NoRoutee
|
NoRoutee
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue