diff --git a/server/src/main/java/org/opensearch/common/cache/store/listeners/EventType.java b/server/src/main/java/org/opensearch/common/cache/store/listeners/EventType.java deleted file mode 100644 index f81b94ec29858..0000000000000 --- a/server/src/main/java/org/opensearch/common/cache/store/listeners/EventType.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -package org.opensearch.common.cache.store.listeners; - -/** - * Describes various event types which is used to notify the called via listener. - * - * @opensearch.internal - */ -public enum EventType { - - ON_MISS, - ON_HIT, - ON_CACHED, - ON_REMOVAL; -} diff --git a/server/src/test/java/org/opensearch/common/cache/tier/TieredSpilloverCacheTests.java b/server/src/test/java/org/opensearch/common/cache/tier/TieredSpilloverCacheTests.java index d412da2cd497c..e7a056b43e460 100644 --- a/server/src/test/java/org/opensearch/common/cache/tier/TieredSpilloverCacheTests.java +++ b/server/src/test/java/org/opensearch/common/cache/tier/TieredSpilloverCacheTests.java @@ -28,6 +28,7 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Phaser; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; public class TieredSpilloverCacheTests extends OpenSearchTestCase { @@ -552,7 +553,7 @@ public boolean isLoaded() { } @Override - public String load(String key) throws Exception { + public String load(String key) { return UUID.randomUUID().toString(); } }); @@ -560,26 +561,19 @@ public String load(String key) throws Exception { CountDownLatch countDownLatch1 = new CountDownLatch(1); // Put second key on tiered cache. Will cause eviction of first key from onHeap cache and should go into // disk cache. + LoadAwareCacheLoader loadAwareCacheLoader = getLoadAwareCacheLoader(); Thread thread = new Thread(() -> { try { - tieredSpilloverCache.computeIfAbsent(secondKey, new LoadAwareCacheLoader() { - @Override - public boolean isLoaded() { - return false; - } - - @Override - public String load(String key) throws Exception { - return UUID.randomUUID().toString(); - } - }); + tieredSpilloverCache.computeIfAbsent(secondKey, loadAwareCacheLoader); countDownLatch1.countDown(); } catch (Exception e) { throw new RuntimeException(e); } }); thread.start(); - Thread.sleep(100); // Delay for cache for eviction to occur. + assertBusy(() -> { assertTrue(loadAwareCacheLoader.isLoaded()); }, 100, TimeUnit.MILLISECONDS); // We wait for new key to be loaded + // after which it eviction flow is + // guaranteed to occur. StoreAwareCache onDiskCache = tieredSpilloverCache.getOnDiskCache().get(); // Now on a different thread, try to get key(above one which got evicted) from tiered cache. We expect this