From 56f4e1f8d60c9819a1fb8dc0699a35a915e3d7b7 Mon Sep 17 00:00:00 2001 From: Kiran Prakash Date: Mon, 8 Apr 2024 11:41:29 -0700 Subject: [PATCH] Update IndicesRequestCacheTests.java Signed-off-by: Kiran Prakash --- .../indices/IndicesRequestCacheTests.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/server/src/test/java/org/opensearch/indices/IndicesRequestCacheTests.java b/server/src/test/java/org/opensearch/indices/IndicesRequestCacheTests.java index 8c817d37ff470..161e5a8e60912 100644 --- a/server/src/test/java/org/opensearch/indices/IndicesRequestCacheTests.java +++ b/server/src/test/java/org/opensearch/indices/IndicesRequestCacheTests.java @@ -112,7 +112,7 @@ public void cleanup() throws IOException { public void testBasicOperationsCache() throws Exception { threadPool = getThreadPool(); - cache = getIndicesRequestCache(Settings.EMPTY, threadPool); + cache = getIndicesRequestCache(Settings.EMPTY); writer.addDocument(newDoc(0, "foo")); DirectoryReader reader = getReader(writer, indexShard.shardId()); @@ -164,7 +164,7 @@ public void testBasicOperationsCache() throws Exception { public void testBasicOperationsCacheWithFeatureFlag() throws Exception { threadPool = getThreadPool(); Settings settings = Settings.builder().put(super.featureFlagSettings()).put(FeatureFlags.PLUGGABLE_CACHE, "true").build(); - cache = getIndicesRequestCache(settings, threadPool); + cache = getIndicesRequestCache(settings); writer.addDocument(newDoc(0, "foo")); DirectoryReader reader = getReader(writer, indexShard.shardId()); @@ -215,7 +215,7 @@ public void testBasicOperationsCacheWithFeatureFlag() throws Exception { public void testCacheDifferentReaders() throws Exception { threadPool = getThreadPool(); - cache = getIndicesRequestCache(Settings.EMPTY, threadPool); + cache = getIndicesRequestCache(Settings.EMPTY); writer.addDocument(newDoc(0, "foo")); DirectoryReader reader = getReader(writer, indexShard.shardId()); @@ -333,7 +333,7 @@ public void testCacheCleanupThresholdSettingValidator_Invalid_Percentage() { public void testCacheCleanupBasedOnZeroThreshold() throws Exception { threadPool = getThreadPool(); Settings settings = Settings.builder().put(INDICES_REQUEST_CACHE_STALENESS_THRESHOLD_SETTING.getKey(), "0%").build(); - cache = getIndicesRequestCache(settings, threadPool); + cache = getIndicesRequestCache(settings); writer.addDocument(newDoc(0, "foo")); DirectoryReader reader = getReader(writer, indexShard.shardId()); DirectoryReader secondReader = getReader(writer, indexShard.shardId()); @@ -361,7 +361,7 @@ public void testCacheCleanupBasedOnZeroThreshold() throws Exception { public void testCacheCleanupBasedOnStaleThreshold_StalenessHigherThanThreshold() throws Exception { threadPool = getThreadPool(); Settings settings = Settings.builder().put(INDICES_REQUEST_CACHE_STALENESS_THRESHOLD_SETTING.getKey(), "0.49").build(); - cache = getIndicesRequestCache(settings, threadPool); + cache = getIndicesRequestCache(settings); writer.addDocument(newDoc(0, "foo")); DirectoryReader reader = getReader(writer, indexShard.shardId()); @@ -396,7 +396,7 @@ public void testCacheCleanupBasedOnStaleThreshold_StalenessHigherThanThreshold() public void testCacheCleanupBasedOnStaleThreshold_StalenessEqualToThreshold() throws Exception { threadPool = getThreadPool(); Settings settings = Settings.builder().put(INDICES_REQUEST_CACHE_STALENESS_THRESHOLD_SETTING.getKey(), "0.5").build(); - cache = getIndicesRequestCache(settings, threadPool); + cache = getIndicesRequestCache(settings); writer.addDocument(newDoc(0, "foo")); DirectoryReader reader = getReader(writer, indexShard.shardId()); DirectoryReader secondReader = getReader(writer, indexShard.shardId()); @@ -428,7 +428,7 @@ public void testCacheCleanupBasedOnStaleThreshold_StalenessEqualToThreshold() th public void testStaleCount_OnRemovalNotificationOfStaleKey_DecrementsStaleCount() throws Exception { threadPool = getThreadPool(); Settings settings = Settings.builder().put(INDICES_REQUEST_CACHE_STALENESS_THRESHOLD_SETTING.getKey(), "0.51").build(); - cache = getIndicesRequestCache(settings, threadPool); + cache = getIndicesRequestCache(settings); writer.addDocument(newDoc(0, "foo")); DirectoryReader reader = getReader(writer, indexShard.shardId()); DirectoryReader secondReader = getReader(writer, indexShard.shardId()); @@ -462,7 +462,7 @@ public void testStaleCount_OnRemovalNotificationOfStaleKey_DecrementsStaleCount( public void testStaleCount_OnRemovalNotificationOfStaleKey_DoesNotDecrementsStaleCount() throws Exception { threadPool = getThreadPool(); Settings settings = Settings.builder().put(INDICES_REQUEST_CACHE_STALENESS_THRESHOLD_SETTING.getKey(), "0.51").build(); - cache = getIndicesRequestCache(settings, threadPool); + cache = getIndicesRequestCache(settings); writer.addDocument(newDoc(0, "foo")); DirectoryReader reader = getReader(writer, indexShard.shardId()); DirectoryReader secondReader = getReader(writer, indexShard.shardId()); @@ -497,7 +497,7 @@ public void testStaleCount_OnRemovalNotificationOfStaleKey_DoesNotDecrementsStal public void testStaleCount_WithoutReaderClosing_DecrementsStaleCount() throws Exception { threadPool = getThreadPool(); Settings settings = Settings.builder().put(INDICES_REQUEST_CACHE_STALENESS_THRESHOLD_SETTING.getKey(), "0.51").build(); - cache = getIndicesRequestCache(settings, threadPool); + cache = getIndicesRequestCache(settings); writer.addDocument(newDoc(0, "foo")); DirectoryReader reader = getReader(writer, indexShard.shardId()); @@ -525,7 +525,7 @@ public void testStaleCount_WithoutReaderClosing_DecrementsStaleCount() throws Ex public void testStaleCount_OnRemovalNotifications() throws Exception { threadPool = getThreadPool(); Settings settings = Settings.builder().put(INDICES_REQUEST_CACHE_STALENESS_THRESHOLD_SETTING.getKey(), "0.51").build(); - cache = getIndicesRequestCache(settings, threadPool); + cache = getIndicesRequestCache(settings); writer.addDocument(newDoc(0, "foo")); DirectoryReader reader = getReader(writer, indexShard.shardId()); @@ -574,7 +574,7 @@ public void testStaleCount_OnRemovalNotifications() throws Exception { public void testCacheCleanupBasedOnStaleThreshold_StalenessLesserThanThreshold() throws Exception { threadPool = getThreadPool(); Settings settings = Settings.builder().put(INDICES_REQUEST_CACHE_STALENESS_THRESHOLD_SETTING.getKey(), "51%").build(); - cache = getIndicesRequestCache(settings, threadPool); + cache = getIndicesRequestCache(settings); writer.addDocument(newDoc(0, "foo")); DirectoryReader reader = getReader(writer, indexShard.shardId()); @@ -607,7 +607,7 @@ public void testCacheCleanupBasedOnStaleThreshold_StalenessLesserThanThreshold() public void testCleanupKeyToCountMapAreSetAppropriately() throws Exception { threadPool = getThreadPool(); Settings settings = Settings.builder().put(INDICES_REQUEST_CACHE_STALENESS_THRESHOLD_SETTING.getKey(), "0.51").build(); - cache = getIndicesRequestCache(settings, threadPool); + cache = getIndicesRequestCache(settings); writer.addDocument(newDoc(0, "foo")); ShardId shardId = indexShard.shardId(); @@ -656,7 +656,7 @@ private DirectoryReader getReader(IndexWriter writer, ShardId shardId) throws IO return OpenSearchDirectoryReader.wrap(DirectoryReader.open(writer), shardId); } - private IndicesRequestCache getIndicesRequestCache(Settings settings, ThreadPool threadPool) { + private IndicesRequestCache getIndicesRequestCache(Settings settings){ IndicesService indicesService = getInstanceFromNode(IndicesService.class); return new IndicesRequestCache(settings, (shardId -> { IndexService indexService = null; @@ -692,7 +692,7 @@ public void testEviction() throws Exception { final ByteSizeValue size; { threadPool = getThreadPool(); - cache = getIndicesRequestCache(Settings.EMPTY, threadPool); + cache = getIndicesRequestCache(Settings.EMPTY); writer.addDocument(newDoc(0, "foo")); DirectoryReader reader = getReader(writer, indexShard.shardId()); writer.updateDocument(new Term("id", "0"), newDoc(0, "bar")); @@ -735,7 +735,7 @@ public void testEviction() throws Exception { public void testClearAllEntityIdentity() throws Exception { threadPool = getThreadPool(); - cache = getIndicesRequestCache(Settings.EMPTY, threadPool); + cache = getIndicesRequestCache(Settings.EMPTY); writer.addDocument(newDoc(0, "foo")); DirectoryReader reader = getReader(writer, indexShard.shardId()); IndicesService.IndexShardCacheEntity entity = new IndicesService.IndexShardCacheEntity(indexShard); @@ -814,7 +814,7 @@ public BytesReference get() { public void testInvalidate() throws Exception { threadPool = getThreadPool(); - IndicesRequestCache cache = getIndicesRequestCache(Settings.EMPTY, threadPool); + IndicesRequestCache cache = getIndicesRequestCache(Settings.EMPTY); writer.addDocument(newDoc(0, "foo")); DirectoryReader reader = getReader(writer, indexShard.shardId());