Skip to content

Commit

Permalink
Fix enrich cache size setting name
Browse files Browse the repository at this point in the history
The enrich cache size setting accidentally got renamed from
`enrich.cache_size` to `enrich.cache.size` in elastic#111412. This commit
ensures we accept both versions, to avoid breaking BWC twice.
  • Loading branch information
nielsbauman committed Nov 26, 2024
1 parent 993add6 commit 97a937d
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ public class EnrichPlugin extends Plugin implements SystemIndexPlugin, IngestPlu
return String.valueOf(maxConcurrentRequests * maxLookupsPerRequest);
}, val -> Setting.parseInt(val, 1, Integer.MAX_VALUE, QUEUE_CAPACITY_SETTING_NAME), Setting.Property.NodeScope);

public static final String CACHE_SIZE_SETTING_NAME = "enrich.cache.size";
public static final String CACHE_SIZE_SETTING_NAME = "enrich.cache_size";
public static final Setting<FlatNumberOrByteSizeValue> CACHE_SIZE = new Setting<>(
"enrich.cache.size",
CACHE_SIZE_SETTING_NAME,
(String) null,
(String s) -> FlatNumberOrByteSizeValue.parse(
s,
Expand All @@ -138,12 +138,28 @@ public class EnrichPlugin extends Plugin implements SystemIndexPlugin, IngestPlu
Setting.Property.NodeScope
);

public static final String CACHE_SIZE_SETTING_BWC_NAME = "enrich.cache.size";
public static final Setting<FlatNumberOrByteSizeValue> CACHE_SIZE_BWC = new Setting<>(
CACHE_SIZE_SETTING_BWC_NAME,
(String) null,
(String s) -> FlatNumberOrByteSizeValue.parse(
s,
CACHE_SIZE_SETTING_BWC_NAME,
new FlatNumberOrByteSizeValue(ByteSizeValue.ofBytes((long) (0.01 * JvmInfo.jvmInfo().getConfiguredMaxHeapSize())))
),
Setting.Property.NodeScope,
Setting.Property.Deprecated
);

private final Settings settings;
private final EnrichCache enrichCache;

public EnrichPlugin(final Settings settings) {
this.settings = settings;
FlatNumberOrByteSizeValue maxSize = CACHE_SIZE.get(settings);
if (maxSize == null) {
maxSize = CACHE_SIZE_BWC.get(settings);
}
if (maxSize.byteSizeValue() != null) {
this.enrichCache = new EnrichCache(maxSize.byteSizeValue());
} else {
Expand Down

0 comments on commit 97a937d

Please sign in to comment.