|
@@ -14,6 +14,8 @@ import org.elasticsearch.cluster.metadata.Metadata;
|
|
|
import org.elasticsearch.cluster.node.DiscoveryNodes;
|
|
|
import org.elasticsearch.common.Strings;
|
|
|
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
|
|
|
+import org.elasticsearch.common.logging.DeprecationCategory;
|
|
|
+import org.elasticsearch.common.logging.DeprecationLogger;
|
|
|
import org.elasticsearch.common.settings.ClusterSettings;
|
|
|
import org.elasticsearch.common.settings.IndexScopedSettings;
|
|
|
import org.elasticsearch.common.settings.Setting;
|
|
@@ -74,6 +76,8 @@ import static org.elasticsearch.xpack.core.enrich.EnrichPolicy.ENRICH_INDEX_PATT
|
|
|
|
|
|
public class EnrichPlugin extends Plugin implements SystemIndexPlugin, IngestPlugin {
|
|
|
|
|
|
+ private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(EnrichPlugin.class);
|
|
|
+
|
|
|
static final Setting<Integer> ENRICH_FETCH_SIZE_SETTING = Setting.intSetting(
|
|
|
"enrich.fetch_size",
|
|
|
10000,
|
|
@@ -126,9 +130,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,
|
|
@@ -138,16 +142,58 @@ public class EnrichPlugin extends Plugin implements SystemIndexPlugin, IngestPlu
|
|
|
Setting.Property.NodeScope
|
|
|
);
|
|
|
|
|
|
+ /**
|
|
|
+ * This setting solely exists because the original setting was accidentally renamed in
|
|
|
+ * https://github.com/elastic/elasticsearch/pull/111412.
|
|
|
+ */
|
|
|
+ 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;
|
|
|
+ private final long maxCacheSize;
|
|
|
|
|
|
public EnrichPlugin(final Settings settings) {
|
|
|
this.settings = settings;
|
|
|
- FlatNumberOrByteSizeValue maxSize = CACHE_SIZE.get(settings);
|
|
|
+ FlatNumberOrByteSizeValue maxSize;
|
|
|
+ if (settings.hasValue(CACHE_SIZE_SETTING_BWC_NAME)) {
|
|
|
+ if (settings.hasValue(CACHE_SIZE_SETTING_NAME)) {
|
|
|
+ throw new IllegalArgumentException(
|
|
|
+ Strings.format(
|
|
|
+ "Both [{}] and [{}] are set, please use [{}]",
|
|
|
+ CACHE_SIZE_SETTING_NAME,
|
|
|
+ CACHE_SIZE_SETTING_BWC_NAME,
|
|
|
+ CACHE_SIZE_SETTING_NAME
|
|
|
+ )
|
|
|
+ );
|
|
|
+ }
|
|
|
+ deprecationLogger.warn(
|
|
|
+ DeprecationCategory.SETTINGS,
|
|
|
+ "enrich_cache_size_name",
|
|
|
+ "The [{}] setting is deprecated and will be removed in a future version. Please use [{}] instead.",
|
|
|
+ CACHE_SIZE_SETTING_BWC_NAME,
|
|
|
+ CACHE_SIZE_SETTING_NAME
|
|
|
+ );
|
|
|
+ maxSize = CACHE_SIZE_BWC.get(settings);
|
|
|
+ } else {
|
|
|
+ maxSize = CACHE_SIZE.get(settings);
|
|
|
+ }
|
|
|
if (maxSize.byteSizeValue() != null) {
|
|
|
this.enrichCache = new EnrichCache(maxSize.byteSizeValue());
|
|
|
+ this.maxCacheSize = maxSize.byteSizeValue().getBytes();
|
|
|
} else {
|
|
|
this.enrichCache = new EnrichCache(maxSize.flatNumber());
|
|
|
+ this.maxCacheSize = maxSize.flatNumber();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -286,6 +332,11 @@ public class EnrichPlugin extends Plugin implements SystemIndexPlugin, IngestPlu
|
|
|
return "Manages data related to Enrich policies";
|
|
|
}
|
|
|
|
|
|
+ // Visible for testing
|
|
|
+ long getMaxCacheSize() {
|
|
|
+ return maxCacheSize;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* A class that specifies either a flat (unit-less) number or a byte size value.
|
|
|
*/
|