Skip to content

Commit

Permalink
Use single dispatcher for enforcement caches instead of two
Browse files Browse the repository at this point in the history
* I doubt that it's really necessary to have separate dispatchers for each cache

Signed-off-by: Yannic Klem <Yannic.Klem@bosch.io>
  • Loading branch information
Yannic92 committed Apr 29, 2022
1 parent e24934a commit 78eab6b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
*/
public final class Contextual<T extends WithDittoHeaders> implements WithSender<T>, WithDittoHeaders {

private static final String POLICY_ENFORCER_CACHE_DISPATCHER = "policy-enforcer-cache-dispatcher";
private static final String POLICY_ENFORCER_CACHE_DISPATCHER = "enforcement-cache-dispatcher";

@Nullable private final T message;
private final ActorRef self;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import akka.actor.ActorContext;
import akka.actor.ActorRef;
import akka.actor.Props;
import akka.dispatch.MessageDispatcher;

/**
* Ditto default implementation of{@link EnforcerActorFactory}.
Expand Down Expand Up @@ -98,17 +99,17 @@ public ActorRef startEnforcerActor(final ActorContext context,
final AsyncCacheLoader<EnforcementCacheKey, Entry<EnforcementCacheKey>> thingEnforcerIdCacheLoader =
new ThingEnforcementIdCacheLoader(askWithRetryConfig, actorSystem.getScheduler(),
thingsShardRegionProxy);
final MessageDispatcher enforcementCacheDispatcher =
actorSystem.dispatchers().lookup("enforcement-cache-dispatcher");
final Cache<EnforcementCacheKey, Entry<EnforcementCacheKey>> thingIdCache =
CacheFactory.createCache(thingEnforcerIdCacheLoader, cachesConfig.getIdCacheConfig(),
ID_CACHE_METRIC_NAME_PREFIX + ThingCommand.RESOURCE_TYPE,
actorSystem.dispatchers().lookup("thing-id-cache-dispatcher"));
ID_CACHE_METRIC_NAME_PREFIX + ThingCommand.RESOURCE_TYPE, enforcementCacheDispatcher);

final AsyncCacheLoader<EnforcementCacheKey, Entry<PolicyEnforcer>> policyEnforcerCacheLoader =
new PolicyEnforcerCacheLoader(askWithRetryConfig, actorSystem.getScheduler(), policiesShardRegionProxy);
final Cache<EnforcementCacheKey, Entry<PolicyEnforcer>> policyEnforcerCache =
CacheFactory.createCache(policyEnforcerCacheLoader, cachesConfig.getEnforcerCacheConfig(),
ENFORCER_CACHE_METRIC_NAME_PREFIX + "policy",
actorSystem.dispatchers().lookup("policy-enforcer-cache-dispatcher"));
ENFORCER_CACHE_METRIC_NAME_PREFIX + "policy", enforcementCacheDispatcher);
final Cache<EnforcementCacheKey, Entry<Enforcer>> projectedEnforcerCache =
policyEnforcerCache.projectValues(PolicyEnforcer::project, PolicyEnforcer::embed);

Expand Down
7 changes: 1 addition & 6 deletions concierge/service/src/main/resources/concierge.conf
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,7 @@ blocked-namespaces-dispatcher {
throughput = 5
}

thing-id-cache-dispatcher {
type = "Dispatcher"
executor = "thread-pool-executor"
}

policy-enforcer-cache-dispatcher {
enforcement-cache-dispatcher {
type = "Dispatcher"
executor = "thread-pool-executor"
}
Expand Down
5 changes: 0 additions & 5 deletions concierge/service/src/test/resources/test.conf
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,3 @@ akka {
}
}
}

policy-enforcer-cache-dispatcher {
type = "Dispatcher"
executor = "thread-pool-executor"
}

0 comments on commit 78eab6b

Please sign in to comment.