Skip to content

Commit

Permalink
Deprecate original IRC size setting
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Alfonsi <[email protected]>
  • Loading branch information
Peter Alfonsi committed Nov 14, 2024
1 parent 3d1fe73 commit 469006a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import java.util.function.ToLongBiFunction;

import org.ehcache.PersistentCacheManager;
import org.ehcache.impl.serialization.StringSerializer;

import static org.opensearch.cache.EhcacheDiskCacheSettings.DISK_LISTENER_MODE_SYNC_KEY;
import static org.opensearch.cache.EhcacheDiskCacheSettings.DISK_MAX_SIZE_IN_BYTES_KEY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,14 @@ public final class IndicesRequestCache implements RemovalListener<ICacheKey<Indi
/**
* If pluggable caching is off, or pluggable caching is on but a store name isn't specified, this setting determines the cache size.
* Otherwise, the implementation-specific size setting like indices.requests.cache.opensearch_onheap.size is used instead.
*
* Deprecated; once pluggable caching is no longer behind a feature flag (likely in 2.19), this setting will no longer have any effect.
*/
public static final Setting<ByteSizeValue> INDICES_CACHE_QUERY_SIZE = Setting.memorySizeSetting(
"indices.requests.cache.size",
"1%",
Property.NodeScope
Property.NodeScope,
Property.Deprecated
);
public static final Setting<TimeValue> INDICES_CACHE_QUERY_EXPIRE = Setting.positiveTimeSetting(
"indices.requests.cache.expire",
Expand Down Expand Up @@ -229,8 +232,7 @@ CacheConfig<Key, BytesReference> getCacheConfig(Settings settings, NodeEnvironme
if (!CacheService.pluggableCachingEnabled(CacheType.INDICES_REQUEST_CACHE, settings)) {
// If pluggable caching is not enabled, use the max size based on the IRC setting into the config.
// If pluggable caching is enabled, cache implementations instead determine their own sizes based on their own implementation
// size
// settings.
// size settings.
configBuilder.setMaxSizeInBytes(sizeInBytes);
}
return configBuilder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,7 @@ public void testCacheMaxSize_WhenPluggableCachingOff() throws Exception {
config = cache.getCacheConfig(settings, env);
}
assertEquals(cacheSize, (long) config.getMaxSizeInBytes());
allowDeprecationWarning();
}

public void testCacheMaxSize_WhenPluggableCachingOn() throws Exception {
Expand All @@ -888,6 +889,7 @@ public void testCacheMaxSize_WhenPluggableCachingOn() throws Exception {
config = cache.getCacheConfig(settings, env);
}
assertEquals(0, (long) config.getMaxSizeInBytes());
allowDeprecationWarning();
}

private IndicesRequestCache getIndicesRequestCache(Settings settings) throws IOException {
Expand Down Expand Up @@ -1133,6 +1135,7 @@ public void testEviction() throws Exception {
assertEquals(2, cache.count());
assertEquals(1, indexShard.requestCache().stats().getEvictions());
IOUtils.close(reader, secondReader, thirdReader, environment);
allowDeprecationWarning();
}

public void testClearAllEntityIdentity() throws Exception {
Expand Down Expand Up @@ -1410,6 +1413,7 @@ public void testGetOrComputeConcurrentlyWithMultipleIndices() throws Exception {
}
IOUtils.close(cache);
executorService.shutdownNow();
allowDeprecationWarning();
}

public void testDeleteAndCreateIndexShardOnSameNodeAndVerifyStats() throws Exception {
Expand Down Expand Up @@ -1578,6 +1582,12 @@ public static String generateString(int length) {
return sb.toString();
}

private void allowDeprecationWarning() {
assertWarnings(
"[indices.requests.cache.size] setting was deprecated in OpenSearch and will be removed in a future release! See the breaking changes documentation for the next major version."
);
}

private class TestBytesReference extends AbstractBytesReference {

int dummyValue;
Expand Down

0 comments on commit 469006a

Please sign in to comment.