From eb5722d8ffec0578e62c6d3a0e43662d26d94b3b Mon Sep 17 00:00:00 2001 From: Yannic Klem Date: Mon, 17 Jan 2022 10:11:51 +0100 Subject: [PATCH] Allow to disable automatic passivation for specific shard regions Signed-off-by: Yannic Klem --- .../updater/actors/ShardRegionFactory.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/thingsearch/service/src/main/java/org/eclipse/ditto/thingsearch/service/updater/actors/ShardRegionFactory.java b/thingsearch/service/src/main/java/org/eclipse/ditto/thingsearch/service/updater/actors/ShardRegionFactory.java index 1d0f0f263a..23ac1d9789 100644 --- a/thingsearch/service/src/main/java/org/eclipse/ditto/thingsearch/service/updater/actors/ShardRegionFactory.java +++ b/thingsearch/service/src/main/java/org/eclipse/ditto/thingsearch/service/updater/actors/ShardRegionFactory.java @@ -115,11 +115,31 @@ public ActorRef getSearchUpdaterShardRegion(final int numberOfShards, * @return the shard region. */ public ActorRef createShardRegion(final int shards, final Props props, final String name, final String role) { + return createShardRegion(shards, true, props, name, role); + } + + /** + * Create a new shard region. + * + * @param shards number of shards. + * @param automaticPassivationEnabled indicates whether the entities should be passivated automatically. + * @param props props of actors in the shard region. + * @param name name of the shard region. + * @param role cluster role where the shard region starts. + * @return the shard region. + */ + public ActorRef createShardRegion(final int shards, final boolean automaticPassivationEnabled, final Props props, + final String name, final String role) { final ClusterSharding clusterSharding = ClusterSharding.get(actorSystem); final ClusterShardingSettings shardingSettings = ClusterShardingSettings.create(actorSystem).withRole(role); final ShardRegionExtractor shardRegionExtractor = ShardRegionExtractor.of(shards, actorSystem); - return clusterSharding.start(name, props, shardingSettings, shardRegionExtractor); + if (automaticPassivationEnabled) { + return clusterSharding.start(name, props, shardingSettings, shardRegionExtractor); + } else { + return clusterSharding.start(name, props, shardingSettings.withNoPassivationStrategy(), + shardRegionExtractor); + } } }