Skip to content

Commit 128506d

Browse files
author
Peter Alfonsi
committed
remove removalNotification
Signed-off-by: Peter Alfonsi <petealft@amazon.com>
1 parent b498909 commit 128506d

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

modules/cache-common/src/main/java/org/opensearch/cache/common/tier/TieredSpilloverCache.java

-8
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,6 @@ public void put(ICacheKey<K> key, V value) {
278278
}
279279
updateStatsOnPut(cacheValueTuple.v2(), key, value);
280280
}
281-
} else {
282-
// Signal to the caller that the key didn't enter the cache by sending a removal notification.
283-
removalListener.onRemoval(new RemovalNotification<>(key, value, RemovalReason.EXPLICIT));
284281
}
285282
}
286283

@@ -403,11 +400,6 @@ private Tuple<V, Tuple<Boolean, Boolean>> compute(
403400
throw new IllegalStateException(ex);
404401
}
405402
}
406-
if (wasRejectedByPolicy) {
407-
// Signal to the caller that the key didn't enter the cache by sending a removal notification.
408-
// This case does not count as a cache miss.
409-
removalListener.onRemoval(new RemovalNotification<>(key, value, RemovalReason.EXPLICIT));
410-
}
411403
return new Tuple<>(value, new Tuple<>(wasCacheMiss, wasRejectedByPolicy));
412404
}
413405

modules/cache-common/src/test/java/org/opensearch/cache/common/tier/TieredSpilloverCacheTests.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,7 @@ public CachedQueryResult.PolicyValues apply(String s) {
15671567
expectedKeys++;
15681568
}
15691569
}
1570-
assertEquals(keyValueMap.size() - expectedKeys, removalListener.evictionsMetric.count());
1570+
assertEquals(0, removalListener.evictionsMetric.count());
15711571
assertEquals(0, getHitsForTier(tieredSpilloverCache, TIER_DIMENSION_VALUE_ON_HEAP));
15721572
assertEquals(expectedKeys, tieredSpilloverCache.count());
15731573

@@ -1657,8 +1657,7 @@ public void testEntryPoliciesWithPut() throws Exception {
16571657

16581658
assertEquals(0, getEvictionsForTier(tieredSpilloverCache, TIER_DIMENSION_VALUE_ON_HEAP));
16591659
assertEquals(expectedKeys, getTotalStatsSnapshot(tieredSpilloverCache).getItems());
1660-
assertEquals(keyValuePairs.size() - expectedKeys, removalListener.evictionsMetric.count()); // Policy rejects should send a removal
1661-
// notification
1660+
assertEquals(0, removalListener.evictionsMetric.count());
16621661
}
16631662

16641663
public void testEntryPoliciesConcurrentlyWithComputeIfAbsent() throws Exception {
@@ -1745,8 +1744,7 @@ public void testEntryPoliciesConcurrentlyWithComputeIfAbsent() throws Exception
17451744

17461745
assertEquals(0, getEvictionsForTier(tieredSpilloverCache, TIER_DIMENSION_VALUE_ON_HEAP));
17471746
assertEquals(expectedKeys, getTotalStatsSnapshot(tieredSpilloverCache).getItems());
1748-
// Policy rejects should send a removal notification every time the caller attempts to put them in
1749-
assertEquals((keyValuePairs.size() - expectedKeys) * numRepetitionsPerKey, removalListener.evictionsMetric.count());
1747+
assertEquals(0, removalListener.evictionsMetric.count());
17501748
}
17511749

17521750
public void testPutWithDiskCacheDisabledSetting() throws Exception {

0 commit comments

Comments
 (0)