Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ static ResilienceConfiguration createResilienceConfiguration(
Try<Destination>
tryGetDestination( @Nonnull final String destinationName, @Nonnull final DestinationOptions options )
{
if( Cache.preLookupCheckEnabled && !preLookupCheckSuccessful(destinationName) ) {
if( Cache.preLookupCheckEnabled && !preLookupCheckSuccessful(destinationName, options) ) {
final String msg = "Destination %s was not found among the destinations of the current tenant.";
return Try.failure(new DestinationNotFoundException(String.format(msg, destinationName)));
}
Expand Down Expand Up @@ -388,9 +388,9 @@ private static boolean hasCauseAssignableFrom( @Nonnull final Throwable t, @Nonn
return ExceptionUtils.getThrowableList(t).stream().map(Throwable::getClass).anyMatch(cls::isAssignableFrom);
}

private boolean preLookupCheckSuccessful( final String destinationName )
private boolean preLookupCheckSuccessful( final String destinationName, final DestinationOptions options )
{
return getAllDestinationProperties()
return getAllDestinationProperties(DestinationServiceOptionsAugmenter.getRetrievalStrategy(options).get())
.stream()
.anyMatch(properties -> properties.get(DestinationProperty.NAME).contains(destinationName));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static GetOrComputeAllDestinationsCommand prepareCommand(

final CacheKey cacheKey = CacheKey.ofTenantOptionalIsolation();

cacheKey.append(destinationOptions);
cacheKey.append(DestinationServiceOptionsAugmenter.getRetrievalStrategy(destinationOptions));

final ReentrantLock isolationLock =
Objects.requireNonNull(isolationLocks.get(cacheKey, any -> new ReentrantLock()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1267,9 +1267,13 @@ void testConcurrentFetchSameDestinationButDifferentTenant()
assertThat(DestinationService.Cache.isolationLocks().asMap())
.containsOnlyKeys(
CacheKey.fromIds("TenantA", null).append(destinationName, options),
CacheKey.fromIds("TenantA", null).append(options),
CacheKey
.fromIds("TenantA", null)
.append(DestinationServiceOptionsAugmenter.getRetrievalStrategy(options)),
CacheKey.fromIds("TenantB", null).append(destinationName, options),
CacheKey.fromIds("TenantB", null).append(options));
CacheKey
.fromIds("TenantB", null)
.append(DestinationServiceOptionsAugmenter.getRetrievalStrategy(options)));

// assert cache entries for one get-single command for each tenant
assertThat(DestinationService.Cache.instanceSingle().asMap())
Expand Down Expand Up @@ -1339,7 +1343,9 @@ void testPrincipalIsolationForDestinationWithUserPropagationWithExchangeOnlyStra
.containsOnlyKeys(
CacheKey.of(subscriberTenant, principal1).append(destinationName, options),
CacheKey.of(subscriberTenant, principal2).append(destinationName, options),
CacheKey.of(subscriberTenant, null).append(options));
CacheKey
.of(subscriberTenant, null)
.append(DestinationServiceOptionsAugmenter.getRetrievalStrategy(options)));

assertThat(DestinationService.Cache.instanceSingle().asMap())
.containsOnlyKeys(
Expand Down Expand Up @@ -1383,7 +1389,9 @@ void testPrincipalIsolationForDestinationWithUserPropagationWithDefaultExchangeS
assertThat(DestinationService.Cache.isolationLocks().asMap())
.containsOnlyKeys(
CacheKey.of(subscriberTenant, null).append(destinationName, options),
CacheKey.of(subscriberTenant, null).append(options));
CacheKey
.of(subscriberTenant, null)
.append(DestinationServiceOptionsAugmenter.getRetrievalStrategy(options)));

assertThat(DestinationService.Cache.instanceSingle().asMap())
.containsOnlyKeys(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ void testCommandIsIdempotent()
assertThat(result.get()).containsExactly(destination);

assertThat(allDestinationsCache.estimatedSize()).isEqualTo(1);
assertThat(allDestinationsCache.getIfPresent(CacheKey.ofNoIsolation().append(EMPTY_OPTIONS)))
assertThat(
allDestinationsCache
.getIfPresent(
CacheKey
.ofNoIsolation()
.append(DestinationServiceOptionsAugmenter.getRetrievalStrategy(EMPTY_OPTIONS))))
.containsExactly(destination);
verify(tryGetAllDestinations, times(1)).get();
}
Expand All @@ -104,8 +109,10 @@ void testIsolationAndAtomicityPerTenant()
final CountDownLatch mainThreadLatch = new CountDownLatch(1);
final CountDownLatch getAllLatch = new CountDownLatch(1);
final AtomicInteger lockInvocations = new AtomicInteger();
final CacheKey t1Key = CacheKey.of(t1, null).append(EMPTY_OPTIONS);
final CacheKey t2Key = CacheKey.of(t2, null).append(EMPTY_OPTIONS);
final CacheKey t1Key =
CacheKey.of(t1, null).append(DestinationServiceOptionsAugmenter.getRetrievalStrategy(EMPTY_OPTIONS));
final CacheKey t2Key =
CacheKey.of(t2, null).append(DestinationServiceOptionsAugmenter.getRetrievalStrategy(EMPTY_OPTIONS));
final ReentrantLock tenantIsolationLock = spy(ReentrantLock.class);

doAnswer(invocation -> {
Expand Down
Loading