Skip to content

Commit

Permalink
Removing unwanted EventType class and refactoring one UT
Browse files Browse the repository at this point in the history
Signed-off-by: Sagar Upadhyaya <sagar.upadhyaya.121@gmail.com>
  • Loading branch information
sgup432 committed Jan 3, 2024
1 parent 7e72d07 commit fdda280
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 35 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -552,34 +553,27 @@ public boolean isLoaded() {
}

@Override
public String load(String key) throws Exception {
public String load(String key) {
return UUID.randomUUID().toString();
}
});
CountDownLatch countDownLatch = new CountDownLatch(1);
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<String, String> loadAwareCacheLoader = getLoadAwareCacheLoader();
Thread thread = new Thread(() -> {
try {
tieredSpilloverCache.computeIfAbsent(secondKey, new LoadAwareCacheLoader<String, String>() {
@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<String, String> onDiskCache = tieredSpilloverCache.getOnDiskCache().get();

// Now on a different thread, try to get key(above one which got evicted) from tiered cache. We expect this
Expand Down

0 comments on commit fdda280

Please sign in to comment.