2019-09-19 04:23:27 -07:00
|
|
|
/*
|
2021-01-08 17:55:38 +01:00
|
|
|
* Copyright (C) 2019-2021 Lightbend Inc. <https://www.lightbend.com>
|
2019-09-19 04:23:27 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package akka.cluster.sharding
|
|
|
|
|
|
2021-11-04 21:10:04 +13:00
|
|
|
import akka.actor.ActorSystem
|
|
|
|
|
import akka.testkit.{ AkkaSpec, TestKit }
|
|
|
|
|
import com.typesafe.config.ConfigFactory
|
|
|
|
|
import org.scalatest.matchers.should.Matchers
|
|
|
|
|
import org.scalatest.wordspec.AnyWordSpec
|
|
|
|
|
|
2019-09-19 04:23:27 -07:00
|
|
|
import scala.concurrent.duration._
|
|
|
|
|
|
2021-11-04 21:10:04 +13:00
|
|
|
class ClusterShardingSettingsSpec extends AnyWordSpec with Matchers {
|
|
|
|
|
|
|
|
|
|
def settings(conf: String): ClusterShardingSettings = {
|
|
|
|
|
val config = ConfigFactory.parseString(conf).withFallback(AkkaSpec.testConf)
|
|
|
|
|
val system = ActorSystem("ClusterShardingSettingsSpec", config)
|
|
|
|
|
val clusterShardingSettings = ClusterShardingSettings(system)
|
|
|
|
|
TestKit.shutdownActorSystem(system)
|
|
|
|
|
clusterShardingSettings
|
|
|
|
|
}
|
2019-09-19 04:23:27 -07:00
|
|
|
|
2021-11-04 21:10:04 +13:00
|
|
|
val defaultSettings: ClusterShardingSettings = settings(conf = "")
|
2019-09-19 04:23:27 -07:00
|
|
|
|
|
|
|
|
"ClusterShardingSettings" must {
|
|
|
|
|
|
2021-11-04 21:10:04 +13:00
|
|
|
"have default passivation strategy (passivate idle entities after 120 seconds)" in {
|
2021-11-24 01:45:41 +13:00
|
|
|
defaultSettings.passivationStrategy shouldBe ClusterShardingSettings.IdlePassivationStrategy(
|
|
|
|
|
timeout = 120.seconds,
|
|
|
|
|
interval = 60.seconds)
|
2021-11-04 21:10:04 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"allow timeout for (default) idle passivation strategy to be configured (via config)" in {
|
|
|
|
|
settings("""
|
|
|
|
|
#passivation-idle-timeout
|
2021-12-10 01:04:27 +13:00
|
|
|
akka.cluster.sharding.passivation {
|
|
|
|
|
default-idle-strategy.idle-entity.timeout = 3 minutes
|
2021-11-04 21:10:04 +13:00
|
|
|
}
|
|
|
|
|
#passivation-idle-timeout
|
2021-11-24 01:45:41 +13:00
|
|
|
""").passivationStrategy shouldBe ClusterShardingSettings.IdlePassivationStrategy(
|
|
|
|
|
timeout = 3.minutes,
|
|
|
|
|
interval = 90.seconds)
|
2021-11-04 21:10:04 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"allow timeout for (default) idle passivation strategy to be configured (via factory method)" in {
|
|
|
|
|
defaultSettings
|
2021-12-10 01:04:27 +13:00
|
|
|
.withPassivationStrategy(
|
|
|
|
|
ClusterShardingSettings.PassivationStrategySettings.defaults.withIdleEntityPassivation(timeout = 42.seconds))
|
2021-11-24 01:45:41 +13:00
|
|
|
.passivationStrategy shouldBe ClusterShardingSettings.IdlePassivationStrategy(
|
|
|
|
|
timeout = 42.seconds,
|
|
|
|
|
interval = 21.seconds)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"allow timeout and interval for (default) idle passivation strategy to be configured (via config)" in {
|
|
|
|
|
settings("""
|
2021-12-10 01:04:27 +13:00
|
|
|
akka.cluster.sharding.passivation {
|
|
|
|
|
default-idle-strategy {
|
|
|
|
|
idle-entity {
|
2021-11-24 01:45:41 +13:00
|
|
|
timeout = 3 minutes
|
|
|
|
|
interval = 1 minute
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
""").passivationStrategy shouldBe ClusterShardingSettings.IdlePassivationStrategy(
|
|
|
|
|
timeout = 3.minutes,
|
|
|
|
|
interval = 1.minute)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"allow timeout and interval for (default) idle passivation strategy to be configured (via factory method)" in {
|
|
|
|
|
defaultSettings
|
2021-12-10 01:04:27 +13:00
|
|
|
.withPassivationStrategy(ClusterShardingSettings.PassivationStrategySettings.defaults
|
|
|
|
|
.withIdleEntityPassivation(timeout = 42.seconds, interval = 42.millis))
|
2021-11-24 01:45:41 +13:00
|
|
|
.passivationStrategy shouldBe ClusterShardingSettings.IdlePassivationStrategy(
|
|
|
|
|
timeout = 42.seconds,
|
|
|
|
|
interval = 42.millis)
|
2021-11-04 21:10:04 +13:00
|
|
|
}
|
|
|
|
|
|
2021-12-10 01:04:27 +13:00
|
|
|
"allow new default passivation strategy to be enabled (via config)" in {
|
|
|
|
|
settings("""
|
|
|
|
|
#passivation-new-default-strategy
|
|
|
|
|
akka.cluster.sharding.passivation {
|
|
|
|
|
strategy = default-strategy
|
|
|
|
|
}
|
|
|
|
|
#passivation-new-default-strategy
|
|
|
|
|
""").passivationStrategy shouldBe ClusterShardingSettings.LeastRecentlyUsedPassivationStrategy(
|
|
|
|
|
limit = 100000,
|
|
|
|
|
segmented = List(0.2, 0.8),
|
|
|
|
|
idle = None)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"allow new default passivation strategy limit to be configured (via config)" in {
|
|
|
|
|
settings("""
|
|
|
|
|
#passivation-new-default-strategy-configured
|
|
|
|
|
akka.cluster.sharding.passivation {
|
|
|
|
|
strategy = default-strategy
|
|
|
|
|
default-strategy {
|
|
|
|
|
active-entity-limit = 1000000
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#passivation-new-default-strategy-configured
|
|
|
|
|
""").passivationStrategy shouldBe ClusterShardingSettings.LeastRecentlyUsedPassivationStrategy(
|
|
|
|
|
limit = 1000000,
|
|
|
|
|
segmented = List(0.2, 0.8),
|
|
|
|
|
idle = None)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"allow new default passivation strategy with idle timeout to be configured (via config)" in {
|
|
|
|
|
settings("""
|
|
|
|
|
#passivation-new-default-strategy-with-idle
|
|
|
|
|
akka.cluster.sharding.passivation {
|
|
|
|
|
strategy = default-strategy
|
|
|
|
|
default-strategy {
|
|
|
|
|
idle-entity.timeout = 30.minutes
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#passivation-new-default-strategy-with-idle
|
|
|
|
|
""").passivationStrategy shouldBe ClusterShardingSettings.LeastRecentlyUsedPassivationStrategy(
|
|
|
|
|
limit = 100000,
|
|
|
|
|
segmented = List(0.2, 0.8),
|
|
|
|
|
idle = Some(ClusterShardingSettings.IdlePassivationStrategy(timeout = 30.minutes, interval = 15.minutes)))
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-04 21:10:04 +13:00
|
|
|
"allow least recently used passivation strategy to be configured (via config)" in {
|
|
|
|
|
settings("""
|
2021-12-10 01:04:27 +13:00
|
|
|
#custom-passivation-strategy
|
|
|
|
|
#lru-policy
|
|
|
|
|
akka.cluster.sharding.passivation {
|
|
|
|
|
strategy = custom-lru-strategy
|
|
|
|
|
custom-lru-strategy {
|
|
|
|
|
active-entity-limit = 1000000
|
|
|
|
|
replacement.policy = least-recently-used
|
2021-11-04 21:10:04 +13:00
|
|
|
}
|
|
|
|
|
}
|
2021-12-10 01:04:27 +13:00
|
|
|
#lru-policy
|
|
|
|
|
#custom-passivation-strategy
|
2021-11-24 01:45:41 +13:00
|
|
|
""").passivationStrategy shouldBe ClusterShardingSettings.LeastRecentlyUsedPassivationStrategy(
|
|
|
|
|
limit = 1000000,
|
2021-12-08 13:31:01 +13:00
|
|
|
segmented = Nil,
|
2021-11-24 01:45:41 +13:00
|
|
|
idle = None)
|
2021-11-04 21:10:04 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"allow least recently used passivation strategy to be configured (via factory method)" in {
|
|
|
|
|
defaultSettings
|
2021-12-10 01:04:27 +13:00
|
|
|
.withPassivationStrategy(
|
|
|
|
|
ClusterShardingSettings.PassivationStrategySettings.defaults
|
|
|
|
|
.withActiveEntityLimit(42000)
|
|
|
|
|
.withLeastRecentlyUsedReplacement())
|
2021-11-24 01:45:41 +13:00
|
|
|
.passivationStrategy shouldBe ClusterShardingSettings.LeastRecentlyUsedPassivationStrategy(
|
|
|
|
|
limit = 42000,
|
2021-12-08 13:31:01 +13:00
|
|
|
segmented = Nil,
|
|
|
|
|
idle = None)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"allow segmented least recently used passivation strategy to be configured (via config)" in {
|
|
|
|
|
settings("""
|
2021-12-10 01:04:27 +13:00
|
|
|
#slru-policy
|
|
|
|
|
akka.cluster.sharding.passivation {
|
|
|
|
|
strategy = custom-slru-strategy
|
|
|
|
|
custom-slru-strategy {
|
|
|
|
|
active-entity-limit = 1000000
|
|
|
|
|
replacement {
|
|
|
|
|
policy = least-recently-used
|
|
|
|
|
least-recently-used {
|
|
|
|
|
segmented {
|
|
|
|
|
levels = 2
|
|
|
|
|
proportions = [0.2, 0.8]
|
|
|
|
|
}
|
2021-12-08 13:31:01 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-10 01:04:27 +13:00
|
|
|
#slru-policy
|
2021-12-08 13:31:01 +13:00
|
|
|
""").passivationStrategy shouldBe ClusterShardingSettings.LeastRecentlyUsedPassivationStrategy(
|
|
|
|
|
limit = 1000000,
|
|
|
|
|
segmented = List(0.2, 0.8),
|
|
|
|
|
idle = None)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"allow 4-level segmented least recently used passivation strategy to be configured (via config)" in {
|
|
|
|
|
settings("""
|
2021-12-10 01:04:27 +13:00
|
|
|
#s4lru-policy
|
|
|
|
|
akka.cluster.sharding.passivation {
|
|
|
|
|
strategy = custom-s4lru-strategy
|
|
|
|
|
custom-s4lru-strategy {
|
|
|
|
|
active-entity-limit = 1000000
|
|
|
|
|
replacement {
|
|
|
|
|
policy = least-recently-used
|
|
|
|
|
least-recently-used {
|
|
|
|
|
segmented.levels = 4
|
|
|
|
|
}
|
2021-12-08 13:31:01 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-10 01:04:27 +13:00
|
|
|
#s4lru-policy
|
2021-12-08 13:31:01 +13:00
|
|
|
""").passivationStrategy shouldBe ClusterShardingSettings.LeastRecentlyUsedPassivationStrategy(
|
|
|
|
|
limit = 1000000,
|
|
|
|
|
segmented = List(0.25, 0.25, 0.25, 0.25),
|
|
|
|
|
idle = None)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"allow segmented least recently used passivation strategy to be configured (via factory method)" in {
|
|
|
|
|
defaultSettings
|
2021-12-10 01:04:27 +13:00
|
|
|
.withPassivationStrategy(ClusterShardingSettings.PassivationStrategySettings.defaults
|
|
|
|
|
.withActiveEntityLimit(42000)
|
|
|
|
|
.withReplacementPolicy(ClusterShardingSettings.PassivationStrategySettings.LeastRecentlyUsedSettings.defaults
|
|
|
|
|
.withSegmented(proportions = List(0.4, 0.3, 0.2, 0.1))))
|
2021-12-08 13:31:01 +13:00
|
|
|
.passivationStrategy shouldBe ClusterShardingSettings.LeastRecentlyUsedPassivationStrategy(
|
|
|
|
|
limit = 42000,
|
|
|
|
|
segmented = List(0.4, 0.3, 0.2, 0.1),
|
2021-11-24 01:45:41 +13:00
|
|
|
idle = None)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"allow least recently used passivation strategy with idle timeout to be configured (via config)" in {
|
|
|
|
|
settings("""
|
2021-12-10 01:04:27 +13:00
|
|
|
akka.cluster.sharding.passivation {
|
|
|
|
|
strategy = custom-lru-with-idle
|
|
|
|
|
custom-lru-with-idle {
|
|
|
|
|
active-entity-limit = 1000000
|
|
|
|
|
replacement.policy = least-recently-used
|
|
|
|
|
idle-entity.timeout = 30.minutes
|
2021-11-24 01:45:41 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
""").passivationStrategy shouldBe ClusterShardingSettings.LeastRecentlyUsedPassivationStrategy(
|
|
|
|
|
limit = 1000000,
|
2021-12-08 13:31:01 +13:00
|
|
|
segmented = Nil,
|
2021-11-24 01:45:41 +13:00
|
|
|
idle = Some(ClusterShardingSettings.IdlePassivationStrategy(timeout = 30.minutes, interval = 15.minutes)))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"allow least recently used passivation strategy with idle timeout to be configured (via factory method)" in {
|
|
|
|
|
defaultSettings
|
2021-12-10 01:04:27 +13:00
|
|
|
.withPassivationStrategy(
|
|
|
|
|
ClusterShardingSettings.PassivationStrategySettings.defaults
|
|
|
|
|
.withActiveEntityLimit(42000)
|
|
|
|
|
.withLeastRecentlyUsedReplacement()
|
|
|
|
|
.withIdleEntityPassivation(timeout = 42.minutes))
|
2021-11-24 01:45:41 +13:00
|
|
|
.passivationStrategy shouldBe ClusterShardingSettings.LeastRecentlyUsedPassivationStrategy(
|
|
|
|
|
limit = 42000,
|
2021-12-08 13:31:01 +13:00
|
|
|
segmented = Nil,
|
2021-11-24 01:45:41 +13:00
|
|
|
idle = Some(ClusterShardingSettings.IdlePassivationStrategy(timeout = 42.minutes, interval = 21.minutes)))
|
2019-09-19 04:23:27 -07:00
|
|
|
}
|
|
|
|
|
|
2021-11-17 21:54:02 +13:00
|
|
|
"allow most recently used passivation strategy to be configured (via config)" in {
|
|
|
|
|
settings("""
|
2021-12-10 01:04:27 +13:00
|
|
|
#mru-policy
|
|
|
|
|
akka.cluster.sharding.passivation {
|
|
|
|
|
strategy = custom-mru-strategy
|
|
|
|
|
custom-mru-strategy {
|
|
|
|
|
active-entity-limit = 1000000
|
|
|
|
|
replacement.policy = most-recently-used
|
2021-11-17 21:54:02 +13:00
|
|
|
}
|
|
|
|
|
}
|
2021-12-10 01:04:27 +13:00
|
|
|
#mru-policy
|
2021-11-24 01:45:41 +13:00
|
|
|
""").passivationStrategy shouldBe ClusterShardingSettings.MostRecentlyUsedPassivationStrategy(
|
|
|
|
|
limit = 1000000,
|
|
|
|
|
idle = None)
|
2021-11-17 21:54:02 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"allow most recently used passivation strategy to be configured (via factory method)" in {
|
|
|
|
|
defaultSettings
|
2021-12-10 01:04:27 +13:00
|
|
|
.withPassivationStrategy(
|
|
|
|
|
ClusterShardingSettings.PassivationStrategySettings.defaults
|
|
|
|
|
.withActiveEntityLimit(42000)
|
|
|
|
|
.withMostRecentlyUsedReplacement())
|
2021-11-24 01:45:41 +13:00
|
|
|
.passivationStrategy shouldBe ClusterShardingSettings.MostRecentlyUsedPassivationStrategy(
|
|
|
|
|
limit = 42000,
|
|
|
|
|
idle = None)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"allow most recently used passivation strategy with idle timeout to be configured (via config)" in {
|
|
|
|
|
settings("""
|
2021-12-10 01:04:27 +13:00
|
|
|
akka.cluster.sharding.passivation {
|
|
|
|
|
strategy = custom-mru-with-idle
|
|
|
|
|
custom-mru-with-idle {
|
|
|
|
|
active-entity-limit = 1000000
|
|
|
|
|
replacement.policy = most-recently-used
|
|
|
|
|
idle-entity.timeout = 30.minutes
|
2021-11-24 01:45:41 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
""").passivationStrategy shouldBe ClusterShardingSettings.MostRecentlyUsedPassivationStrategy(
|
|
|
|
|
limit = 1000000,
|
|
|
|
|
idle = Some(ClusterShardingSettings.IdlePassivationStrategy(timeout = 30.minutes, interval = 15.minutes)))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"allow most recently used passivation strategy with idle timeout to be configured (via factory method)" in {
|
|
|
|
|
defaultSettings
|
2021-12-10 01:04:27 +13:00
|
|
|
.withPassivationStrategy(
|
|
|
|
|
ClusterShardingSettings.PassivationStrategySettings.defaults
|
|
|
|
|
.withActiveEntityLimit(42000)
|
|
|
|
|
.withMostRecentlyUsedReplacement()
|
|
|
|
|
.withIdleEntityPassivation(timeout = 42.minutes))
|
2021-11-24 01:45:41 +13:00
|
|
|
.passivationStrategy shouldBe ClusterShardingSettings.MostRecentlyUsedPassivationStrategy(
|
|
|
|
|
limit = 42000,
|
|
|
|
|
idle = Some(ClusterShardingSettings.IdlePassivationStrategy(timeout = 42.minutes, interval = 21.minutes)))
|
2021-11-17 21:54:02 +13:00
|
|
|
}
|
|
|
|
|
|
2021-11-19 00:09:05 +13:00
|
|
|
"allow least frequently used passivation strategy to be configured (via config)" in {
|
|
|
|
|
settings("""
|
2021-12-10 01:04:27 +13:00
|
|
|
#lfu-policy
|
|
|
|
|
akka.cluster.sharding.passivation {
|
|
|
|
|
strategy = custom-lfu-strategy
|
|
|
|
|
custom-lfu-strategy {
|
|
|
|
|
active-entity-limit = 1000000
|
|
|
|
|
replacement.policy = least-frequently-used
|
2021-11-19 00:09:05 +13:00
|
|
|
}
|
|
|
|
|
}
|
2021-12-10 01:04:27 +13:00
|
|
|
#lfu-policy
|
2021-11-24 01:45:41 +13:00
|
|
|
""").passivationStrategy shouldBe ClusterShardingSettings.LeastFrequentlyUsedPassivationStrategy(
|
|
|
|
|
limit = 1000000,
|
2021-12-08 13:31:01 +13:00
|
|
|
dynamicAging = false,
|
2021-11-24 01:45:41 +13:00
|
|
|
idle = None)
|
2021-11-19 00:09:05 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"allow least frequently used passivation strategy to be configured (via factory method)" in {
|
|
|
|
|
defaultSettings
|
2021-12-10 01:04:27 +13:00
|
|
|
.withPassivationStrategy(
|
|
|
|
|
ClusterShardingSettings.PassivationStrategySettings.defaults
|
|
|
|
|
.withActiveEntityLimit(42000)
|
|
|
|
|
.withLeastFrequentlyUsedReplacement())
|
2021-11-24 01:45:41 +13:00
|
|
|
.passivationStrategy shouldBe ClusterShardingSettings.LeastFrequentlyUsedPassivationStrategy(
|
|
|
|
|
limit = 42000,
|
2021-12-08 13:31:01 +13:00
|
|
|
dynamicAging = false,
|
2021-11-24 01:45:41 +13:00
|
|
|
idle = None)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"allow least frequently used passivation strategy with idle timeout to be configured (via config)" in {
|
|
|
|
|
settings("""
|
2021-12-10 01:04:27 +13:00
|
|
|
akka.cluster.sharding.passivation {
|
|
|
|
|
strategy = custom-lfu-with-idle
|
|
|
|
|
custom-lfu-with-idle {
|
|
|
|
|
active-entity-limit = 1000000
|
|
|
|
|
replacement.policy = least-frequently-used
|
|
|
|
|
idle-entity.timeout = 30.minutes
|
2021-11-24 01:45:41 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
""").passivationStrategy shouldBe ClusterShardingSettings.LeastFrequentlyUsedPassivationStrategy(
|
|
|
|
|
limit = 1000000,
|
2021-12-08 13:31:01 +13:00
|
|
|
dynamicAging = false,
|
2021-11-24 01:45:41 +13:00
|
|
|
idle = Some(ClusterShardingSettings.IdlePassivationStrategy(timeout = 30.minutes, interval = 15.minutes)))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"allow least frequently used passivation strategy with idle timeout to be configured (via factory method)" in {
|
|
|
|
|
defaultSettings
|
2021-12-10 01:04:27 +13:00
|
|
|
.withPassivationStrategy(
|
|
|
|
|
ClusterShardingSettings.PassivationStrategySettings.defaults
|
|
|
|
|
.withActiveEntityLimit(42000)
|
|
|
|
|
.withLeastFrequentlyUsedReplacement()
|
|
|
|
|
.withIdleEntityPassivation(timeout = 42.minutes))
|
2021-11-24 01:45:41 +13:00
|
|
|
.passivationStrategy shouldBe ClusterShardingSettings.LeastFrequentlyUsedPassivationStrategy(
|
|
|
|
|
limit = 42000,
|
2021-12-08 13:31:01 +13:00
|
|
|
dynamicAging = false,
|
2021-11-24 01:45:41 +13:00
|
|
|
idle = Some(ClusterShardingSettings.IdlePassivationStrategy(timeout = 42.minutes, interval = 21.minutes)))
|
2021-11-19 00:09:05 +13:00
|
|
|
}
|
|
|
|
|
|
2021-12-08 13:31:01 +13:00
|
|
|
"allow least frequently used passivation strategy with dynamic aging to be configured (via config)" in {
|
|
|
|
|
settings("""
|
2021-12-10 01:04:27 +13:00
|
|
|
#lfuda-policy
|
|
|
|
|
akka.cluster.sharding.passivation {
|
|
|
|
|
strategy = custom-lfu-with-dynamic-aging
|
|
|
|
|
custom-lfu-with-dynamic-aging {
|
|
|
|
|
active-entity-limit = 1000
|
|
|
|
|
replacement {
|
|
|
|
|
policy = least-frequently-used
|
|
|
|
|
least-frequently-used {
|
|
|
|
|
dynamic-aging = on
|
|
|
|
|
}
|
2021-12-08 13:31:01 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-10 01:04:27 +13:00
|
|
|
#lfuda-policy
|
2021-12-08 13:31:01 +13:00
|
|
|
""").passivationStrategy shouldBe ClusterShardingSettings.LeastFrequentlyUsedPassivationStrategy(
|
|
|
|
|
limit = 1000,
|
|
|
|
|
dynamicAging = true,
|
|
|
|
|
idle = None)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"allow least frequently used passivation strategy with dynamic aging to be configured (via factory method)" in {
|
|
|
|
|
defaultSettings
|
2021-12-10 01:04:27 +13:00
|
|
|
.withPassivationStrategy(
|
|
|
|
|
ClusterShardingSettings.PassivationStrategySettings.defaults
|
|
|
|
|
.withActiveEntityLimit(42000)
|
|
|
|
|
.withReplacementPolicy(
|
|
|
|
|
ClusterShardingSettings.PassivationStrategySettings.LeastFrequentlyUsedSettings.defaults
|
|
|
|
|
.withDynamicAging()))
|
2021-12-08 13:31:01 +13:00
|
|
|
.passivationStrategy shouldBe ClusterShardingSettings.LeastFrequentlyUsedPassivationStrategy(
|
|
|
|
|
limit = 42000,
|
|
|
|
|
dynamicAging = true,
|
|
|
|
|
idle = None)
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-04 21:10:04 +13:00
|
|
|
"disable automatic passivation if `remember-entities` is enabled (via config)" in {
|
|
|
|
|
settings("""
|
|
|
|
|
akka.cluster.sharding.remember-entities = on
|
|
|
|
|
""").passivationStrategy shouldBe ClusterShardingSettings.NoPassivationStrategy
|
2019-09-19 04:23:27 -07:00
|
|
|
}
|
|
|
|
|
|
2021-11-04 21:10:04 +13:00
|
|
|
"disable automatic passivation if `remember-entities` is enabled (via factory method)" in {
|
|
|
|
|
defaultSettings
|
2019-09-19 04:23:27 -07:00
|
|
|
.withRememberEntities(true)
|
2021-11-04 21:10:04 +13:00
|
|
|
.passivationStrategy shouldBe ClusterShardingSettings.NoPassivationStrategy
|
2019-09-19 04:23:27 -07:00
|
|
|
}
|
|
|
|
|
|
2021-11-04 21:10:04 +13:00
|
|
|
"disable automatic passivation if idle timeout is set to zero (via config)" in {
|
|
|
|
|
settings("""
|
2021-12-10 01:04:27 +13:00
|
|
|
akka.cluster.sharding.passivation.default-idle-strategy.idle-entity.timeout = 0
|
2021-11-04 21:10:04 +13:00
|
|
|
""").passivationStrategy shouldBe ClusterShardingSettings.NoPassivationStrategy
|
2019-09-19 04:23:27 -07:00
|
|
|
}
|
|
|
|
|
|
2021-11-04 21:10:04 +13:00
|
|
|
"disable automatic passivation if idle timeout is set to zero (via factory method)" in {
|
|
|
|
|
defaultSettings
|
2021-12-10 01:04:27 +13:00
|
|
|
.withPassivationStrategy(ClusterShardingSettings.PassivationStrategySettings.defaults.withIdleEntityPassivation(
|
|
|
|
|
timeout = Duration.Zero))
|
2021-12-08 13:31:01 +13:00
|
|
|
.passivationStrategy shouldBe ClusterShardingSettings.NoPassivationStrategy
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"disable automatic passivation if disabled (via factory method)" in {
|
|
|
|
|
defaultSettings
|
|
|
|
|
.withNoPassivationStrategy()
|
2021-11-04 21:10:04 +13:00
|
|
|
.passivationStrategy shouldBe ClusterShardingSettings.NoPassivationStrategy
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
"support old `passivate-idle-entity-after` setting (overriding new strategy settings)" in {
|
|
|
|
|
settings("""
|
|
|
|
|
akka.cluster.sharding {
|
|
|
|
|
passivate-idle-entity-after = 5 minutes
|
2021-12-10 01:04:27 +13:00
|
|
|
passivation.strategy = default-strategy
|
2021-11-04 21:10:04 +13:00
|
|
|
}
|
2021-11-24 01:45:41 +13:00
|
|
|
""").passivationStrategy shouldBe ClusterShardingSettings.IdlePassivationStrategy(
|
|
|
|
|
timeout = 5.minutes,
|
|
|
|
|
interval = 2.5.minutes)
|
2021-11-04 21:10:04 +13:00
|
|
|
}
|
2019-09-19 04:23:27 -07:00
|
|
|
|
2021-11-04 21:10:04 +13:00
|
|
|
}
|
2019-09-19 04:23:27 -07:00
|
|
|
}
|