From e9a734ad7c997cad60bc2923eea3438b20742498 Mon Sep 17 00:00:00 2001 From: Rory Hunter Date: Mon, 25 Jan 2021 10:43:37 +0000 Subject: [PATCH 1/5] Align JSON logs better with ECS (#67266) The JSON logs that Elasticsearch produces are roughly in an ECS shape. This PR improves that alignment. --- .../common/logging/ClusterIdConverter.java | 59 ++++++++++++++++ .../common/logging/DeprecatedMessage.java | 4 +- .../NodeAndClusterIdStateListener.java | 8 +++ .../common/logging/NodeIdConverter.java | 58 ++++++++++++++++ .../xpack/deprecation/DeprecationHttpIT.java | 52 +++++++------- .../logging/DeprecationIndexingComponent.java | 16 ++--- .../deprecation/logging/EcsJsonLayout.java | 67 ++++++++++--------- 7 files changed, 197 insertions(+), 67 deletions(-) create mode 100644 server/src/main/java/org/elasticsearch/common/logging/ClusterIdConverter.java create mode 100644 server/src/main/java/org/elasticsearch/common/logging/NodeIdConverter.java diff --git a/server/src/main/java/org/elasticsearch/common/logging/ClusterIdConverter.java b/server/src/main/java/org/elasticsearch/common/logging/ClusterIdConverter.java new file mode 100644 index 0000000000000..90f24c8c7917f --- /dev/null +++ b/server/src/main/java/org/elasticsearch/common/logging/ClusterIdConverter.java @@ -0,0 +1,59 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.common.logging; + +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.config.plugins.Plugin; +import org.apache.logging.log4j.core.pattern.ConverterKeys; +import org.apache.logging.log4j.core.pattern.LogEventPatternConverter; +import org.apache.logging.log4j.core.pattern.PatternConverter; + +/** + * Pattern converter to format the cluster_id variable into JSON fields cluster.id. + */ +@Plugin(category = PatternConverter.CATEGORY, name = "ClusterIdConverter") +@ConverterKeys({"cluster_id"}) +public final class ClusterIdConverter extends LogEventPatternConverter { + /** + * Called by log4j2 to initialize this converter. + */ + public static ClusterIdConverter newInstance(@SuppressWarnings("unused") final String[] options) { + return new ClusterIdConverter(); + } + + public ClusterIdConverter() { + super("cluster_id", "cluster_id"); + } + + /** + * Formats the cluster.uuid into json fields. + * + * @param event - a log event is ignored in this method as it uses the clusterId value + * from NodeAndClusterIdStateListener to format + */ + @Override + public void format(LogEvent event, StringBuilder toAppendTo) { + if (NodeAndClusterIdStateListener.nodeAndClusterId.get() != null) { + toAppendTo.append(NodeAndClusterIdStateListener.nodeAndClusterId.get().v2()); + } + // nodeId/clusterUuid not received yet, not appending + } + +} diff --git a/server/src/main/java/org/elasticsearch/common/logging/DeprecatedMessage.java b/server/src/main/java/org/elasticsearch/common/logging/DeprecatedMessage.java index dac3dae533b28..f34e53eaddd7f 100644 --- a/server/src/main/java/org/elasticsearch/common/logging/DeprecatedMessage.java +++ b/server/src/main/java/org/elasticsearch/common/logging/DeprecatedMessage.java @@ -19,11 +19,11 @@ package org.elasticsearch.common.logging; -import java.util.Map; - import org.elasticsearch.common.Strings; import org.elasticsearch.common.collect.MapBuilder; +import java.util.Map; + /** * A logger message used by {@link DeprecationLogger}. * Carries x-opaque-id field if provided in the headers. Will populate the x-opaque-id field in JSON logs. diff --git a/server/src/main/java/org/elasticsearch/common/logging/NodeAndClusterIdStateListener.java b/server/src/main/java/org/elasticsearch/common/logging/NodeAndClusterIdStateListener.java index f26cc876d8f4c..41b8c74d64ade 100644 --- a/server/src/main/java/org/elasticsearch/common/logging/NodeAndClusterIdStateListener.java +++ b/server/src/main/java/org/elasticsearch/common/logging/NodeAndClusterIdStateListener.java @@ -21,9 +21,11 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.apache.lucene.util.SetOnce; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterStateObserver; import org.elasticsearch.cluster.service.ClusterService; +import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.concurrent.ThreadContext; @@ -34,6 +36,7 @@ */ public class NodeAndClusterIdStateListener implements ClusterStateObserver.Listener { private static final Logger logger = LogManager.getLogger(NodeAndClusterIdStateListener.class); + static final SetOnce> nodeAndClusterId = new SetOnce<>(); private NodeAndClusterIdStateListener() {} @@ -67,6 +70,11 @@ public void onNewClusterState(ClusterState state) { logger.debug("Received cluster state update. Setting nodeId=[{}] and clusterUuid=[{}]", nodeId, clusterUUID); NodeAndClusterIdConverter.setNodeIdAndClusterId(nodeId, clusterUUID); + setNodeIdAndClusterId(nodeId, clusterUUID); + } + + void setNodeIdAndClusterId(String nodeId, String clusterUUID){ + nodeAndClusterId.set(Tuple.tuple(nodeId,clusterUUID)); } @Override diff --git a/server/src/main/java/org/elasticsearch/common/logging/NodeIdConverter.java b/server/src/main/java/org/elasticsearch/common/logging/NodeIdConverter.java new file mode 100644 index 0000000000000..9ff44dadb54ae --- /dev/null +++ b/server/src/main/java/org/elasticsearch/common/logging/NodeIdConverter.java @@ -0,0 +1,58 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.common.logging; + +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.config.plugins.Plugin; +import org.apache.logging.log4j.core.pattern.ConverterKeys; +import org.apache.logging.log4j.core.pattern.LogEventPatternConverter; +import org.apache.logging.log4j.core.pattern.PatternConverter; + +/** + * Pattern converter to format the node_id variable into JSON fields node.id . + */ +@Plugin(category = PatternConverter.CATEGORY, name = "NodeIdConverter") +@ConverterKeys({"node_id"}) +public final class NodeIdConverter extends LogEventPatternConverter { + /** + * Called by log4j2 to initialize this converter. + */ + public static NodeIdConverter newInstance(@SuppressWarnings("unused") final String[] options) { + return new NodeIdConverter(); + } + + public NodeIdConverter() { + super("node_id", "node_id"); + } + + /** + * Formats the node.id into json fields. + * + * @param event - a log event is ignored in this method as it uses the clusterId value + * from NodeAndClusterIdStateListener to format + */ + @Override + public void format(LogEvent event, StringBuilder toAppendTo) { + if (NodeAndClusterIdStateListener.nodeAndClusterId.get() != null) { + toAppendTo.append(NodeAndClusterIdStateListener.nodeAndClusterId.get().v1()); + } + // nodeId/clusterUuid not received yet, not appending + } +} diff --git a/x-pack/plugin/deprecation/qa/rest/src/javaRestTest/java/org/elasticsearch/xpack/deprecation/DeprecationHttpIT.java b/x-pack/plugin/deprecation/qa/rest/src/javaRestTest/java/org/elasticsearch/xpack/deprecation/DeprecationHttpIT.java index e5da92f583c8f..00c82a00a9bf6 100644 --- a/x-pack/plugin/deprecation/qa/rest/src/javaRestTest/java/org/elasticsearch/xpack/deprecation/DeprecationHttpIT.java +++ b/x-pack/plugin/deprecation/qa/rest/src/javaRestTest/java/org/elasticsearch/xpack/deprecation/DeprecationHttpIT.java @@ -63,16 +63,16 @@ public void testDeprecatedSettingsReturnWarnings() throws IOException { .startObject("transient") .field( TestDeprecationHeaderRestAction.TEST_DEPRECATED_SETTING_TRUE1.getKey(), - !TestDeprecationHeaderRestAction.TEST_DEPRECATED_SETTING_TRUE1.getDefault(Settings.EMPTY) + TestDeprecationHeaderRestAction.TEST_DEPRECATED_SETTING_TRUE1.getDefault(Settings.EMPTY) == false ) .field( TestDeprecationHeaderRestAction.TEST_DEPRECATED_SETTING_TRUE2.getKey(), - !TestDeprecationHeaderRestAction.TEST_DEPRECATED_SETTING_TRUE2.getDefault(Settings.EMPTY) + TestDeprecationHeaderRestAction.TEST_DEPRECATED_SETTING_TRUE2.getDefault(Settings.EMPTY) == false ) // There should be no warning for this field .field( TestDeprecationHeaderRestAction.TEST_NOT_DEPRECATED_SETTING.getKey(), - !TestDeprecationHeaderRestAction.TEST_NOT_DEPRECATED_SETTING.getDefault(Settings.EMPTY) + TestDeprecationHeaderRestAction.TEST_NOT_DEPRECATED_SETTING.getDefault(Settings.EMPTY) == false ) .endObject() .endObject(); @@ -276,35 +276,37 @@ public void testDeprecationMessagesCanBeIndexed() throws Exception { hasItems( allOf( hasKey("@timestamp"), - hasKey("cluster.name"), - hasKey("cluster.uuid"), - hasKey("component"), - hasEntry("data_stream.dataset", "deprecation.elasticsearch"), + hasKey("elasticsearch.cluster.name"), + hasKey("elasticsearch.cluster.uuid"), + hasEntry("elasticsearch.http.request.x_opaque_id", "some xid"), + hasKey("elasticsearch.node.id"), + hasKey("elasticsearch.node.name"), + hasEntry("data_stream.dataset", "elasticsearch.deprecation"), hasEntry("data_stream.namespace", "default"), hasEntry("data_stream.type", "logs"), - hasEntry("ecs.version", "1.6"), - hasEntry("key", "deprecated_settings"), - hasEntry("level", "DEPRECATION"), - hasEntry("message", "[deprecated_settings] usage is deprecated. use [settings] instead"), - hasKey("node.id"), - hasKey("node.name"), - hasEntry("x-opaque-id", "some xid") + hasEntry("ecs.version", "1.7"), + hasEntry("event.code", "deprecated_settings"), + hasEntry("event.dataset", "elasticsearch.deprecation"), + hasEntry("log.level", "DEPRECATION"), + hasKey("log.logger"), + hasEntry("message", "[deprecated_settings] usage is deprecated. use [settings] instead") ), allOf( hasKey("@timestamp"), - hasKey("cluster.name"), - hasKey("cluster.uuid"), - hasKey("component"), - hasEntry("data_stream.dataset", "deprecation.elasticsearch"), + hasKey("elasticsearch.cluster.name"), + hasKey("elasticsearch.cluster.uuid"), + hasEntry("elasticsearch.http.request.x_opaque_id", "some xid"), + hasKey("elasticsearch.node.id"), + hasKey("elasticsearch.node.name"), + hasEntry("data_stream.dataset", "elasticsearch.deprecation"), hasEntry("data_stream.namespace", "default"), hasEntry("data_stream.type", "logs"), - hasEntry("ecs.version", "1.6"), - hasEntry("key", "deprecated_route"), - hasEntry("level", "DEPRECATION"), - hasEntry("message", "[/_test_cluster/deprecated_settings] exists for deprecated tests"), - hasKey("node.id"), - hasKey("node.name"), - hasEntry("x-opaque-id", "some xid") + hasEntry("ecs.version", "1.7"), + hasEntry("event.code", "deprecated_route"), + hasEntry("event.dataset", "elasticsearch.deprecation"), + hasEntry("log.level", "DEPRECATION"), + hasKey("log.logger"), + hasEntry("message", "[/_test_cluster/deprecated_settings] exists for deprecated tests") ) ) ); diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/DeprecationIndexingComponent.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/DeprecationIndexingComponent.java index ef8b796861285..5ea33cb609af9 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/DeprecationIndexingComponent.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/DeprecationIndexingComponent.java @@ -6,11 +6,6 @@ package org.elasticsearch.xpack.deprecation.logging; -import java.util.Arrays; -import java.util.Map; -import java.util.function.Consumer; -import java.util.stream.Collectors; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.core.LoggerContext; @@ -37,6 +32,11 @@ import org.elasticsearch.common.util.concurrent.EsExecutors; import org.elasticsearch.xpack.core.ClientHelper; +import java.util.Arrays; +import java.util.Map; +import java.util.function.Consumer; +import java.util.stream.Collectors; + /** * This component manages the construction and lifecycle of the {@link DeprecationIndexingAppender}. * It also starts and stops the appender @@ -62,14 +62,14 @@ public DeprecationIndexingComponent(Client client, Settings settings) { final LoggerContext context = (LoggerContext) LogManager.getContext(false); final Configuration configuration = context.getConfiguration(); - final EcsJsonLayout layout = EcsJsonLayout.newBuilder() - .setType("deprecation") + final EcsJsonLayout ecsLayout = EcsJsonLayout.newBuilder() + .setDataset("elasticsearch.deprecation") .setESMessageFields("key,x-opaque-id") .setConfiguration(configuration) .build(); this.filter = new RateLimitingFilter(); - this.appender = new DeprecationIndexingAppender("deprecation_indexing_appender", filter, layout, consumer); + this.appender = new DeprecationIndexingAppender("deprecation_indexing_appender", filter, ecsLayout, consumer); } @Override diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/EcsJsonLayout.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/EcsJsonLayout.java index c9930351ca1ea..7c91dc3e89bc3 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/EcsJsonLayout.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/EcsJsonLayout.java @@ -6,14 +6,6 @@ package org.elasticsearch.xpack.deprecation.logging; -import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; - import org.apache.logging.log4j.core.Layout; import org.apache.logging.log4j.core.LogEvent; import org.apache.logging.log4j.core.config.Node; @@ -27,13 +19,22 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.logging.ESJsonLayout; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + /** - * This is in essense a fork of {@link ESJsonLayout}, with tweaks to align the output more closely + * This is in essence a fork of {@link ESJsonLayout}, with tweaks to align the output more closely * with ECS. This will be removed in the next major release of ES. */ @Plugin(name = "EcsJsonLayout", category = Node.CATEGORY, elementType = Layout.ELEMENT_TYPE, printObject = true) public class EcsJsonLayout extends AbstractStringLayout { - private static final String ECS_VERSION = "1.6"; + private static final String ECS_VERSION = "1.7"; private final PatternLayout patternLayout; @@ -45,26 +46,33 @@ protected EcsJsonLayout(String typeName, Charset charset, String[] esmessagefiel .build(); } - protected String pattern(String type, String[] esMessageFields) { - if (Strings.isEmpty(type)) { - throw new IllegalArgumentException("layout parameter 'type_name' cannot be empty"); + protected String pattern(String dataset, String[] esMessageFields) { + if (Strings.isEmpty(dataset)) { + throw new IllegalArgumentException("layout parameter 'dataset' cannot be empty"); } Map map = new LinkedHashMap<>(); - map.put("type", inQuotes(type)); + map.put("event.dataset", inQuotes(dataset)); map.put("@timestamp", inQuotes("%d{yyyy-MM-dd'T'HH:mm:ss,SSSZZ}")); - map.put("level", inQuotes("%p")); - map.put("component", inQuotes("%c")); - map.put("cluster.name", inQuotes("${sys:es.logs.cluster_name}")); - map.put("node.name", inQuotes("%node_name")); + map.put("log.level", inQuotes("%p")); + map.put("log.logger", inQuotes("%c")); + map.put("elasticsearch.cluster.name", inQuotes("${sys:es.logs.cluster_name}")); + map.put("elasticsearch.cluster.uuid", inQuotes("%cluster_id")); + map.put("elasticsearch.node.id", inQuotes("%node_id")); + map.put("elasticsearch.node.name", inQuotes("%node_name")); map.put("message", inQuotes("%notEmpty{%enc{%marker}{JSON} }%enc{%.-10000m}{JSON}")); map.put("data_stream.type", inQuotes("logs")); - map.put("data_stream.dataset", inQuotes("deprecation.elasticsearch")); + map.put("data_stream.dataset", inQuotes("elasticsearch.deprecation")); map.put("data_stream.namespace", inQuotes("default")); map.put("ecs.version", inQuotes(ECS_VERSION)); + Map ecsKeyReplacements = new HashMap<>(); + ecsKeyReplacements.put("x-opaque-id", "elasticsearch.http.request.x_opaque_id"); + ecsKeyReplacements.put("key", "event.code"); + for (String key : esMessageFields) { - map.put(key, inQuotes("%ESMessageField{" + key + "}")); + map.put(ecsKeyReplacements.getOrDefault(key, key), inQuotes("%ESMessageField{" + key + "}")); } + return createPattern(map, Stream.of(esMessageFields).collect(Collectors.toSet())); } @@ -87,7 +95,6 @@ protected String createPattern(Map map, Set esMessageFie separator = ", "; } - sb.append(notEmpty(", %node_and_cluster_id ")); sb.append("%exceptionAsJson "); sb.append("}"); sb.append(System.lineSeparator()); @@ -100,10 +107,6 @@ private void appendField(StringBuilder sb, Map.Entry entry) { sb.append(entry.getValue().toString()); } - private String notEmpty(String value) { - return "%notEmpty{" + value + "}"; - } - private CharSequence jsonKey(String s) { return inQuotes(s) + ": "; } @@ -126,8 +129,8 @@ PatternLayout getPatternLayout() { public static class Builder> extends AbstractStringLayout.Builder implements org.apache.logging.log4j.core.util.Builder { - @PluginAttribute("type_name") - String type; + @PluginAttribute("dataset") + String dataset; @PluginAttribute(value = "charset", defaultString = "UTF-8") Charset charset; @@ -142,7 +145,7 @@ public Builder() { @Override public EcsJsonLayout build() { String[] split = Strings.isNullOrEmpty(esMessageFields) ? new String[]{} : esMessageFields.split(","); - return EcsJsonLayout.createLayout(type, charset, split); + return EcsJsonLayout.createLayout(dataset, charset, split); } public Charset getCharset() { @@ -154,12 +157,12 @@ public B setCharset(final Charset charset) { return asBuilder(); } - public String getType() { - return type; + public String getDataset() { + return dataset; } - public B setType(final String type) { - this.type = type; + public B setDataset(final String dataset) { + this.dataset = dataset; return asBuilder(); } From 7fd090d80fcea3b0891758b7b8e4c2253b144aed Mon Sep 17 00:00:00 2001 From: Rory Hunter Date: Tue, 26 Jan 2021 14:44:57 +0000 Subject: [PATCH 2/5] Address review feedback --- .../org/elasticsearch/common/logging/ClusterIdConverter.java | 2 ++ .../java/org/elasticsearch/common/logging/NodeIdConverter.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/server/src/main/java/org/elasticsearch/common/logging/ClusterIdConverter.java b/server/src/main/java/org/elasticsearch/common/logging/ClusterIdConverter.java index 90f24c8c7917f..0703d99ea7316 100644 --- a/server/src/main/java/org/elasticsearch/common/logging/ClusterIdConverter.java +++ b/server/src/main/java/org/elasticsearch/common/logging/ClusterIdConverter.java @@ -27,6 +27,8 @@ /** * Pattern converter to format the cluster_id variable into JSON fields cluster.id. + *

+ * This is used in `EcsJsonLayout`, which does not use {@link NodeAndClusterIdConverter}. */ @Plugin(category = PatternConverter.CATEGORY, name = "ClusterIdConverter") @ConverterKeys({"cluster_id"}) diff --git a/server/src/main/java/org/elasticsearch/common/logging/NodeIdConverter.java b/server/src/main/java/org/elasticsearch/common/logging/NodeIdConverter.java index 9ff44dadb54ae..644d26f9a079c 100644 --- a/server/src/main/java/org/elasticsearch/common/logging/NodeIdConverter.java +++ b/server/src/main/java/org/elasticsearch/common/logging/NodeIdConverter.java @@ -27,6 +27,8 @@ /** * Pattern converter to format the node_id variable into JSON fields node.id . + *

+ * This is used in `EcsJsonLayout`, which does not use {@link NodeAndClusterIdConverter}. */ @Plugin(category = PatternConverter.CATEGORY, name = "NodeIdConverter") @ConverterKeys({"node_id"}) From 247ae6b2b8249f597bb1851e2659301cb8509168 Mon Sep 17 00:00:00 2001 From: Rory Hunter Date: Wed, 27 Jan 2021 15:09:18 +0000 Subject: [PATCH 3/5] Introduce deprecation categories Sort-of backport of #67443. Closes #64824. Introduce the concept of categories to deprecation logging. Every location where we log a deprecation message must now include a deprecation category. --- .../common/CJKBigramFilterFactory.java | 3 +- .../analysis/common/CommonAnalysisPlugin.java | 21 ++++----- .../common/CommonGramsTokenFilterFactory.java | 3 +- .../common/EdgeNGramTokenFilterFactory.java | 5 ++- .../common/FingerprintTokenFilterFactory.java | 3 +- ...acyDelimitedPayloadTokenFilterFactory.java | 3 +- .../common/MultiplexerTokenFilterFactory.java | 9 ++-- .../common/NGramTokenFilterFactory.java | 7 +-- .../common/NGramTokenizerFactory.java | 3 +- .../StandardHtmlStripAnalyzerProvider.java | 3 +- .../common/SynonymTokenFilterFactory.java | 3 +- .../WordDelimiterGraphTokenFilterFactory.java | 5 ++- .../WordDelimiterTokenFilterFactory.java | 5 ++- .../ingest/common/ScriptProcessor.java | 3 +- .../ingest/useragent/UserAgentProcessor.java | 5 ++- .../RestMultiSearchTemplateAction.java | 3 +- .../join/query/HasChildQueryBuilder.java | 3 +- .../percolator/PercolateQueryBuilder.java | 5 ++- .../index/reindex/ReindexValidator.java | 3 +- .../reindex/remote/RemoteRequestBuilders.java | 3 +- .../IcuNormalizerTokenFilterFactory.java | 3 +- .../analysis/PhoneticTokenFilterFactory.java | 5 ++- .../azure/classic/AzureDiscoveryPlugin.java | 3 +- .../discovery/ec2/Ec2ClientSettings.java | 5 ++- .../repositories/s3/S3Repository.java | 3 +- .../common/logging/EvilLoggerTests.java | 3 +- .../common/logging/JsonLoggerTests.java | 16 +++---- .../AddVotingConfigExclusionsRequest.java | 5 ++- .../restore/RestoreSnapshotRequest.java | 3 +- .../alias/get/TransportGetAliasesAction.java | 5 ++- .../template/put/PutIndexTemplateRequest.java | 3 +- .../action/bulk/BulkRequestParser.java | 4 +- .../ingest/SimulatePipelineRequest.java | 3 +- .../action/search/MultiSearchRequest.java | 3 +- .../termvectors/TermVectorsRequest.java | 3 +- .../elasticsearch/bootstrap/Bootstrap.java | 6 ++- .../metadata/IndexNameExpressionResolver.java | 3 +- .../metadata/IndexTemplateMetadata.java | 3 +- .../metadata/MetadataCreateIndexService.java | 10 +++-- .../cluster/routing/OperationRouting.java | 5 ++- .../allocation/DiskThresholdMonitor.java | 14 ++++-- .../common/geo/SpatialStrategy.java | 4 +- .../org/elasticsearch/common/joda/Joda.java | 14 +++--- .../common/logging/DeprecatedMessage.java | 14 ++++-- .../common/logging/DeprecationCategory.java | 45 +++++++++++++++++++ .../common/logging/DeprecationLogger.java | 13 ++++-- .../common/settings/Setting.java | 19 ++++++-- .../common/time/DateFormatters.java | 7 ++- .../elasticsearch/common/time/DateUtils.java | 3 +- .../common/unit/ByteSizeValue.java | 3 +- .../common/util/concurrent/EsExecutors.java | 2 + .../xcontent/LoggingDeprecationHandler.java | 7 +-- .../java/org/elasticsearch/http/HttpInfo.java | 2 + .../analysis/PreConfiguredTokenFilter.java | 5 ++- .../analysis/ShingleTokenFilterFactory.java | 5 ++- .../index/mapper/CompletionFieldMapper.java | 3 +- .../index/mapper/DateFieldMapper.java | 4 +- .../index/mapper/DynamicTemplate.java | 3 +- .../index/mapper/FieldMapper.java | 41 +++++++++-------- .../index/mapper/FieldNamesFieldMapper.java | 5 ++- .../index/mapper/IdFieldMapper.java | 3 +- .../index/mapper/IpFieldMapper.java | 3 +- .../index/mapper/MapperService.java | 3 +- .../index/mapper/ObjectMapper.java | 25 ++++++----- .../index/mapper/RootObjectMapper.java | 3 +- .../index/mapper/TypeFieldMapper.java | 3 +- .../index/mapper/TypeFieldType.java | 7 +-- .../index/mapper/TypeParsers.java | 4 +- .../index/query/GeoShapeQueryBuilder.java | 3 +- .../index/query/IdsQueryBuilder.java | 3 +- .../index/query/MoreLikeThisQueryBuilder.java | 3 +- .../index/query/SearchExecutionContext.java | 3 +- .../index/query/TypeQueryBuilder.java | 3 +- .../RandomScoreFunctionBuilder.java | 3 +- .../index/reindex/ReindexRequest.java | 5 ++- .../index/similarity/SimilarityProviders.java | 13 +++--- .../index/similarity/SimilarityService.java | 9 ++-- .../indices/analysis/AnalysisModule.java | 5 ++- .../indices/flush/SyncedFlushService.java | 3 +- .../ingest/ConditionalProcessor.java | 3 +- .../java/org/elasticsearch/node/Node.java | 2 + .../rest/DeprecationRestHandler.java | 3 +- .../admin/indices/RestCloseIndexAction.java | 4 +- .../admin/indices/RestCreateIndexAction.java | 3 +- .../admin/indices/RestForceMergeAction.java | 3 +- .../indices/RestGetFieldMappingAction.java | 5 ++- .../indices/RestGetIndexTemplateAction.java | 3 +- .../admin/indices/RestGetIndicesAction.java | 3 +- .../admin/indices/RestGetMappingAction.java | 5 ++- .../indices/RestPutIndexTemplateAction.java | 5 ++- .../admin/indices/RestPutMappingAction.java | 3 +- .../admin/indices/RestResizeHandler.java | 3 +- .../indices/RestRolloverIndexAction.java | 3 +- .../indices/RestValidateQueryAction.java | 3 +- .../rest/action/cat/RestIndicesAction.java | 3 +- .../rest/action/cat/RestNodesAction.java | 3 +- .../rest/action/cat/RestShardsAction.java | 3 +- .../rest/action/document/RestBulkAction.java | 3 +- .../action/document/RestDeleteAction.java | 3 +- .../rest/action/document/RestGetAction.java | 3 +- .../action/document/RestGetSourceAction.java | 3 +- .../rest/action/document/RestIndexAction.java | 3 +- .../action/document/RestMultiGetAction.java | 5 ++- .../document/RestMultiTermVectorsAction.java | 3 +- .../document/RestTermVectorsAction.java | 3 +- .../action/document/RestUpdateAction.java | 3 +- .../rest/action/search/RestCountAction.java | 3 +- .../rest/action/search/RestExplainAction.java | 3 +- .../action/search/RestMultiSearchAction.java | 3 +- .../rest/action/search/RestSearchAction.java | 3 +- .../script/AbstractSortScript.java | 5 ++- .../script/AggregationScript.java | 5 ++- .../org/elasticsearch/script/FieldScript.java | 5 ++- .../script/JodaCompatibleZonedDateTime.java | 10 +++-- .../org/elasticsearch/script/ScoreScript.java | 5 ++- .../java/org/elasticsearch/script/Script.java | 5 ++- .../elasticsearch/script/ScriptMetadata.java | 7 ++- .../script/ScriptedMetricAggContexts.java | 7 +-- .../script/StoredScriptSource.java | 15 ++++--- .../script/TermsSetQueryScript.java | 5 ++- .../elasticsearch/script/UpdateScript.java | 3 +- .../search/aggregations/InternalOrder.java | 3 +- .../bucket/histogram/DateIntervalWrapper.java | 9 ++-- .../SignificantTermsAggregatorFactory.java | 3 +- .../PercentilesAggregationBuilder.java | 4 +- .../MovAvgPipelineAggregationBuilder.java | 25 ++++++----- .../search/builder/SearchSourceBuilder.java | 3 +- .../fetch/subphase/FetchDocValuesPhase.java | 3 +- .../search/lookup/LeafDocLookup.java | 3 +- .../search/slice/SliceBuilder.java | 3 +- .../search/sort/FieldSortBuilder.java | 5 ++- .../search/sort/GeoDistanceSortBuilder.java | 5 ++- .../search/sort/ScriptSortBuilder.java | 5 ++- .../completion/context/GeoContextMapping.java | 5 ++- .../transport/TransportInfo.java | 3 +- .../transport/TransportService.java | 4 +- .../indices/TransportAnalyzeActionTests.java | 7 ++- .../logging/RateLimitingFilterTests.java | 34 +++++++------- .../index/analysis/AnalysisRegistryTests.java | 9 ++-- .../rest/DeprecationRestHandlerTests.java | 3 +- .../test/loggerusage/ESLoggerUsageTests.java | 3 +- .../query/DeprecatedQueryBuilder.java | 3 +- .../elasticsearch/xpack/core/XPackPlugin.java | 3 +- .../core/ml/datafeed/DatafeedUpdate.java | 3 +- .../authz/permission/IndicesPermission.java | 19 +++++--- .../xpack/core/ssl/SSLService.java | 6 ++- .../transform/action/GetTransformAction.java | 8 +++- .../transforms/pivot/PivotConfig.java | 2 + .../MockDeprecatedAggregationBuilder.java | 3 +- .../MockDeprecatedQueryBuilder.java | 3 +- .../TestDeprecatedQueryBuilder.java | 9 +++- .../TestDeprecationHeaderRestAction.java | 3 +- .../deprecation/logging/EcsJsonLayout.java | 3 +- .../graph/rest/action/RestGraphAction.java | 3 +- .../xpack/ml/job/JobManager.java | 3 +- .../inference/RestGetTrainedModelsAction.java | 2 + .../xpack/ml/utils/DomainSplitFunction.java | 3 +- .../action/TransportPutRollupJobAction.java | 3 +- .../xpack/security/authc/ApiKeyService.java | 15 ++++--- .../xpack/security/authc/Realms.java | 7 +-- .../authc/esnative/ReservedRealm.java | 5 ++- .../ldap/ActiveDirectorySessionFactory.java | 4 +- .../authc/ldap/support/SessionFactory.java | 3 +- .../authz/store/CompositeRolesStore.java | 5 ++- .../DeprecationRoleDescriptorConsumer.java | 3 +- ...eprecationRoleDescriptorConsumerTests.java | 3 +- .../index/query/ShapeQueryBuilder.java | 4 +- .../mapper/SparseVectorFieldMapper.java | 3 +- .../xpack/vectors/query/ScoreScriptUtils.java | 8 ++-- .../watcher/actions/index/IndexAction.java | 3 +- .../rest/action/RestWatcherStatsAction.java | 4 +- .../search/WatcherSearchTemplateRequest.java | 5 ++- 172 files changed, 635 insertions(+), 337 deletions(-) create mode 100644 server/src/main/java/org/elasticsearch/common/logging/DeprecationCategory.java diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CJKBigramFilterFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CJKBigramFilterFactory.java index 8422a519bf682..722817669c430 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CJKBigramFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CJKBigramFilterFactory.java @@ -23,6 +23,7 @@ import org.apache.lucene.analysis.cjk.CJKBigramFilter; import org.apache.lucene.analysis.miscellaneous.DisableGraphAttribute; import org.elasticsearch.Version; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -102,7 +103,7 @@ public TokenFilterFactory getSynonymFilter() { "] cannot be used to parse synonyms"); } else { - DEPRECATION_LOGGER.deprecate("synonym_tokenfilters", "Token filter [" + name() + DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters", "Token filter [" + name() + "] will not be usable to parse synonyms after v7.0"); } } diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonAnalysisPlugin.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonAnalysisPlugin.java index 8f42459ca6b76..d1073bc6d50fc 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonAnalysisPlugin.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonAnalysisPlugin.java @@ -116,6 +116,7 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.settings.Settings; @@ -249,7 +250,7 @@ public Map> getTokenFilters() { filters.put("dutch_stem", DutchStemTokenFilterFactory::new); filters.put("edge_ngram", EdgeNGramTokenFilterFactory::new); filters.put("edgeNGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> { - deprecationLogger.deprecate("edgeNGram_deprecation", + deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "edgeNGram_deprecation", "The [edgeNGram] token filter name is deprecated and will be removed in a future version. " + "Please change the filter name to [edge_ngram] instead."); return new EdgeNGramTokenFilterFactory(indexSettings, environment, name, settings); @@ -274,7 +275,7 @@ public Map> getTokenFilters() { filters.put("multiplexer", MultiplexerTokenFilterFactory::new); filters.put("ngram", NGramTokenFilterFactory::new); filters.put("nGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> { - deprecationLogger.deprecate("nGram_deprecation", + deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "nGram_deprecation", "The [nGram] token filter name is deprecated and will be removed in a future version. " + "Please change the filter name to [ngram] instead."); return new NGramTokenFilterFactory(indexSettings, environment, name, settings); @@ -323,7 +324,7 @@ public Map> getTokenizers() { tokenizers.put("thai", ThaiTokenizerFactory::new); tokenizers.put("nGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> { if (indexSettings.getIndexVersionCreated().onOrAfter(org.elasticsearch.Version.V_7_6_0)) { - deprecationLogger.deprecate("nGram_tokenizer_deprecation", + deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "nGram_tokenizer_deprecation", "The [nGram] tokenizer name is deprecated and will be removed in a future version. " + "Please change the tokenizer name to [ngram] instead."); } @@ -332,7 +333,7 @@ public Map> getTokenizers() { tokenizers.put("ngram", NGramTokenizerFactory::new); tokenizers.put("edgeNGram", (IndexSettings indexSettings, Environment environment, String name, Settings settings) -> { if (indexSettings.getIndexVersionCreated().onOrAfter(org.elasticsearch.Version.V_7_6_0)) { - deprecationLogger.deprecate("edgeNGram_tokenizer_deprecation", + deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "edgeNGram_tokenizer_deprecation", "The [edgeNGram] tokenizer name is deprecated and will be removed in a future version. " + "Please change the tokenizer name to [edge_ngram] instead."); } @@ -413,7 +414,7 @@ public List getPreConfiguredCharFilters() { filters.add(PreConfiguredCharFilter.singleton("html_strip", false, HTMLStripCharFilter::new)); filters.add(PreConfiguredCharFilter.elasticsearchVersion("htmlStrip", false, (reader, version) -> { if (version.onOrAfter(org.elasticsearch.Version.V_6_3_0)) { - deprecationLogger.deprecate("htmlStrip_deprecation", + deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "htmlStrip_deprecation", "The [htmpStrip] char filter name is deprecated and will be removed in a future version. " + "Please change the filter name to [html_strip] instead."); } @@ -444,7 +445,7 @@ public List getPreConfiguredTokenFilters() { "[delimited_payload_filter] is not supported for new indices, use [delimited_payload] instead"); } if (version.onOrAfter(Version.V_6_2_0)) { - deprecationLogger.deprecate("analysis_delimited_payload_filter", + deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "analysis_delimited_payload_filter", "Deprecated [delimited_payload_filter] used, replaced by [delimited_payload]"); } return new DelimitedPayloadTokenFilter(input, @@ -464,7 +465,7 @@ public List getPreConfiguredTokenFilters() { "The [edgeNGram] token filter name was deprecated in 6.4 and cannot be used in new indices. " + "Please change the filter name to [edge_ngram] instead."); } else { - deprecationLogger.deprecate("edgeNGram_deprecation", + deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "edgeNGram_deprecation", "The [edgeNGram] token filter name is deprecated and will be removed in a future version. " + "Please change the filter name to [edge_ngram] instead."); } @@ -491,7 +492,7 @@ public List getPreConfiguredTokenFilters() { throw new IllegalArgumentException("The [nGram] token filter name was deprecated in 6.4 and cannot be used in new indices. " + "Please change the filter name to [ngram] instead."); } else { - deprecationLogger.deprecate("nGram_deprecation", + deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "nGram_deprecation", "The [nGram] token filter name is deprecated and will be removed in a future version. " + "Please change the filter name to [ngram] instead."); } @@ -569,7 +570,7 @@ public List getPreConfiguredTokenizers() { // Temporary shim for aliases. TODO deprecate after they are moved tokenizers.add(PreConfiguredTokenizer.elasticsearchVersion("nGram", (version) -> { if (version.onOrAfter(org.elasticsearch.Version.V_7_6_0)) { - deprecationLogger.deprecate("nGram_tokenizer_deprecation", + deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "nGram_tokenizer_deprecation", "The [nGram] tokenizer name is deprecated and will be removed in a future version. " + "Please change the tokenizer name to [ngram] instead."); } @@ -577,7 +578,7 @@ public List getPreConfiguredTokenizers() { })); tokenizers.add(PreConfiguredTokenizer.elasticsearchVersion("edgeNGram", (version) -> { if (version.onOrAfter(org.elasticsearch.Version.V_7_6_0)) { - deprecationLogger.deprecate("edgeNGram_tokenizer_deprecation", + deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "edgeNGram_tokenizer_deprecation", "The [edgeNGram] tokenizer name is deprecated and will be removed in a future version. " + "Please change the tokenizer name to [edge_ngram] instead."); } diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonGramsTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonGramsTokenFilterFactory.java index b83081aa237b5..71325f6bf5edd 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonGramsTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/CommonGramsTokenFilterFactory.java @@ -24,6 +24,7 @@ import org.apache.lucene.analysis.commongrams.CommonGramsFilter; import org.apache.lucene.analysis.commongrams.CommonGramsQueryFilter; import org.elasticsearch.Version; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -69,7 +70,7 @@ public TokenFilterFactory getSynonymFilter() { if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } else { - DEPRECATION_LOGGER.deprecate("synonym_tokenfilters", "Token filter [" + name() + DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters", "Token filter [" + name() + "] will not be usable to parse synonyms after v7.0"); } diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/EdgeNGramTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/EdgeNGramTokenFilterFactory.java index 1de8c486d8874..9cdf3da29324a 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/EdgeNGramTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/EdgeNGramTokenFilterFactory.java @@ -23,6 +23,7 @@ import org.apache.lucene.analysis.ngram.EdgeNGramTokenFilter; import org.apache.lucene.analysis.reverse.ReverseStringFilter; import org.elasticsearch.Version; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -91,8 +92,8 @@ public TokenFilterFactory getSynonymFilter() { throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } else { - DEPRECATION_LOGGER.deprecate("synonym_tokenfilters", "Token filter [" + name() - + "] will not be usable to parse synonyms after v7.0"); + DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters", + "Token filter [" + name() + "] will not be usable to parse synonyms after v7.0"); return this; } } diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/FingerprintTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/FingerprintTokenFilterFactory.java index cbdb0a11ce9a3..afabd29d31261 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/FingerprintTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/FingerprintTokenFilterFactory.java @@ -22,6 +22,7 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.miscellaneous.FingerprintFilter; import org.elasticsearch.Version; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -58,7 +59,7 @@ public TokenFilterFactory getSynonymFilter() { throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } else { - DEPRECATION_LOGGER.deprecate("synonym_tokenfilters", "Token filter [" + name() + DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters", "Token filter [" + name() + "] will not be usable to parse synonyms after v7.0"); return this; } diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/LegacyDelimitedPayloadTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/LegacyDelimitedPayloadTokenFilterFactory.java index a3866d31a8338..cb8ac4c9ef897 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/LegacyDelimitedPayloadTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/LegacyDelimitedPayloadTokenFilterFactory.java @@ -20,6 +20,7 @@ package org.elasticsearch.analysis.common; import org.elasticsearch.Version; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -37,7 +38,7 @@ public class LegacyDelimitedPayloadTokenFilterFactory extends DelimitedPayloadTo "[delimited_payload_filter] is not supported for new indices, use [delimited_payload] instead"); } if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_6_2_0)) { - deprecationLogger.deprecate("analysis_legacy_delimited_payload_filter", + deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "analysis_legacy_delimited_payload_filter", "Deprecated [delimited_payload_filter] used, replaced by [delimited_payload]"); } } diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/MultiplexerTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/MultiplexerTokenFilterFactory.java index cc41882cfc6a0..a56a78675e51b 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/MultiplexerTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/MultiplexerTokenFilterFactory.java @@ -26,6 +26,7 @@ import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute; import org.elasticsearch.Version; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -66,8 +67,8 @@ public TokenFilterFactory getSynonymFilter() { } else { if (preserveOriginal) { - DEPRECATION_LOGGER.deprecate("synonym_tokenfilters", "Token filter [" + name() - + "] will not be usable to parse synonyms after v7.0"); + DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters", + "Token filter [" + name() + "] will not be usable to parse synonyms after v7.0"); return IDENTITY_FILTER; } throw new IllegalArgumentException("Token filter [" + name() @@ -129,8 +130,8 @@ public TokenFilterFactory getSynonymFilter() { } else { if (preserveOriginal) { - DEPRECATION_LOGGER.deprecate("synonym_tokenfilters", "Token filter [" + name() - + "] will not be usable to parse synonyms after v7.0"); + DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters", + "Token filter [" + name() + "] will not be usable to parse synonyms after v7.0"); return IDENTITY_FILTER; } throw new IllegalArgumentException("Token filter [" + name() diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/NGramTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/NGramTokenFilterFactory.java index 5d282b0c32a10..fbed260f74767 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/NGramTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/NGramTokenFilterFactory.java @@ -22,6 +22,7 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.ngram.NGramTokenFilter; import org.elasticsearch.Version; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -52,7 +53,7 @@ public class NGramTokenFilterFactory extends AbstractTokenFilterFactory { + maxAllowedNgramDiff + "] but was [" + ngramDiff + "]. This limit can be set by changing the [" + IndexSettings.MAX_NGRAM_DIFF_SETTING.getKey() + "] index level setting."); } else { - deprecationLogger.deprecate("ngram_big_difference", + deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "ngram_big_difference", "Deprecated big difference between max_gram and min_gram in NGram Tokenizer," + "expected difference must be less than or equal to: [" + maxAllowedNgramDiff + "]"); } @@ -71,8 +72,8 @@ public TokenFilterFactory getSynonymFilter() { throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } else { - DEPRECATION_LOGGER.deprecate("synonym_tokenfilters", "Token filter [" + name() - + "] will not be usable to parse synonyms after v7.0"); + DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters", + "Token filter [" + name() + "] will not be usable to parse synonyms after v7.0"); return this; } } diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/NGramTokenizerFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/NGramTokenizerFactory.java index 86327a0cc1c49..15de0d14ed4a2 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/NGramTokenizerFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/NGramTokenizerFactory.java @@ -22,6 +22,7 @@ import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.ngram.NGramTokenizer; import org.elasticsearch.Version; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.index.IndexSettings; @@ -118,7 +119,7 @@ public boolean isTokenChar(int c) { + maxAllowedNgramDiff + "] but was [" + ngramDiff + "]. This limit can be set by changing the [" + IndexSettings.MAX_NGRAM_DIFF_SETTING.getKey() + "] index level setting."); } else { - deprecationLogger.deprecate("ngram_big_difference", + deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "ngram_big_difference", "Deprecated big difference between max_gram and min_gram in NGram Tokenizer," + "expected difference must be less than or equal to: [" + maxAllowedNgramDiff + "]"); } diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/StandardHtmlStripAnalyzerProvider.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/StandardHtmlStripAnalyzerProvider.java index be8dd658a64a3..407f359143b67 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/StandardHtmlStripAnalyzerProvider.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/StandardHtmlStripAnalyzerProvider.java @@ -21,6 +21,7 @@ import org.apache.lucene.analysis.CharArraySet; import org.elasticsearch.Version; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -49,7 +50,7 @@ public class StandardHtmlStripAnalyzerProvider extends AbstractIndexAnalyzerProv throw new IllegalArgumentException("[standard_html_strip] analyzer is not supported for new indices, " + "use a custom analyzer using [standard] tokenizer and [html_strip] char_filter, plus [lowercase] filter"); } else { - DEPRECATION_LOGGER.deprecate("standard_html_strip_deprecation", + DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "standard_html_strip_deprecation", "Deprecated analyzer [standard_html_strip] used, " + "replace it with a custom analyzer using [standard] tokenizer and [html_strip] char_filter, plus [lowercase] filter"); } diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/SynonymTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/SynonymTokenFilterFactory.java index 62189a1d7f34a..57c842385119e 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/SynonymTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/SynonymTokenFilterFactory.java @@ -23,6 +23,7 @@ import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.synonym.SynonymFilter; import org.apache.lucene.analysis.synonym.SynonymMap; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -57,7 +58,7 @@ public class SynonymTokenFilterFactory extends AbstractTokenFilterFactory { this.settings = settings; if (settings.get("ignore_case") != null) { - DEPRECATION_LOGGER.deprecate("synonym_ignore_case_option", + DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_ignore_case_option", "The ignore_case option on the synonym_graph filter is deprecated. " + "Instead, insert a lowercase filter in the filter chain before the synonym_graph filter."); } diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/WordDelimiterGraphTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/WordDelimiterGraphTokenFilterFactory.java index e381ad05dad02..683199a7cd8c0 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/WordDelimiterGraphTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/WordDelimiterGraphTokenFilterFactory.java @@ -24,6 +24,7 @@ import org.apache.lucene.analysis.miscellaneous.WordDelimiterGraphFilter; import org.apache.lucene.analysis.miscellaneous.WordDelimiterIterator; import org.elasticsearch.Version; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -112,8 +113,8 @@ public TokenFilterFactory getSynonymFilter() { throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } else { - DEPRECATION_LOGGER.deprecate("synonym_tokenfilters", "Token filter [" + name() - + "] will not be usable to parse synonyms after v7.0"); + DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters", + "Token filter [" + name() + "] will not be usable to parse synonyms after v7.0"); return this; } } diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/WordDelimiterTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/WordDelimiterTokenFilterFactory.java index 97ccef9225586..2b6f1997ebe2c 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/WordDelimiterTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/WordDelimiterTokenFilterFactory.java @@ -24,6 +24,7 @@ import org.apache.lucene.analysis.miscellaneous.WordDelimiterFilter; import org.apache.lucene.analysis.miscellaneous.WordDelimiterIterator; import org.elasticsearch.Version; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -115,8 +116,8 @@ public TokenFilterFactory getSynonymFilter() { throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } else { - DEPRECATION_LOGGER.deprecate("synonym_tokenfilters", "Token filter [" + name() - + "] will not be usable to parse synonyms after v7.0"); + DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters", + "Token filter [" + name() + "] will not be usable to parse synonyms after v7.0"); return this; } } diff --git a/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/ScriptProcessor.java b/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/ScriptProcessor.java index a7ad13f2c5115..7994a2a16d4a2 100644 --- a/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/ScriptProcessor.java +++ b/modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/ScriptProcessor.java @@ -21,6 +21,7 @@ import org.elasticsearch.common.Nullable; import org.elasticsearch.common.bytes.BytesReference; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.util.CollectionUtils; import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; @@ -55,7 +56,7 @@ public final class ScriptProcessor extends AbstractProcessor { DeprecationLogger.getLogger(DynamicMap.class); private static final Map> PARAMS_FUNCTIONS = org.elasticsearch.common.collect.Map.of( "_type", value -> { - deprecationLogger.deprecate("script_processor", + deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "script_processor", "[types removal] Looking up doc types [_type] in scripts is deprecated."); return value; }); diff --git a/modules/ingest-user-agent/src/main/java/org/elasticsearch/ingest/useragent/UserAgentProcessor.java b/modules/ingest-user-agent/src/main/java/org/elasticsearch/ingest/useragent/UserAgentProcessor.java index d9304af29fac3..6266f84b3652f 100644 --- a/modules/ingest-user-agent/src/main/java/org/elasticsearch/ingest/useragent/UserAgentProcessor.java +++ b/modules/ingest-user-agent/src/main/java/org/elasticsearch/ingest/useragent/UserAgentProcessor.java @@ -19,6 +19,7 @@ package org.elasticsearch.ingest.useragent; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.ingest.AbstractProcessor; import org.elasticsearch.ingest.IngestDocument; @@ -314,7 +315,7 @@ public UserAgentProcessor create(Map factories, Strin } if (useECS == false) { - deprecationLogger.deprecate("ecs_false_non_common_schema", + deprecationLogger.deprecate(DeprecationCategory.SETTINGS, "ecs_false_non_common_schema", "setting [ecs] to false for non-common schema " + "format is deprecated and will be removed in 8.0, set to true or remove to use the non-deprecated format"); } @@ -357,7 +358,7 @@ public static Property parseProperty(String propertyName) { Property value = valueOf(propertyName.toUpperCase(Locale.ROOT)); if (DEPRECATED_PROPERTIES.contains(value)) { final String key = "user_agent_processor_property_" + propertyName.replaceAll("[^\\w_]+", "_"); - deprecationLogger.deprecate(key, + deprecationLogger.deprecate(DeprecationCategory.PARSING, key, "the [{}] property is deprecated for the user-agent processor", propertyName); } return value; diff --git a/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestMultiSearchTemplateAction.java b/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestMultiSearchTemplateAction.java index 783342760f5b1..a4db590608951 100644 --- a/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestMultiSearchTemplateAction.java +++ b/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/RestMultiSearchTemplateAction.java @@ -20,6 +20,7 @@ package org.elasticsearch.script.mustache; import org.elasticsearch.client.node.NodeClient; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.BaseRestHandler; @@ -84,7 +85,7 @@ public RestChannelConsumer prepareRequest(RestRequest request, NodeClient client // Emit a single deprecation message if any search template contains types. for (SearchTemplateRequest searchTemplateRequest : multiRequest.requests()) { if (searchTemplateRequest.getRequest().types().length > 0) { - deprecationLogger.deprecate("msearch_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "msearch_with_types", TYPES_DEPRECATION_MESSAGE); break; } } diff --git a/modules/parent-join/src/main/java/org/elasticsearch/join/query/HasChildQueryBuilder.java b/modules/parent-join/src/main/java/org/elasticsearch/join/query/HasChildQueryBuilder.java index cbb74b3b5853c..45631695fc573 100644 --- a/modules/parent-join/src/main/java/org/elasticsearch/join/query/HasChildQueryBuilder.java +++ b/modules/parent-join/src/main/java/org/elasticsearch/join/query/HasChildQueryBuilder.java @@ -32,6 +32,7 @@ import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.lucene.search.Queries; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -141,7 +142,7 @@ public HasChildQueryBuilder minMaxChildren(int minChildren, int maxChildren) { throw new IllegalArgumentException("[" + NAME + "] requires non-negative 'min_children' field"); } if (minChildren == 0) { - deprecationLogger.deprecate("min_children", MIN_CHILDREN_0_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.QUERIES, "min_children", MIN_CHILDREN_0_DEPRECATION_MESSAGE); } if (maxChildren < 0) { throw new IllegalArgumentException("[" + NAME + "] requires non-negative 'max_children' field"); diff --git a/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolateQueryBuilder.java b/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolateQueryBuilder.java index ee5dba8cc14ba..87ae06d6691ed 100644 --- a/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolateQueryBuilder.java +++ b/modules/percolator/src/main/java/org/elasticsearch/percolator/PercolateQueryBuilder.java @@ -54,6 +54,7 @@ import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.ConstructingObjectParser; import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; @@ -468,7 +469,7 @@ protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) { } GetRequest getRequest; if (indexedDocumentType != null) { - deprecationLogger.deprecate("percolate_with_type", TYPE_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "percolate_with_type", TYPE_DEPRECATION_MESSAGE); getRequest = new GetRequest(indexedDocumentIndex, indexedDocumentType, indexedDocumentId); } else { getRequest = new GetRequest(indexedDocumentIndex, indexedDocumentId); @@ -537,7 +538,7 @@ protected Query doToQuery(SearchExecutionContext context) throws IOException { final List docs = new ArrayList<>(); String type = context.getType(); if (documentType != null) { - deprecationLogger.deprecate("percolate_with_document_type", DOCUMENT_TYPE_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "percolate_with_document_type", DOCUMENT_TYPE_DEPRECATION_MESSAGE); if (documentType.equals(type) == false) { throw new IllegalArgumentException("specified document_type [" + documentType + "] is not equal to the actual type [" + type + "]"); diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexValidator.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexValidator.java index dc54bc7ff080d..543a65b39e7e6 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexValidator.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexValidator.java @@ -33,6 +33,7 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.settings.Settings; @@ -66,7 +67,7 @@ void initialValidation(ReindexRequest request) { state); SearchSourceBuilder searchSource = request.getSearchRequest().source(); if (searchSource != null && searchSource.sorts() != null && searchSource.sorts().isEmpty() == false) { - deprecationLogger.deprecate("reindex_sort", SORT_DEPRECATED_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.API, "reindex_sort", SORT_DEPRECATED_MESSAGE); } } diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/remote/RemoteRequestBuilders.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/remote/RemoteRequestBuilders.java index b557c88b58f78..9112be88412e4 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/remote/RemoteRequestBuilders.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/remote/RemoteRequestBuilders.java @@ -27,6 +27,7 @@ import org.elasticsearch.client.Request; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesReference; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; @@ -184,7 +185,7 @@ private static void addIndices(StringBuilder path, String[] indices) { private static String encodeIndex(String s) { if (s.contains("%")) { // already encoded, pass-through to allow this in mixed version clusters checkIndexOrType("Index", s); - DEPRECATION_LOGGER.deprecate("reindex_url_encoded_index", DEPRECATED_URL_ENCODED_INDEX_WARNING); + DEPRECATION_LOGGER.deprecate(DeprecationCategory.API, "reindex_url_encoded_index", DEPRECATED_URL_ENCODED_INDEX_WARNING); return s; } try { diff --git a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuNormalizerTokenFilterFactory.java b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuNormalizerTokenFilterFactory.java index cb00ecf24e496..b46c33cc6069c 100644 --- a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuNormalizerTokenFilterFactory.java +++ b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuNormalizerTokenFilterFactory.java @@ -24,6 +24,7 @@ import com.ibm.icu.text.UnicodeSet; import org.apache.lucene.analysis.TokenStream; import org.elasticsearch.Version; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -60,7 +61,7 @@ static Normalizer2 wrapWithUnicodeSetFilter(final IndexSettings indexSettings, String unicodeSetFilter = settings.get("unicodeSetFilter"); if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { if (unicodeSetFilter != null) { - deprecationLogger.deprecate("icu_normalizer_unicode_set_filter", + deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "icu_normalizer_unicode_set_filter", "[unicodeSetFilter] has been deprecated in favor of [unicode_set_filter]"); } else { unicodeSetFilter = settings.get("unicode_set_filter"); diff --git a/plugins/analysis-phonetic/src/main/java/org/elasticsearch/index/analysis/PhoneticTokenFilterFactory.java b/plugins/analysis-phonetic/src/main/java/org/elasticsearch/index/analysis/PhoneticTokenFilterFactory.java index d106a18f2a600..20b20ce8cddc4 100644 --- a/plugins/analysis-phonetic/src/main/java/org/elasticsearch/index/analysis/PhoneticTokenFilterFactory.java +++ b/plugins/analysis-phonetic/src/main/java/org/elasticsearch/index/analysis/PhoneticTokenFilterFactory.java @@ -36,6 +36,7 @@ import org.apache.lucene.analysis.phonetic.DoubleMetaphoneFilter; import org.apache.lucene.analysis.phonetic.PhoneticFilter; import org.elasticsearch.Version; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -150,8 +151,8 @@ public TokenFilterFactory getSynonymFilter() { throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } else { - DEPRECATION_LOGGER.deprecate("synonym_tokenfilters", "Token filter [" + name() - + "] will not be usable to parse synonyms after v7.0"); + DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters", + "Token filter [" + name() + "] will not be usable to parse synonyms after v7.0"); return this; } } diff --git a/plugins/discovery-azure-classic/src/main/java/org/elasticsearch/plugin/discovery/azure/classic/AzureDiscoveryPlugin.java b/plugins/discovery-azure-classic/src/main/java/org/elasticsearch/plugin/discovery/azure/classic/AzureDiscoveryPlugin.java index c2a614d52e747..a0a270f547739 100644 --- a/plugins/discovery-azure-classic/src/main/java/org/elasticsearch/plugin/discovery/azure/classic/AzureDiscoveryPlugin.java +++ b/plugins/discovery-azure-classic/src/main/java/org/elasticsearch/plugin/discovery/azure/classic/AzureDiscoveryPlugin.java @@ -23,6 +23,7 @@ import org.apache.logging.log4j.Logger; import org.elasticsearch.cloud.azure.classic.management.AzureComputeService; import org.elasticsearch.cloud.azure.classic.management.AzureComputeServiceImpl; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.network.NetworkService; import org.elasticsearch.common.settings.Setting; @@ -48,7 +49,7 @@ public class AzureDiscoveryPlugin extends Plugin implements DiscoveryPlugin { public AzureDiscoveryPlugin(Settings settings) { this.settings = settings; - deprecationLogger.deprecate("azure_discovery_plugin", "azure classic discovery plugin is deprecated."); + deprecationLogger.deprecate(DeprecationCategory.PLUGINS, "azure_discovery_plugin", "azure classic discovery plugin is deprecated."); logger.trace("starting azure classic discovery plugin..."); } diff --git a/plugins/discovery-ec2/src/main/java/org/elasticsearch/discovery/ec2/Ec2ClientSettings.java b/plugins/discovery-ec2/src/main/java/org/elasticsearch/discovery/ec2/Ec2ClientSettings.java index 8e97d4ba7455c..ef0ec8755bbae 100644 --- a/plugins/discovery-ec2/src/main/java/org/elasticsearch/discovery/ec2/Ec2ClientSettings.java +++ b/plugins/discovery-ec2/src/main/java/org/elasticsearch/discovery/ec2/Ec2ClientSettings.java @@ -26,6 +26,7 @@ import com.amazonaws.auth.BasicSessionCredentials; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.SecureSetting; import org.elasticsearch.common.settings.SecureString; @@ -135,12 +136,12 @@ static AWSCredentials loadCredentials(Settings settings) { return null; } else { if (key.length() == 0) { - deprecationLogger.deprecate("ec2_invalid_settings", + deprecationLogger.deprecate(DeprecationCategory.SETTINGS, "ec2_invalid_settings", "Setting [{}] is set but [{}] is not, which will be unsupported in future", SECRET_KEY_SETTING.getKey(), ACCESS_KEY_SETTING.getKey()); } if (secret.length() == 0) { - deprecationLogger.deprecate("ec2_invalid_settings", + deprecationLogger.deprecate(DeprecationCategory.SETTINGS, "ec2_invalid_settings", "Setting [{}] is set but [{}] is not, which will be unsupported in future", ACCESS_KEY_SETTING.getKey(), SECRET_KEY_SETTING.getKey()); } diff --git a/plugins/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3Repository.java b/plugins/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3Repository.java index 5f2cb452ab8ab..bcbc599790ef1 100644 --- a/plugins/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3Repository.java +++ b/plugins/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3Repository.java @@ -31,6 +31,7 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.blobstore.BlobPath; import org.elasticsearch.common.blobstore.BlobStore; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.SecureSetting; import org.elasticsearch.common.settings.SecureString; @@ -257,7 +258,7 @@ class S3Repository extends MeteredBlobStoreRepository { if (S3ClientSettings.checkDeprecatedCredentials(metadata.settings())) { // provided repository settings - deprecationLogger.deprecate("s3_repository_secret_settings", + deprecationLogger.deprecate(DeprecationCategory.SECURITY, "s3_repository_secret_settings", "Using s3 access/secret key from repository settings. Instead " + "store these in named clients and the elasticsearch keystore for secure settings."); } diff --git a/qa/evil-tests/src/test/java/org/elasticsearch/common/logging/EvilLoggerTests.java b/qa/evil-tests/src/test/java/org/elasticsearch/common/logging/EvilLoggerTests.java index 9628beb25b167..e354cbee21ceb 100644 --- a/qa/evil-tests/src/test/java/org/elasticsearch/common/logging/EvilLoggerTests.java +++ b/qa/evil-tests/src/test/java/org/elasticsearch/common/logging/EvilLoggerTests.java @@ -128,7 +128,8 @@ public void testConcurrentDeprecationLogger() throws IOException, UserException, } for (int j = 0; j < iterations; j++) { for (final Integer id : ids) { - deprecationLogger.deprecate(Integer.toString(id), "This is a maybe logged deprecation message" + id); + deprecationLogger.deprecate(DeprecationCategory.OTHER, Integer.toString(id), + "This is a maybe logged deprecation message" + id); } } diff --git a/qa/logging-config/src/test/java/org/elasticsearch/common/logging/JsonLoggerTests.java b/qa/logging-config/src/test/java/org/elasticsearch/common/logging/JsonLoggerTests.java index 4994a6888bee3..db006034ca2d0 100644 --- a/qa/logging-config/src/test/java/org/elasticsearch/common/logging/JsonLoggerTests.java +++ b/qa/logging-config/src/test/java/org/elasticsearch/common/logging/JsonLoggerTests.java @@ -83,7 +83,7 @@ public void testDeprecatedMessage() throws Exception { withThreadContext(threadContext -> { threadContext.putHeader(Task.X_OPAQUE_ID, "someId"); final DeprecationLogger testLogger = DeprecationLogger.getLogger("test"); - testLogger.deprecate("someKey", "deprecated message1"); + testLogger.deprecate(DeprecationCategory.OTHER, "someKey", "deprecated message1"); final Path path = PathUtils.get( System.getProperty("es.logs.base_path"), @@ -116,10 +116,10 @@ public void testDeprecatedMessage() throws Exception { public void testDeprecatedMessageWithoutXOpaqueId() throws IOException { final Logger testLogger = LogManager.getLogger("test"); - testLogger.info(new DeprecatedMessage("key", "someId", "deprecated message1")); - testLogger.info(new DeprecatedMessage("key", "", "deprecated message2")); + testLogger.info(new DeprecatedMessage(DeprecationCategory.OTHER, "key", "someId", "deprecated message1")); + testLogger.info(new DeprecatedMessage(DeprecationCategory.OTHER, "key", "", "deprecated message2")); // This message will be filtered out by the RateLimitingFilter because an empty ID is the same as a null one. - testLogger.info(new DeprecatedMessage("key", null, "deprecated message3")); + testLogger.info(new DeprecatedMessage(DeprecationCategory.OTHER, "key", null, "deprecated message3")); testLogger.info("deprecated message4"); final Path path = PathUtils.get(System.getProperty("es.logs.base_path"), @@ -279,8 +279,8 @@ public void testDuplicateLogMessages() throws Exception { // For the same key and X-Opaque-ID deprecation should be once withThreadContext(threadContext -> { threadContext.putHeader(Task.X_OPAQUE_ID, "ID1"); - deprecationLogger.deprecate("key", "message1"); - deprecationLogger.deprecate("key", "message2"); + deprecationLogger.deprecate(DeprecationCategory.OTHER, "key", "message1"); + deprecationLogger.deprecate(DeprecationCategory.OTHER, "key", "message2"); assertWarnings("message1", "message2"); final Path path = PathUtils.get(System.getProperty("es.logs.base_path"), @@ -307,8 +307,8 @@ public void testDuplicateLogMessages() throws Exception { //continuing with message1-ID1 in logs already, adding a new deprecation log line with message2-ID2 withThreadContext(threadContext -> { threadContext.putHeader(Task.X_OPAQUE_ID, "ID2"); - deprecationLogger.deprecate("key", "message1"); - deprecationLogger.deprecate("key", "message2"); + deprecationLogger.deprecate(DeprecationCategory.OTHER, "key", "message1"); + deprecationLogger.deprecate(DeprecationCategory.OTHER, "key", "message2"); assertWarnings("message1", "message2"); final Path path = PathUtils.get( diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/AddVotingConfigExclusionsRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/AddVotingConfigExclusionsRequest.java index d3cbe2bd366ae..ef032070dc068 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/AddVotingConfigExclusionsRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/AddVotingConfigExclusionsRequest.java @@ -28,6 +28,7 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.unit.TimeValue; @@ -82,7 +83,7 @@ public AddVotingConfigExclusionsRequest(String[] nodeDescriptions, String[] node } if (nodeDescriptions.length > 0) { - deprecationLogger.deprecate("voting_config_exclusion", DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.API, "voting_config_exclusion", DEPRECATION_MESSAGE); } this.nodeDescriptions = nodeDescriptions; @@ -104,7 +105,7 @@ public AddVotingConfigExclusionsRequest(StreamInput in) throws IOException { timeout = in.readTimeValue(); if (nodeDescriptions.length > 0) { - deprecationLogger.deprecate("voting_config_exclusion", + deprecationLogger.deprecate(DeprecationCategory.API, "voting_config_exclusion", "nodeDescription is deprecated and will be removed, use nodeIds or nodeNames instead"); } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java index 522d6880ba65b..700ed5f32e643 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/snapshots/restore/RestoreSnapshotRequest.java @@ -27,6 +27,7 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.ToXContentObject; @@ -489,7 +490,7 @@ public RestoreSnapshotRequest source(Map source) { if (!(entry.getValue() instanceof Map)) { throw new IllegalArgumentException("malformed settings section"); } - DEPRECATION_LOGGER.deprecate("RestoreSnapshotRequest#settings", + DEPRECATION_LOGGER.deprecate(DeprecationCategory.API, "RestoreSnapshotRequest#settings", "specifying [settings] when restoring a snapshot has no effect and will not be supported in a future version"); } else if (name.equals("include_global_state")) { includeGlobalState = nodeBooleanValue(entry.getValue(), "include_global_state"); diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/get/TransportGetAliasesAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/get/TransportGetAliasesAction.java index 6e2eec1f8592d..2904e11a24b28 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/get/TransportGetAliasesAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/get/TransportGetAliasesAction.java @@ -30,6 +30,7 @@ import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.collect.ImmutableOpenMap; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.indices.SystemIndices; @@ -111,7 +112,7 @@ private static void checkSystemIndexAccess(GetAliasesRequest request, SystemIndi } } if (systemIndicesNames.isEmpty() == false) { - deprecationLogger.deprecate("open_system_index_access", + deprecationLogger.deprecate(DeprecationCategory.API, "open_system_index_access", "this request accesses system indices: {}, but in a future major version, direct access to system " + "indices will be prevented by default", systemIndicesNames); } else { @@ -124,7 +125,7 @@ private static void checkSystemAliasAccess(GetAliasesRequest request, SystemIndi .filter(alias -> systemIndices.isSystemIndex(alias)) .collect(Collectors.toList()); if (systemAliases.isEmpty() == false) { - deprecationLogger.deprecate("open_system_alias_access", + deprecationLogger.deprecate(DeprecationCategory.API, "open_system_alias_access", "this request accesses aliases with names reserved for system indices: {}, but in a future major version, direct" + "access to system indices and their aliases will not be allowed", systemAliases); } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequest.java index c9be1c3102ed0..5e05271c9b65d 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/template/put/PutIndexTemplateRequest.java @@ -33,6 +33,7 @@ import org.elasticsearch.common.collect.MapBuilder; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.DeprecationHandler; @@ -336,7 +337,7 @@ public PutIndexTemplateRequest source(Map templateSource) { if (name.equals("template")) { // This is needed to allow for bwc (beats, logstash) with pre-5.0 templates (#21009) if(entry.getValue() instanceof String) { - deprecationLogger.deprecate("put_index_template_field", + deprecationLogger.deprecate(DeprecationCategory.API, "put_index_template_field", "Deprecated field [template] used, replaced by [index_patterns]"); patterns(Collections.singletonList((String) entry.getValue())); } diff --git a/server/src/main/java/org/elasticsearch/action/bulk/BulkRequestParser.java b/server/src/main/java/org/elasticsearch/action/bulk/BulkRequestParser.java index 4e05866f9fae0..642dcc936cb7d 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/BulkRequestParser.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/BulkRequestParser.java @@ -27,6 +27,7 @@ import org.elasticsearch.common.ParseField; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.lucene.uid.Versions; import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; @@ -207,7 +208,8 @@ public void parse( index = stringDeduplicator.computeIfAbsent(parser.text(), Function.identity()); } else if (TYPE.match(currentFieldName, parser.getDeprecationHandler())) { if (warnOnTypeUsage && typesDeprecationLogged == false) { - deprecationLogger.deprecate("bulk_with_types", RestBulkAction.TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "bulk_with_types", + RestBulkAction.TYPES_DEPRECATION_MESSAGE); typesDeprecationLogged = true; } type = stringDeduplicator.computeIfAbsent(parser.text(), Function.identity()); diff --git a/server/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineRequest.java b/server/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineRequest.java index 4b0f2791bdaf5..6b516f022f7e8 100644 --- a/server/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineRequest.java +++ b/server/src/main/java/org/elasticsearch/action/ingest/SimulatePipelineRequest.java @@ -24,6 +24,7 @@ import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -183,7 +184,7 @@ private static List parseDocs(Map config) { String index = ConfigurationUtils.readStringOrIntProperty(null, null, dataMap, Metadata.INDEX.getFieldName(), "_index"); if (dataMap.containsKey(Metadata.TYPE.getFieldName())) { - deprecationLogger.deprecate("simulate_pipeline_with_types", + deprecationLogger.deprecate(DeprecationCategory.TYPES, "simulate_pipeline_with_types", "[types removal] specifying _type in pipeline simulation requests is deprecated"); } String type = ConfigurationUtils.readStringOrIntProperty(null, null, diff --git a/server/src/main/java/org/elasticsearch/action/search/MultiSearchRequest.java b/server/src/main/java/org/elasticsearch/action/search/MultiSearchRequest.java index 2943d14bc5d9c..9e7315ce1f92f 100644 --- a/server/src/main/java/org/elasticsearch/action/search/MultiSearchRequest.java +++ b/server/src/main/java/org/elasticsearch/action/search/MultiSearchRequest.java @@ -28,6 +28,7 @@ import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; @@ -195,7 +196,7 @@ public static void readMultiLineFormat(BytesReference data, // support first line with \n if (nextMarker == 0) { from = nextMarker + 1; - deprecationLogger.deprecate("multi_search_empty_first_line", + deprecationLogger.deprecate(DeprecationCategory.API, "multi_search_empty_first_line", "support for empty first line before any action metadata in msearch API is deprecated and " + "will be removed in the next major version"); continue; diff --git a/server/src/main/java/org/elasticsearch/action/termvectors/TermVectorsRequest.java b/server/src/main/java/org/elasticsearch/action/termvectors/TermVectorsRequest.java index d66eda89aa984..7c28d3cb8bea4 100644 --- a/server/src/main/java/org/elasticsearch/action/termvectors/TermVectorsRequest.java +++ b/server/src/main/java/org/elasticsearch/action/termvectors/TermVectorsRequest.java @@ -32,6 +32,7 @@ import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.lucene.uid.Versions; import org.elasticsearch.common.util.set.Sets; @@ -613,7 +614,7 @@ public static void parseRequest(TermVectorsRequest termVectorsRequest, XContentP termVectorsRequest.index = parser.text(); } else if (TYPE.match(currentFieldName, parser.getDeprecationHandler())) { termVectorsRequest.type = parser.text(); - deprecationLogger.deprecate("termvectors_with_types", + deprecationLogger.deprecate(DeprecationCategory.TYPES, "termvectors_with_types", RestTermVectorsAction.TYPES_DEPRECATION_MESSAGE); } else if (ID.match(currentFieldName, parser.getDeprecationHandler())) { if (termVectorsRequest.doc != null) { diff --git a/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java b/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java index a87a647d8c063..91d5eacfef5ee 100644 --- a/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java +++ b/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java @@ -35,6 +35,7 @@ import org.elasticsearch.common.PidFile; import org.elasticsearch.common.SuppressForbidden; import org.elasticsearch.common.inject.CreationException; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.logging.LogConfigurator; import org.elasticsearch.common.logging.Loggers; @@ -366,7 +367,7 @@ static void init( + "requirement. Consider switching to a distribution of Elasticsearch with a bundled JDK. " + "If you are already using a distribution with a bundled JDK, ensure the JAVA_HOME environment variable is not set.", System.getProperty("java.home")); - DeprecationLogger.getLogger(Bootstrap.class).deprecate("java_version_11_required", message); + DeprecationLogger.getLogger(Bootstrap.class).deprecate(DeprecationCategory.OTHER, "java_version_11_required", message); } if (BootstrapInfo.getSystemProperties().get("es.xcontent.strict_duplicate_detection") != null) { final String message = String.format( @@ -374,7 +375,8 @@ static void init( "The Java option es.xcontent.strict_duplicate_detection is set to [%s]; " + "this option is deprecated and non-functional and should be removed from Java configuration.", BootstrapInfo.getSystemProperties().get("es.xcontent.strict_duplicate_detection")); - DeprecationLogger.getLogger(Bootstrap.class).deprecate("strict_duplicate_detection_setting_removed", message); + DeprecationLogger.getLogger(Bootstrap.class).deprecate(DeprecationCategory.OTHER, "strict_duplicate_detection_setting_removed", + message); } if (environment.pidFile() != null) { try { diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolver.java b/server/src/main/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolver.java index 2a6bfd20e804f..12dd497faafec 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolver.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/IndexNameExpressionResolver.java @@ -28,6 +28,7 @@ import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Strings; import org.elasticsearch.common.collect.ImmutableOpenMap; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.time.DateFormatter; @@ -322,7 +323,7 @@ private void checkSystemIndexAccess(Context context, Metadata metadata, Set 1) { - deprecationLogger.deprecate("index-templates", + deprecationLogger.deprecate(DeprecationCategory.TEMPLATES, "index-templates", "Index template {} contains multiple typed mappings; templates in 8x will only support a single mapping", name); } diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexService.java b/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexService.java index 260ea6763d2c2..c6987c7e0a296 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexService.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexService.java @@ -55,6 +55,7 @@ import org.elasticsearch.common.ValidationException; import org.elasticsearch.common.compress.CompressedXContent; import org.elasticsearch.common.io.PathUtils; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.IndexScopedSettings; import org.elasticsearch.common.settings.Setting; @@ -214,7 +215,7 @@ public boolean validateDotIndex(String index, @Nullable Boolean isHidden) { } else if (isHidden) { logger.trace("index [{}] is a hidden index", index); } else { - DEPRECATION_LOGGER.deprecate("index_name_starts_with_dot", + DEPRECATION_LOGGER.deprecate(DeprecationCategory.INDICES, "index_name_starts_with_dot", "index name [{}] starts with a dot '.', in the next major version, index names " + "starting with a dot are reserved for hidden indices and system indices", index); } @@ -362,7 +363,7 @@ public ClusterState applyCreateIndexRequest(ClusterState currentState, CreateInd request.index(), isHiddenFromRequest); if (v1Templates.size() > 1) { - DEPRECATION_LOGGER.deprecate("index_template_multiple_match", + DEPRECATION_LOGGER.deprecate(DeprecationCategory.TEMPLATES, "index_template_multiple_match", "index [{}] matches multiple legacy templates [{}], composable templates will only match a single template", request.index(), v1Templates.stream().map(IndexTemplateMetadata::name).sorted().collect(Collectors.joining(", "))); } @@ -764,7 +765,7 @@ static Settings aggregateIndexSettings(ClusterState currentState, CreateIndexClu */ shardLimitValidator.validateShardLimit(indexSettings, currentState); if (indexSettings.getAsBoolean(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true) == false) { - DEPRECATION_LOGGER.deprecate("soft_deletes_disabled", + DEPRECATION_LOGGER.deprecate(DeprecationCategory.SETTINGS, "soft_deletes_disabled", "Creating indices with soft-deletes disabled is deprecated and will be removed in future Elasticsearch versions. " + "Please do not specify value for setting [index.soft_deletes.enabled] of index [" + request.index() + "]."); } @@ -1232,7 +1233,8 @@ public static void validateTranslogRetentionSettings(Settings indexSettings) { if (IndexSettings.INDEX_SOFT_DELETES_SETTING.get(indexSettings) && (IndexSettings.INDEX_TRANSLOG_RETENTION_AGE_SETTING.exists(indexSettings) || IndexSettings.INDEX_TRANSLOG_RETENTION_SIZE_SETTING.exists(indexSettings))) { - DEPRECATION_LOGGER.deprecate("translog_retention", "Translog retention settings [index.translog.retention.age] " + DEPRECATION_LOGGER.deprecate(DeprecationCategory.SETTINGS, "translog_retention", + "Translog retention settings [index.translog.retention.age] " + "and [index.translog.retention.size] are deprecated and effectively ignored. They will be removed in a future version."); } } diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/OperationRouting.java b/server/src/main/java/org/elasticsearch/cluster/routing/OperationRouting.java index 2596c164b7b2f..6e33e89b56c82 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/OperationRouting.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/OperationRouting.java @@ -26,6 +26,7 @@ import org.elasticsearch.cluster.routing.allocation.decider.AwarenessAllocationDecider; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.Setting; @@ -66,7 +67,7 @@ public OperationRouting(Settings settings, ClusterSettings clusterSettings) { if (ignoreAwarenessAttr == false) { awarenessAttributes = AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTE_SETTING.get(settings); if (awarenessAttributes.isEmpty() == false) { - deprecationLogger.deprecate("searches_not_routed_on_awareness_attributes", + deprecationLogger.deprecate(DeprecationCategory.SETTINGS, "searches_not_routed_on_awareness_attributes", IGNORE_AWARENESS_ATTRIBUTES_DEPRECATION_MESSAGE); } clusterSettings.addSettingsUpdateConsumer(AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTE_SETTING, @@ -91,7 +92,7 @@ private void setAwarenessAttributes(List awarenessAttributes) { boolean ignoreAwarenessAttr = parseBoolean(System.getProperty(IGNORE_AWARENESS_ATTRIBUTES_PROPERTY), false); if (ignoreAwarenessAttr == false) { if (this.awarenessAttributes.isEmpty() && awarenessAttributes.isEmpty() == false) { - deprecationLogger.deprecate("searches_not_routed_on_awareness_attributes", + deprecationLogger.deprecate(DeprecationCategory.SETTINGS, "searches_not_routed_on_awareness_attributes", IGNORE_AWARENESS_ATTRIBUTES_DEPRECATION_MESSAGE); } this.awarenessAttributes = awarenessAttributes; diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/DiskThresholdMonitor.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/DiskThresholdMonitor.java index 0cce3b894900e..1b34d96725f94 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/DiskThresholdMonitor.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/DiskThresholdMonitor.java @@ -41,6 +41,7 @@ import org.elasticsearch.common.Priority; import org.elasticsearch.common.Strings; import org.elasticsearch.common.collect.ImmutableOpenMap; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.Settings; @@ -101,9 +102,13 @@ public DiskThresholdMonitor(Settings settings, Supplier clusterSta this.diskThresholdSettings = new DiskThresholdSettings(settings, clusterSettings); this.client = client; if (diskThresholdSettings.isAutoReleaseIndexEnabled() == false) { - deprecationLogger.deprecate(DiskThresholdSettings.AUTO_RELEASE_INDEX_ENABLED_KEY.replace(".", "_"), + deprecationLogger.deprecate( + DeprecationCategory.SETTINGS, + DiskThresholdSettings.AUTO_RELEASE_INDEX_ENABLED_KEY.replace(".", "_"), "[{}] will be removed in version {}", - DiskThresholdSettings.AUTO_RELEASE_INDEX_ENABLED_KEY, Version.V_7_4_0.major + 1); + DiskThresholdSettings.AUTO_RELEASE_INDEX_ENABLED_KEY, + Version.V_7_4_0.major + 1 + ); } } @@ -312,9 +317,12 @@ public void onNewInfo(ClusterInfo info) { updateIndicesReadOnly(indicesToAutoRelease, listener, false); } else { deprecationLogger.deprecate( + DeprecationCategory.SETTINGS, DiskThresholdSettings.AUTO_RELEASE_INDEX_ENABLED_KEY.replace(".", "_"), "[{}] will be removed in version {}", - DiskThresholdSettings.AUTO_RELEASE_INDEX_ENABLED_KEY, Version.V_7_4_0.major + 1); + DiskThresholdSettings.AUTO_RELEASE_INDEX_ENABLED_KEY, + Version.V_7_4_0.major + 1 + ); logger.debug("[{}] disabled, not releasing read-only-allow-delete block on indices: [{}]", DiskThresholdSettings.AUTO_RELEASE_INDEX_ENABLED_KEY, indicesToAutoRelease); listener.onResponse(null); diff --git a/server/src/main/java/org/elasticsearch/common/geo/SpatialStrategy.java b/server/src/main/java/org/elasticsearch/common/geo/SpatialStrategy.java index e0127d9f1a825..97b501f6e2989 100644 --- a/server/src/main/java/org/elasticsearch/common/geo/SpatialStrategy.java +++ b/server/src/main/java/org/elasticsearch/common/geo/SpatialStrategy.java @@ -21,6 +21,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import java.io.IOException; @@ -55,7 +56,8 @@ public static SpatialStrategy fromString(String strategyName, DeprecationLogger return strategy; } } - logger.deprecate("geo_strategy", "Unrecognised strategy [" + strategyName + "], falling back to [recursive]"); + logger.deprecate(DeprecationCategory.OTHER, "geo_strategy", + "Unrecognised strategy [" + strategyName + "], falling back to [recursive]"); return null; } } diff --git a/server/src/main/java/org/elasticsearch/common/joda/Joda.java b/server/src/main/java/org/elasticsearch/common/joda/Joda.java index 48dd1518605bf..9595f92fb3650 100644 --- a/server/src/main/java/org/elasticsearch/common/joda/Joda.java +++ b/server/src/main/java/org/elasticsearch/common/joda/Joda.java @@ -21,6 +21,7 @@ import org.elasticsearch.Version; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.time.DateFormatter; import org.elasticsearch.common.time.FormatNames; @@ -75,7 +76,8 @@ public static JodaDateFormatter forPattern(String input) { String msg = "Camel case format name {} is deprecated and will be removed in a future version. " + "Use snake case name {} instead."; getDeprecationLogger() - .deprecate("camelCaseDateFormat", msg, formatName.getCamelCaseName(), formatName.getSnakeCaseName()); + .deprecate(DeprecationCategory.PARSING,"camelCaseDateFormat", msg, formatName.getCamelCaseName(), + formatName.getSnakeCaseName()); } DateTimeFormatter formatter; @@ -159,8 +161,8 @@ public static JodaDateFormatter forPattern(String input) { formatter = ISODateTimeFormat.weekDateTimeNoMillis(); } else if (FormatNames.WEEKYEAR.matches(input)) { getDeprecationLogger() - .deprecate("week_year_format_name", "Format name \"week_year\" is deprecated and will be removed in a future version. " + - "Use \"weekyear\" format instead"); + .deprecate(DeprecationCategory.PARSING, "week_year_format_name", + "Format name \"week_year\" is deprecated and will be removed in a future version. Use \"weekyear\" format instead"); formatter = ISODateTimeFormat.weekyear(); } else if (FormatNames.WEEK_YEAR.matches(input)) { formatter = ISODateTimeFormat.weekyear(); @@ -289,7 +291,7 @@ public static JodaDateFormatter forPattern(String input) { private static void maybeLogJodaDeprecation(String format) { if (JodaDeprecationPatterns.isDeprecatedPattern(format)) { String suggestion = JodaDeprecationPatterns.formatSuggestion(format); - getDeprecationLogger().deprecate("joda-pattern-deprecation", + getDeprecationLogger().deprecate(DeprecationCategory.PARSING, "joda-pattern-deprecation", suggestion + " " + JodaDeprecationPatterns.USE_NEW_FORMAT_SPECIFIERS); } } @@ -399,11 +401,11 @@ public int parseInto(DateTimeParserBucket bucket, String text, int position) { long millis = new BigDecimal(text).longValue() * factor; // check for deprecations, but after it has parsed correctly so invalid values aren't counted as deprecated if (millis < 0) { - getDeprecationLogger().deprecate("epoch-negative", "Use of negative values" + + getDeprecationLogger().deprecate(DeprecationCategory.PARSING, "epoch-negative", "Use of negative values" + " in epoch time formats is deprecated and will not be supported in the next major version of Elasticsearch."); } if (scientificNotation.matcher(text).find()) { - getDeprecationLogger().deprecate("epoch-scientific-notation", "Use of scientific notation" + + getDeprecationLogger().deprecate(DeprecationCategory.PARSING, "epoch-scientific-notation", "Use of scientific notation" + " in epoch time formats is deprecated and will not be supported in the next major version of Elasticsearch."); } DateTime dt = new DateTime(millis, DateTimeZone.UTC); diff --git a/server/src/main/java/org/elasticsearch/common/logging/DeprecatedMessage.java b/server/src/main/java/org/elasticsearch/common/logging/DeprecatedMessage.java index f34e53eaddd7f..f893a94e2a221 100644 --- a/server/src/main/java/org/elasticsearch/common/logging/DeprecatedMessage.java +++ b/server/src/main/java/org/elasticsearch/common/logging/DeprecatedMessage.java @@ -22,7 +22,9 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.collect.MapBuilder; +import java.util.Locale; import java.util.Map; +import java.util.Objects; /** * A logger message used by {@link DeprecationLogger}. @@ -31,12 +33,18 @@ public class DeprecatedMessage extends ESLogMessage { public static final String X_OPAQUE_ID_FIELD_NAME = "x-opaque-id"; - public DeprecatedMessage(String key, String xOpaqueId, String messagePattern, Object... args) { - super(fieldMap(key, xOpaqueId), messagePattern, args); + public DeprecatedMessage(DeprecationCategory category, String key, String xOpaqueId, String messagePattern, Object... args) { + super(fieldMap(category, key, xOpaqueId), messagePattern, args); } - private static Map fieldMap(String key, String xOpaqueId) { + private static Map fieldMap(DeprecationCategory category, String key, String xOpaqueId) { final MapBuilder builder = MapBuilder.newMapBuilder(); + + // The fields below are emitted using ECS keys in `EcsJsonLayout` + + Objects.requireNonNull(category, "category cannot be null"); + builder.put("category", category.name().toLowerCase(Locale.ROOT)); + if (Strings.isNullOrEmpty(key) == false) { builder.put("key", key); } diff --git a/server/src/main/java/org/elasticsearch/common/logging/DeprecationCategory.java b/server/src/main/java/org/elasticsearch/common/logging/DeprecationCategory.java new file mode 100644 index 0000000000000..6777edbf7563f --- /dev/null +++ b/server/src/main/java/org/elasticsearch/common/logging/DeprecationCategory.java @@ -0,0 +1,45 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.common.logging; + +/** + * Deprecation log messages are categorised so that consumers of the logs can easily aggregate them. + *

+ * When categorising a message, you should consider the impact of the work required to mitigate the + * deprecation. For example, a settings change would normally be categorised as {@link #SETTINGS}, + * but if the setting in question was related to security configuration, it may be more appropriate + * to categorise the deprecation message as {@link #SECURITY}. + */ +public enum DeprecationCategory { + AGGREGATIONS, + ANALYSIS, + API, + INDICES, + MAPPINGS, + OTHER, + PARSING, + PLUGINS, + QUERIES, + SCRIPTING, + SECURITY, + SETTINGS, + TEMPLATES, + TYPES +} diff --git a/server/src/main/java/org/elasticsearch/common/logging/DeprecationLogger.java b/server/src/main/java/org/elasticsearch/common/logging/DeprecationLogger.java index fcc3b2b09951c..fc980d9230e77 100644 --- a/server/src/main/java/org/elasticsearch/common/logging/DeprecationLogger.java +++ b/server/src/main/java/org/elasticsearch/common/logging/DeprecationLogger.java @@ -86,14 +86,19 @@ private static String toLoggerName(final Class cls) { * Logs a message at the {@link #DEPRECATION} level. The message is also sent to the header warning logger, * so that it can be returned to the client. */ - public DeprecationLoggerBuilder deprecate(final String key, final String msg, final Object... params) { - return new DeprecationLoggerBuilder().withDeprecation(key, msg, params); + public DeprecationLoggerBuilder deprecate( + final DeprecationCategory category, + final String key, + final String msg, + final Object... params + ) { + return new DeprecationLoggerBuilder().withDeprecation(category, key, msg, params); } public class DeprecationLoggerBuilder { - public DeprecationLoggerBuilder withDeprecation(String key, String msg, Object[] params) { - ESLogMessage deprecationMessage = new DeprecatedMessage(key, HeaderWarning.getXOpaqueId(), msg, params); + public DeprecationLoggerBuilder withDeprecation(DeprecationCategory category, String key, String msg, Object[] params) { + ESLogMessage deprecationMessage = new DeprecatedMessage(category, key, HeaderWarning.getXOpaqueId(), msg, params); logger.log(DEPRECATION, deprecationMessage); diff --git a/server/src/main/java/org/elasticsearch/common/settings/Setting.java b/server/src/main/java/org/elasticsearch/common/settings/Setting.java index 4e1dd2eead0d8..0893a32927627 100644 --- a/server/src/main/java/org/elasticsearch/common/settings/Setting.java +++ b/server/src/main/java/org/elasticsearch/common/settings/Setting.java @@ -27,6 +27,7 @@ import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Strings; import org.elasticsearch.common.collect.Tuple; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.unit.MemorySizeValue; @@ -313,6 +314,16 @@ public final boolean isPrivateIndex() { return properties.contains(Property.PrivateIndex); } + /** + * Checks whether this is a secure setting. + * @param settings used to check whether this setting is secure + * @return whether this is a secure setting. + */ + public final boolean isSecure(Settings settings) { + final SecureSettings secureSettings = settings.getSecureSettings(); + return secureSettings != null && secureSettings.getSettingNames().contains(getKey()); + } + /** * Returns the setting properties * @see Property @@ -515,8 +526,7 @@ private String getRaw(final Settings settings) { * @return the raw string representation of the setting value */ String innerGetRaw(final Settings settings) { - SecureSettings secureSettings = settings.getSecureSettings(); - if (secureSettings != null && secureSettings.getSettingNames().contains(getKey())) { + if (this.isSecure(settings)) { throw new IllegalArgumentException("Setting [" + getKey() + "] is a non-secure setting" + " and must be stored inside elasticsearch.yml, but was found inside the Elasticsearch keystore"); } @@ -529,8 +539,11 @@ void checkDeprecation(Settings settings) { if (this.isDeprecated() && this.exists(settings)) { // It would be convenient to show its replacement key, but replacement is often not so simple final String key = getKey(); + + DeprecationCategory category = this.isSecure(settings) ? DeprecationCategory.SECURITY : DeprecationCategory.SETTINGS; + Settings.DeprecationLoggerHolder.deprecationLogger - .deprecate(key, "[{}] setting was deprecated in Elasticsearch and will be removed in a future release! " + .deprecate(category, key, "[{}] setting was deprecated in Elasticsearch and will be removed in a future release! " + "See the breaking changes documentation for the next major version.", key); } } diff --git a/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java b/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java index 0ce2f430407b8..8414a2c9237d2 100644 --- a/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java +++ b/server/src/main/java/org/elasticsearch/common/time/DateFormatters.java @@ -21,6 +21,7 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.SuppressForbidden; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.util.LazyInitializable; @@ -1662,7 +1663,8 @@ static DateFormatter forPattern(String input) { String msg = "Camel case format name {} is deprecated and will be removed in a future version. " + "Use snake case name {} instead."; deprecationLogger.getOrCompute() - .deprecate("camelCaseDateFormat", msg, formatName.getCamelCaseName(), formatName.getSnakeCaseName()); + .deprecate(DeprecationCategory.PARSING, "camelCaseDateFormat", msg, formatName.getCamelCaseName(), + formatName.getSnakeCaseName()); } if (FormatNames.ISO8601.matches(input)) { @@ -1743,7 +1745,8 @@ static DateFormatter forPattern(String input) { return WEEK_DATE_TIME_NO_MILLIS; } else if (FormatNames.WEEK_YEAR.matches(input)) { deprecationLogger.getOrCompute() - .deprecate("week_year_format_name", "Format name \"week_year\" is deprecated and will be removed in a future version. " + + .deprecate(DeprecationCategory.PARSING, + "week_year_format_name", "Format name \"week_year\" is deprecated and will be removed in a future version. " + "Use \"weekyear\" format instead"); return WEEK_YEAR; } else if (FormatNames.WEEKYEAR.matches(input)) { diff --git a/server/src/main/java/org/elasticsearch/common/time/DateUtils.java b/server/src/main/java/org/elasticsearch/common/time/DateUtils.java index eb7daf2a3f69c..594984763d650 100644 --- a/server/src/main/java/org/elasticsearch/common/time/DateUtils.java +++ b/server/src/main/java/org/elasticsearch/common/time/DateUtils.java @@ -19,6 +19,7 @@ package org.elasticsearch.common.time; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.joda.time.DateTimeZone; @@ -200,7 +201,7 @@ public static ZoneId dateTimeZoneToZoneId(DateTimeZone timeZone) { public static ZoneId of(String zoneId) { String deprecatedId = DEPRECATED_SHORT_TIMEZONES.get(zoneId); if (deprecatedId != null) { - deprecationLogger.deprecate("timezone", + deprecationLogger.deprecate(DeprecationCategory.PARSING, "timezone", "Use of short timezone id " + zoneId + " is deprecated. Use " + deprecatedId + " instead"); return ZoneId.of(deprecatedId); } diff --git a/server/src/main/java/org/elasticsearch/common/unit/ByteSizeValue.java b/server/src/main/java/org/elasticsearch/common/unit/ByteSizeValue.java index 05484a598c990..c03b117778b5b 100644 --- a/server/src/main/java/org/elasticsearch/common/unit/ByteSizeValue.java +++ b/server/src/main/java/org/elasticsearch/common/unit/ByteSizeValue.java @@ -25,6 +25,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.logging.LogConfigurator; import org.elasticsearch.common.xcontent.ToXContentFragment; @@ -269,7 +270,7 @@ private static ByteSizeValue parse(final String initialInput, final String norma try { final double doubleValue = Double.parseDouble(s); DeprecationLoggerHolder.deprecationLogger - .deprecate("fractional_byte_values", + .deprecate(DeprecationCategory.PARSING, "fractional_byte_values", "Fractional bytes values are deprecated. Use non-fractional bytes values instead: [{}] found for setting [{}]", initialInput, settingName); return new ByteSizeValue((long) (doubleValue * unit.toBytes(1))); diff --git a/server/src/main/java/org/elasticsearch/common/util/concurrent/EsExecutors.java b/server/src/main/java/org/elasticsearch/common/util/concurrent/EsExecutors.java index e49562a647d92..abd0090a68af6 100644 --- a/server/src/main/java/org/elasticsearch/common/util/concurrent/EsExecutors.java +++ b/server/src/main/java/org/elasticsearch/common/util/concurrent/EsExecutors.java @@ -21,6 +21,7 @@ import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.common.SuppressForbidden; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting.Property; @@ -75,6 +76,7 @@ private static Function processorsParser(final String name) { final int availableProcessors = Runtime.getRuntime().availableProcessors(); if (value > availableProcessors) { deprecationLogger.deprecate( + DeprecationCategory.SETTINGS, "processors", "setting [{}] to value [{}] which is more than available processors [{}] is deprecated", name, diff --git a/server/src/main/java/org/elasticsearch/common/xcontent/LoggingDeprecationHandler.java b/server/src/main/java/org/elasticsearch/common/xcontent/LoggingDeprecationHandler.java index c4d66e27da05a..4e54c5c53387e 100644 --- a/server/src/main/java/org/elasticsearch/common/xcontent/LoggingDeprecationHandler.java +++ b/server/src/main/java/org/elasticsearch/common/xcontent/LoggingDeprecationHandler.java @@ -20,6 +20,7 @@ package org.elasticsearch.common.xcontent; import org.elasticsearch.common.ParseField; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import java.util.function.Supplier; @@ -52,21 +53,21 @@ private LoggingDeprecationHandler() { @Override public void usedDeprecatedName(String parserName, Supplier location, String usedName, String modernName) { String prefix = parserName == null ? "" : "[" + parserName + "][" + location.get() + "] "; - deprecationLogger.deprecate("deprecated_field", + deprecationLogger.deprecate(DeprecationCategory.API, "deprecated_field", "{}Deprecated field [{}] used, expected [{}] instead", prefix, usedName, modernName); } @Override public void usedDeprecatedField(String parserName, Supplier location, String usedName, String replacedWith) { String prefix = parserName == null ? "" : "[" + parserName + "][" + location.get() + "] "; - deprecationLogger.deprecate("deprecated_field", + deprecationLogger.deprecate(DeprecationCategory.API, "deprecated_field", "{}Deprecated field [{}] used, replaced by [{}]", prefix, usedName, replacedWith); } @Override public void usedDeprecatedField(String parserName, Supplier location, String usedName) { String prefix = parserName == null ? "" : "[" + parserName + "][" + location.get() + "] "; - deprecationLogger.deprecate("deprecated_field", + deprecationLogger.deprecate(DeprecationCategory.API, "deprecated_field", "{}Deprecated field [{}] used, this field is unused and will be removed entirely", prefix, usedName); } } diff --git a/server/src/main/java/org/elasticsearch/http/HttpInfo.java b/server/src/main/java/org/elasticsearch/http/HttpInfo.java index 4a05f6dcecf74..f34a4bbe3e9b9 100644 --- a/server/src/main/java/org/elasticsearch/http/HttpInfo.java +++ b/server/src/main/java/org/elasticsearch/http/HttpInfo.java @@ -21,6 +21,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.network.InetAddresses; import org.elasticsearch.common.transport.BoundTransportAddress; @@ -73,6 +74,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws String hostString = publishAddress.address().getHostString(); if (CNAME_IN_PUBLISH_HOST) { deprecationLogger.deprecate( + DeprecationCategory.SETTINGS, "cname_in_publish_address", "es.http.cname_in_publish_address system property is deprecated and no longer affects http.publish_address " + "formatting. Remove this property to get rid of this deprecation warning." diff --git a/server/src/main/java/org/elasticsearch/index/analysis/PreConfiguredTokenFilter.java b/server/src/main/java/org/elasticsearch/index/analysis/PreConfiguredTokenFilter.java index 0239682fcfa6c..87c5fb02a70fd 100644 --- a/server/src/main/java/org/elasticsearch/index/analysis/PreConfiguredTokenFilter.java +++ b/server/src/main/java/org/elasticsearch/index/analysis/PreConfiguredTokenFilter.java @@ -22,6 +22,7 @@ import org.apache.lucene.analysis.TokenFilter; import org.apache.lucene.analysis.TokenStream; import org.elasticsearch.Version; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.indices.analysis.PreBuiltCacheFactory; import org.elasticsearch.indices.analysis.PreBuiltCacheFactory.CachingStrategy; @@ -130,7 +131,7 @@ public TokenFilterFactory getSynonymFilter() { throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } else { - DEPRECATION_LOGGER.deprecate(name(), "Token filter [" + name() + DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, name(), "Token filter [" + name() + "] will not be usable to parse synonyms after v7.0"); return this; } @@ -157,7 +158,7 @@ public TokenFilterFactory getSynonymFilter() { throw new IllegalArgumentException("Token filter [" + name() + "] cannot be used to parse synonyms"); } else { - DEPRECATION_LOGGER.deprecate(name(), "Token filter [" + name() + DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, name(), "Token filter [" + name() + "] will not be usable to parse synonyms after v7.0"); return this; } diff --git a/server/src/main/java/org/elasticsearch/index/analysis/ShingleTokenFilterFactory.java b/server/src/main/java/org/elasticsearch/index/analysis/ShingleTokenFilterFactory.java index 9e5b13843949a..a2c1ab9045809 100644 --- a/server/src/main/java/org/elasticsearch/index/analysis/ShingleTokenFilterFactory.java +++ b/server/src/main/java/org/elasticsearch/index/analysis/ShingleTokenFilterFactory.java @@ -23,6 +23,7 @@ import org.apache.lucene.analysis.miscellaneous.DisableGraphAttribute; import org.apache.lucene.analysis.shingle.ShingleFilter; import org.elasticsearch.Version; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -49,7 +50,7 @@ public ShingleTokenFilterFactory(IndexSettings indexSettings, Environment enviro + " must be less than or equal to: [" + maxAllowedShingleDiff + "] but was [" + shingleDiff + "]. This limit" + " can be set by changing the [" + IndexSettings.MAX_SHINGLE_DIFF_SETTING.getKey() + "] index level setting."); } else { - deprecationLogger.deprecate("excessive_shingle_diff", + deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "excessive_shingle_diff", "Deprecated big difference between maxShingleSize and minShingleSize" + " in Shingle TokenFilter, expected difference must be less than or equal to: [" + maxAllowedShingleDiff + "]"); } @@ -75,7 +76,7 @@ public TokenFilterFactory getSynonymFilter() { "] cannot be used to parse synonyms"); } else { - DEPRECATION_LOGGER.deprecate("synonym_tokenfilters", "Token filter " + name() + DEPRECATION_LOGGER.deprecate(DeprecationCategory.ANALYSIS, "synonym_tokenfilters", "Token filter " + name() + "] will not be usable to parse synonym after v7.0"); } return this; diff --git a/server/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java index 08cb2e4ba8127..18775632462c2 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java @@ -31,6 +31,7 @@ import org.apache.lucene.search.suggest.document.SuggestField; import org.elasticsearch.Version; import org.elasticsearch.common.ParsingException; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.unit.Fuzziness; import org.elasticsearch.common.util.set.Sets; @@ -194,7 +195,7 @@ public CompletionFieldMapper build(ContentPath contentPath) { private void checkCompletionContextsLimit() { if (this.contexts.getValue() != null && this.contexts.getValue().size() > COMPLETION_CONTEXTS_LIMIT) { - deprecationLogger.deprecate("excessive_completion_contexts", + deprecationLogger.deprecate(DeprecationCategory.MAPPINGS, "excessive_completion_contexts", "You have defined more than [" + COMPLETION_CONTEXTS_LIMIT + "] completion contexts" + " in the mapping for field [" + name() + "]. " + "The maximum allowed number of completion contexts in a mapping will be limited to " + diff --git a/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java index 377f01c970731..7b9786264f4fc 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java @@ -33,6 +33,7 @@ import org.elasticsearch.common.Nullable; import org.elasticsearch.common.geo.ShapeRelation; import org.elasticsearch.common.joda.Joda; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.lucene.BytesRefs; import org.elasticsearch.common.time.DateFormatter; @@ -277,7 +278,8 @@ private Long parseNullValue(DateFieldType fieldType) { try { return fieldType.parse(nullValue.getValue()); } catch (Exception e) { - DEPRECATION_LOGGER.deprecate("date_mapper_null_field", "Error parsing [" + nullValue.getValue() + DEPRECATION_LOGGER.deprecate(DeprecationCategory.MAPPINGS, "date_mapper_null_field", + "Error parsing [" + nullValue.getValue() + "] as date in [null_value] on field [" + name() + "]); [null_value] will be ignored"); return null; } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/DynamicTemplate.java b/server/src/main/java/org/elasticsearch/index/mapper/DynamicTemplate.java index 17c4d9db4787c..009777ac4475e 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/DynamicTemplate.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/DynamicTemplate.java @@ -20,6 +20,7 @@ package org.elasticsearch.index.mapper; import org.elasticsearch.Version; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.xcontent.ToXContentObject; @@ -216,7 +217,7 @@ static DynamicTemplate parse(String name, Map conf, Version inde if (indexVersionCreated.onOrAfter(Version.V_6_0_0_alpha1)) { throw e; } else { - deprecationLogger.deprecate("invalid_mapping_type", + deprecationLogger.deprecate(DeprecationCategory.MAPPINGS, "invalid_mapping_type", "match_mapping_type [" + matchMappingType + "] is invalid and will be ignored: " + e.getMessage()); // this template is on an unknown type so it will never match anything diff --git a/server/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java index 90bbc2f6237de..7686e5a326d4f 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java @@ -19,6 +19,23 @@ package org.elasticsearch.index.mapper; +import org.apache.lucene.document.Field; +import org.elasticsearch.Version; +import org.elasticsearch.common.Explicit; +import org.elasticsearch.common.TriFunction; +import org.elasticsearch.common.logging.DeprecationCategory; +import org.elasticsearch.common.logging.DeprecationLogger; +import org.elasticsearch.common.settings.Setting; +import org.elasticsearch.common.settings.Setting.Property; +import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentParser; +import org.elasticsearch.common.xcontent.support.AbstractXContentParser; +import org.elasticsearch.common.xcontent.support.XContentMapValues; +import org.elasticsearch.index.analysis.NamedAnalyzer; +import org.elasticsearch.index.mapper.FieldNamesFieldMapper.FieldNamesFieldType; +import org.elasticsearch.index.mapper.Mapper.TypeParser.ParserContext; + import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -37,22 +54,6 @@ import java.util.function.Function; import java.util.function.Supplier; -import org.apache.lucene.document.Field; -import org.elasticsearch.Version; -import org.elasticsearch.common.Explicit; -import org.elasticsearch.common.TriFunction; -import org.elasticsearch.common.logging.DeprecationLogger; -import org.elasticsearch.common.settings.Setting; -import org.elasticsearch.common.settings.Setting.Property; -import org.elasticsearch.common.xcontent.ToXContent; -import org.elasticsearch.common.xcontent.XContentBuilder; -import org.elasticsearch.common.xcontent.XContentParser; -import org.elasticsearch.common.xcontent.support.AbstractXContentParser; -import org.elasticsearch.common.xcontent.support.XContentMapValues; -import org.elasticsearch.index.analysis.NamedAnalyzer; -import org.elasticsearch.index.mapper.FieldNamesFieldMapper.FieldNamesFieldType; -import org.elasticsearch.index.mapper.Mapper.TypeParser.ParserContext; - public abstract class FieldMapper extends Mapper implements Cloneable { public static final Setting IGNORE_MALFORMED_SETTING = Setting.boolSetting("index.mapping.ignore_malformed", false, Property.IndexScope); @@ -969,14 +970,15 @@ public final void parse(String name, ParserContext parserContext, Map parameter = deprecatedParamsMap.get(propName); if (parameter != null) { - deprecationLogger.deprecate(propName, "Parameter [{}] on mapper [{}] is deprecated, use [{}]", + deprecationLogger.deprecate(DeprecationCategory.MAPPINGS, propName, + "Parameter [{}] on mapper [{}] is deprecated, use [{}]", propName, name, parameter.name); } else { parameter = paramsMap.get(propName); } if (parameter == null) { if (isDeprecatedParameter(propName, parserContext.indexVersionCreated())) { - deprecationLogger.deprecate(propName, + deprecationLogger.deprecate(DeprecationCategory.MAPPINGS, propName, "Parameter [{}] has no effect on type [{}] and will be removed in future", propName, type); iterator.remove(); continue; @@ -986,12 +988,13 @@ public final void parse(String name, ParserContext parserContext, Map> getParameters() { @Override public FieldNamesFieldMapper build() { if (enabled.getValue().explicit()) { - deprecationLogger.deprecate("field_names_enabled_parameter", ENABLED_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.MAPPINGS, "field_names_enabled_parameter", ENABLED_DEPRECATION_MESSAGE); } FieldNamesFieldType fieldNamesFieldType = new FieldNamesFieldType(enabled.getValue().value()); return new FieldNamesFieldMapper(enabled.getValue(), indexVersionCreated, fieldNamesFieldType); @@ -143,7 +144,7 @@ public Query termQuery(Object value, SearchExecutionContext context) { if (isEnabled() == false) { throw new IllegalStateException("Cannot run [exists] queries if the [_field_names] field is disabled"); } - deprecationLogger.deprecate("terms_query_on_field_names", + deprecationLogger.deprecate(DeprecationCategory.MAPPINGS, "terms_query_on_field_names", "terms query on the _field_names field is deprecated and will be removed, use exists query instead"); return super.termQuery(value, context); } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/IdFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/IdFieldMapper.java index 5e6355cab45ab..1757b1514b913 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/IdFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/IdFieldMapper.java @@ -28,6 +28,7 @@ import org.apache.lucene.search.SortField; import org.apache.lucene.search.TermInSetQuery; import org.apache.lucene.util.BytesRef; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.util.BigArrays; @@ -164,7 +165,7 @@ public IndexFieldData build( IndexFieldDataCache cache, CircuitBreakerService breakerService ) { - deprecationLogger.deprecate("id_field_data", ID_FIELD_DATA_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.MAPPINGS, "id_field_data", ID_FIELD_DATA_DEPRECATION_MESSAGE); final IndexFieldData fieldData = fieldDataBuilder.build(cache, breakerService); return new IndexFieldData() { @Override diff --git a/server/src/main/java/org/elasticsearch/index/mapper/IpFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/IpFieldMapper.java index 267874c0c7185..aabae77ad1a23 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/IpFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/IpFieldMapper.java @@ -30,6 +30,7 @@ import org.elasticsearch.Version; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.collect.Tuple; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.network.InetAddresses; import org.elasticsearch.index.fielddata.IndexFieldData; @@ -98,7 +99,7 @@ private InetAddress parseNullValue() { try { return InetAddresses.forString(nullValueAsString); } catch (Exception e) { - DEPRECATION_LOGGER.deprecate("ip_mapper_null_field", "Error parsing [" + nullValue.getValue() + DEPRECATION_LOGGER.deprecate(DeprecationCategory.MAPPINGS, "ip_mapper_null_field", "Error parsing [" + nullValue.getValue() + "] as IP in [null_value] on field [" + name() + "]); [null_value] will be ignored"); return null; } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/MapperService.java b/server/src/main/java/org/elasticsearch/index/mapper/MapperService.java index 3f89f3680576e..7507cefa616be 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/MapperService.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/MapperService.java @@ -29,6 +29,7 @@ import org.elasticsearch.common.Nullable; import org.elasticsearch.common.Strings; import org.elasticsearch.common.compress.CompressedXContent; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting.Property; @@ -458,7 +459,7 @@ private synchronized Map internalMerge(@Nullable Documen if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { throw new IllegalArgumentException(DEFAULT_MAPPING_ERROR_MESSAGE); } else if (reason == MergeReason.MAPPING_UPDATE) { // only log in case of explicit mapping updates - deprecationLogger.deprecate("default_mapping_not_allowed", DEFAULT_MAPPING_ERROR_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.MAPPINGS, "default_mapping_not_allowed", DEFAULT_MAPPING_ERROR_MESSAGE); } assert defaultMapper.type().equals(DEFAULT_MAPPING); results.put(DEFAULT_MAPPING, defaultMapper); diff --git a/server/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java index fa697cf3c151d..5e0b711c2ec20 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/ObjectMapper.java @@ -19,17 +19,6 @@ package org.elasticsearch.index.mapper; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Map; - import org.apache.lucene.index.Term; import org.apache.lucene.search.Query; import org.apache.lucene.search.TermQuery; @@ -38,12 +27,24 @@ import org.elasticsearch.Version; import org.elasticsearch.common.Explicit; import org.elasticsearch.common.collect.CopyOnWriteHashMap; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.index.mapper.MapperService.MergeReason; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; + public class ObjectMapper extends Mapper implements Cloneable { private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(ObjectMapper.class); @@ -254,7 +255,7 @@ protected static boolean parseObjectOrDocumentTypeProperties(String fieldName, O } return true; } else if (fieldName.equals("include_in_all")) { - deprecationLogger.deprecate("include_in_all", + deprecationLogger.deprecate(DeprecationCategory.API, "include_in_all", "[include_in_all] is deprecated, the _all field have been removed in this version"); return true; } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/RootObjectMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/RootObjectMapper.java index dfe4b9891bd4c..5ba30ebbe027c 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/RootObjectMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/RootObjectMapper.java @@ -23,6 +23,7 @@ import org.elasticsearch.Version; import org.elasticsearch.common.Explicit; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.time.DateFormatter; import org.elasticsearch.common.xcontent.ToXContent; @@ -445,7 +446,7 @@ private static void validateDynamicTemplate(Mapper.TypeParser.ParserContext pars } else { deprecationMessage = message; } - DEPRECATION_LOGGER.deprecate("invalid_dynamic_template", deprecationMessage); + DEPRECATION_LOGGER.deprecate(DeprecationCategory.TEMPLATES, "invalid_dynamic_template", deprecationMessage); } } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/TypeFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/TypeFieldMapper.java index 4d13000b1ad7d..64cafc9ecfca2 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/TypeFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/TypeFieldMapper.java @@ -26,6 +26,7 @@ import org.apache.lucene.search.Query; import org.apache.lucene.util.BytesRef; import org.elasticsearch.common.geo.ShapeRelation; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.time.DateMathParser; @@ -48,7 +49,7 @@ public class TypeFieldMapper extends MetadataFieldMapper { "in queries and aggregations is deprecated, prefer to use a field instead."; public static void emitTypesDeprecationWarning() { - deprecationLogger.deprecate("query_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "query_with_types", TYPES_DEPRECATION_MESSAGE); } public static final String NAME = "_type"; diff --git a/server/src/main/java/org/elasticsearch/index/mapper/TypeFieldType.java b/server/src/main/java/org/elasticsearch/index/mapper/TypeFieldType.java index 471e916c2d808..9578396cb8b2d 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/TypeFieldType.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/TypeFieldType.java @@ -21,6 +21,7 @@ import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.Query; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.plain.ConstantIndexFieldData; @@ -65,13 +66,13 @@ public String typeName() { @Override public Query existsQuery(SearchExecutionContext context) { - deprecationLogger.deprecate("typefieldtype", TYPES_V7_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "typefieldtype", TYPES_V7_DEPRECATION_MESSAGE); return new MatchAllDocsQuery(); } @Override public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName, Supplier searchLookup) { - deprecationLogger.deprecate("typefieldtype", TYPES_V7_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "typefieldtype", TYPES_V7_DEPRECATION_MESSAGE); return new ConstantIndexFieldData.Builder(type, name(), CoreValuesSourceType.KEYWORD); } @@ -82,7 +83,7 @@ public ValueFetcher valueFetcher(SearchExecutionContext context, String format) @Override protected boolean matches(String pattern, boolean caseInsensitive, SearchExecutionContext context) { - deprecationLogger.deprecate("typefieldtype", TYPES_V7_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "typefieldtype", TYPES_V7_DEPRECATION_MESSAGE); if (caseInsensitive) { return pattern.equalsIgnoreCase(type); } diff --git a/server/src/main/java/org/elasticsearch/index/mapper/TypeParsers.java b/server/src/main/java/org/elasticsearch/index/mapper/TypeParsers.java index fbb62ac769d67..6d17dde254d20 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/TypeParsers.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/TypeParsers.java @@ -19,6 +19,7 @@ package org.elasticsearch.index.mapper; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.time.DateFormatter; import org.elasticsearch.index.similarity.SimilarityProvider; @@ -98,7 +99,8 @@ public static boolean parseMultiField(Consumer multiFieldsB Mapper.TypeParser.ParserContext parserContext, String propName, Object propNode) { if (propName.equals("fields")) { if (parserContext.isWithinMultiField()) { - deprecationLogger.deprecate("multifield_within_multifield", "At least one multi-field, [" + name + "], was " + + deprecationLogger.deprecate(DeprecationCategory.MAPPINGS, "multifield_within_multifield", + "At least one multi-field, [" + name + "], was " + "encountered that itself contains a multi-field. Defining multi-fields within a multi-field is deprecated and will " + "no longer be supported in 8.0. To resolve the issue, all instances of [fields] that occur within a [fields] block " + "should be removed from the mappings, either by flattening the chained [fields] blocks into a single level, or " + diff --git a/server/src/main/java/org/elasticsearch/index/query/GeoShapeQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/GeoShapeQueryBuilder.java index 2cb63e4eb3b8f..f1f529dd86085 100644 --- a/server/src/main/java/org/elasticsearch/index/query/GeoShapeQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/GeoShapeQueryBuilder.java @@ -30,6 +30,7 @@ import org.elasticsearch.common.geo.parsers.ShapeParser; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -253,7 +254,7 @@ public static GeoShapeQueryBuilder fromXContent(XContentParser parser) throws IO GeoShapeQueryBuilder builder; if (pgsqp.type != null) { - deprecationLogger.deprecate("geo_share_query_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "geo_share_query_with_types", TYPES_DEPRECATION_MESSAGE); } if (pgsqp.shape != null) { diff --git a/server/src/main/java/org/elasticsearch/index/query/IdsQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/IdsQueryBuilder.java index e5cf3359e6713..c522bb655a406 100644 --- a/server/src/main/java/org/elasticsearch/index/query/IdsQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/IdsQueryBuilder.java @@ -27,6 +27,7 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.ObjectParser; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -151,7 +152,7 @@ public static IdsQueryBuilder fromXContent(XContentParser parser) { try { IdsQueryBuilder builder = PARSER.apply(parser, null); if (builder.types().length > 0) { - deprecationLogger.deprecate("ids_query_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "ids_query_with_types", TYPES_DEPRECATION_MESSAGE); } return builder; } catch (IllegalArgumentException e) { diff --git a/server/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java index a80f5abb4bf2a..22f0ffbaf1259 100644 --- a/server/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java @@ -41,6 +41,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.lucene.search.MoreLikeThisQuery; import org.elasticsearch.common.lucene.search.XMoreLikeThis; @@ -967,7 +968,7 @@ public static MoreLikeThisQueryBuilder fromXContent(XContentParser parser) throw } if (moreLikeThisQueryBuilder.isTypeless() == false) { - deprecationLogger.deprecate("more_like_this_query_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.API, "more_like_this_query_with_types", TYPES_DEPRECATION_MESSAGE); } return moreLikeThisQueryBuilder; } diff --git a/server/src/main/java/org/elasticsearch/index/query/SearchExecutionContext.java b/server/src/main/java/org/elasticsearch/index/query/SearchExecutionContext.java index 1b7ec0522d7e3..9c3f95f051321 100644 --- a/server/src/main/java/org/elasticsearch/index/query/SearchExecutionContext.java +++ b/server/src/main/java/org/elasticsearch/index/query/SearchExecutionContext.java @@ -35,6 +35,7 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.TriFunction; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.lucene.search.Queries; import org.elasticsearch.common.regex.Regex; @@ -389,7 +390,7 @@ public DocumentMapper documentMapper(String type) { */ public MappedFieldType buildAnonymousFieldType(String type) { if (type.equals("string")) { - deprecationLogger.deprecate("unmapped_type_string", + deprecationLogger.deprecate(DeprecationCategory.MAPPINGS, "unmapped_type_string", "[unmapped_type:string] should be replaced with [unmapped_type:keyword]"); type = "keyword"; } diff --git a/server/src/main/java/org/elasticsearch/index/query/TypeQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/TypeQueryBuilder.java index ea892da26f165..b05dabecd8965 100644 --- a/server/src/main/java/org/elasticsearch/index/query/TypeQueryBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/TypeQueryBuilder.java @@ -27,6 +27,7 @@ import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.lucene.search.Queries; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -128,7 +129,7 @@ public String getWriteableName() { @Override protected Query doToQuery(SearchExecutionContext context) throws IOException { - deprecationLogger.deprecate("type_query", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "type_query", TYPES_DEPRECATION_MESSAGE); if (context.getType().equals(type)) { return Queries.newNonNestedFilter(context.indexVersionCreated()); } else { diff --git a/server/src/main/java/org/elasticsearch/index/query/functionscore/RandomScoreFunctionBuilder.java b/server/src/main/java/org/elasticsearch/index/query/functionscore/RandomScoreFunctionBuilder.java index 879d15c46cf74..96ada87ae358b 100644 --- a/server/src/main/java/org/elasticsearch/index/query/functionscore/RandomScoreFunctionBuilder.java +++ b/server/src/main/java/org/elasticsearch/index/query/functionscore/RandomScoreFunctionBuilder.java @@ -22,6 +22,7 @@ import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.lucene.search.function.RandomScoreFunction; import org.elasticsearch.common.lucene.search.function.ScoreFunction; @@ -162,7 +163,7 @@ protected ScoreFunction doToFunction(SearchExecutionContext context) { } else { String fieldName; if (field == null) { - deprecationLogger.deprecate("seed_requires_field", + deprecationLogger.deprecate(DeprecationCategory.QUERIES, "seed_requires_field", "As of version 7.0 Elasticsearch will require that a [field] parameter is provided when a [seed] is set"); fieldName = IdFieldMapper.NAME; } else { diff --git a/server/src/main/java/org/elasticsearch/index/reindex/ReindexRequest.java b/server/src/main/java/org/elasticsearch/index/reindex/ReindexRequest.java index 75c410d5f9c08..c29a92e479943 100644 --- a/server/src/main/java/org/elasticsearch/index/reindex/ReindexRequest.java +++ b/server/src/main/java/org/elasticsearch/index/reindex/ReindexRequest.java @@ -28,6 +28,7 @@ import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.lucene.uid.Versions; import org.elasticsearch.common.unit.TimeValue; @@ -373,7 +374,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws } String[] types = extractStringArray(source, "type"); if (types != null) { - deprecationLogger.deprecate("reindex_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "reindex_with_types", TYPES_DEPRECATION_MESSAGE); request.getSearchRequest().types(types); } request.setRemoteInfo(buildRemoteInfo(source)); @@ -389,7 +390,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws ObjectParser destParser = new ObjectParser<>("dest"); destParser.declareString(IndexRequest::index, new ParseField("index")); destParser.declareString((request, type) -> { - deprecationLogger.deprecate("reindex_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "reindex_with_types", TYPES_DEPRECATION_MESSAGE); request.type(type); }, new ParseField("type")); destParser.declareString(IndexRequest::routing, new ParseField("routing")); diff --git a/server/src/main/java/org/elasticsearch/index/similarity/SimilarityProviders.java b/server/src/main/java/org/elasticsearch/index/similarity/SimilarityProviders.java index bc7ef5c89f04f..c4f739fa8f428 100644 --- a/server/src/main/java/org/elasticsearch/index/similarity/SimilarityProviders.java +++ b/server/src/main/java/org/elasticsearch/index/similarity/SimilarityProviders.java @@ -51,6 +51,7 @@ import org.apache.lucene.search.similarities.NormalizationZ; import org.apache.lucene.search.similarity.LegacyBM25Similarity; import org.elasticsearch.Version; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; @@ -142,8 +143,9 @@ private static BasicModel parseBasicModel(Version indexCreatedVersion, Settings throw new IllegalArgumentException("Basic model [" + basicModel + "] isn't supported anymore, " + "please use another model."); } else { - deprecationLogger.deprecate(basicModel + "_similarity_model_replaced", "Basic model [" + basicModel + - "] isn't supported anymore and has arbitrarily been replaced with [" + replacement + "]."); + deprecationLogger.deprecate(DeprecationCategory.QUERIES, basicModel + "_similarity_model_replaced", + "Basic model [" + basicModel + "] isn't supported anymore and has arbitrarily been replaced with [" + + replacement + "]."); model = BASIC_MODELS.get(replacement); assert model != null; } @@ -173,8 +175,9 @@ private static AfterEffect parseAfterEffect(Version indexCreatedVersion, Setting throw new IllegalArgumentException("After effect [" + afterEffect + "] isn't supported anymore, please use another effect."); } else { - deprecationLogger.deprecate(afterEffect + "_after_effect_replaced", "After effect [" + afterEffect + - "] isn't supported anymore and has arbitrarily been replaced with [" + replacement + "]."); + deprecationLogger.deprecate(DeprecationCategory.QUERIES, afterEffect + "_after_effect_replaced", + "After effect [" + afterEffect + "] isn't supported anymore and has arbitrarily been replaced with [" + + replacement + "]."); effect = AFTER_EFFECTS.get(replacement); assert effect != null; } @@ -263,7 +266,7 @@ static void assertSettingsIsSubsetOf(String type, Version version, Settings sett if (version.onOrAfter(Version.V_7_0_0)) { throw new IllegalArgumentException("Unknown settings for similarity of type [" + type + "]: " + unknownSettings); } else { - deprecationLogger.deprecate("unknown_similarity_setting", + deprecationLogger.deprecate(DeprecationCategory.QUERIES, "unknown_similarity_setting", "Unknown settings for similarity of type [" + type + "]: " + unknownSettings); } } diff --git a/server/src/main/java/org/elasticsearch/index/similarity/SimilarityService.java b/server/src/main/java/org/elasticsearch/index/similarity/SimilarityService.java index 38a4a4b6e182a..b43dba5ac7422 100644 --- a/server/src/main/java/org/elasticsearch/index/similarity/SimilarityService.java +++ b/server/src/main/java/org/elasticsearch/index/similarity/SimilarityService.java @@ -34,6 +34,7 @@ import org.elasticsearch.Version; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.TriFunction; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.AbstractIndexComponent; @@ -66,7 +67,7 @@ public final class SimilarityService extends AbstractIndexComponent { } else { final ClassicSimilarity similarity = SimilarityProviders.createClassicSimilarity(Settings.EMPTY, version); return () -> { - deprecationLogger.deprecate("classic_similarity", + deprecationLogger.deprecate(DeprecationCategory.QUERIES, "classic_similarity", "The [classic] similarity is now deprecated in favour of BM25, which is generally " + "accepted as a better alternative. Use the [BM25] similarity or build a custom [scripted] similarity " + "instead."); @@ -90,7 +91,7 @@ public final class SimilarityService extends AbstractIndexComponent { throw new IllegalArgumentException("The [classic] similarity may not be used anymore. Please use the [BM25] " + "similarity or build a custom [scripted] similarity instead."); } else { - deprecationLogger.deprecate("classic_similarity", + deprecationLogger.deprecate(DeprecationCategory.QUERIES, "classic_similarity", "The [classic] similarity is now deprecated in favour of BM25, which is generally " + "accepted as a better alternative. Use the [BM25] similarity or build a custom [scripted] similarity " + "instead."); @@ -155,7 +156,7 @@ public SimilarityService(IndexSettings indexSettings, ScriptService scriptServic defaultSimilarity = (providers.get("default") != null) ? providers.get("default").get() : providers.get(SimilarityService.DEFAULT_SIMILARITY).get(); if (providers.get("base") != null) { - deprecationLogger.deprecate("base_similarity_ignored", + deprecationLogger.deprecate(DeprecationCategory.QUERIES, "base_similarity_ignored", "The [base] similarity is ignored since query normalization and coords have been removed"); } } @@ -272,7 +273,7 @@ private static void fail(Version indexCreatedVersion, String message) { if (indexCreatedVersion.onOrAfter(Version.V_7_0_0)) { throw new IllegalArgumentException(message); } else if (indexCreatedVersion.onOrAfter(Version.V_6_5_0)) { - deprecationLogger.deprecate("similarity_failure", message); + deprecationLogger.deprecate(DeprecationCategory.QUERIES, "similarity_failure", message); } } diff --git a/server/src/main/java/org/elasticsearch/indices/analysis/AnalysisModule.java b/server/src/main/java/org/elasticsearch/indices/analysis/AnalysisModule.java index c3b5bbf7d0c13..1b06facffc8af 100644 --- a/server/src/main/java/org/elasticsearch/indices/analysis/AnalysisModule.java +++ b/server/src/main/java/org/elasticsearch/indices/analysis/AnalysisModule.java @@ -24,6 +24,7 @@ import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.NamedRegistry; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; @@ -124,7 +125,7 @@ private NamedRegistry> setupTokenFilters(Li @Override public TokenFilterFactory get(IndexSettings indexSettings, Environment environment, String name, Settings settings) { if (indexSettings.getIndexVersionCreated().before(Version.V_7_0_0)) { - deprecationLogger.deprecate("standard_deprecation", + deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "standard_deprecation", "The [standard] token filter name is deprecated and will be removed in a future version."); } else { throw new IllegalArgumentException("The [standard] token filter has been removed."); @@ -185,7 +186,7 @@ static Map setupPreConfiguredTokenFilters(List // in certain circumstances to create a new index referencing the standard token filter // until version 7_5_2 if (version.before(Version.V_7_6_0)) { - deprecationLogger.deprecate("standard_deprecation", + deprecationLogger.deprecate(DeprecationCategory.ANALYSIS, "standard_deprecation", "The [standard] token filter is deprecated and will be removed in a future version."); } else { throw new IllegalArgumentException("The [standard] token filter has been removed."); diff --git a/server/src/main/java/org/elasticsearch/indices/flush/SyncedFlushService.java b/server/src/main/java/org/elasticsearch/indices/flush/SyncedFlushService.java index 535094609f48e..b813e6df9d957 100644 --- a/server/src/main/java/org/elasticsearch/indices/flush/SyncedFlushService.java +++ b/server/src/main/java/org/elasticsearch/indices/flush/SyncedFlushService.java @@ -41,6 +41,7 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.util.concurrent.AbstractRunnable; import org.elasticsearch.common.util.concurrent.ConcurrentCollections; @@ -160,7 +161,7 @@ public void attemptSyncedFlush(final String[] aliasesOrIndices, final ActionListener listener) { final ClusterState state = clusterService.state(); if (state.nodes().getMinNodeVersion().onOrAfter(Version.V_7_6_0)) { - DEPRECATION_LOGGER.deprecate("synced_flush", SYNCED_FLUSH_DEPRECATION_MESSAGE); + DEPRECATION_LOGGER.deprecate(DeprecationCategory.API, "synced_flush", SYNCED_FLUSH_DEPRECATION_MESSAGE); } final Index[] concreteIndices = indexNameExpressionResolver.concreteIndices(state, indicesOptions, aliasesOrIndices); final Map> results = ConcurrentCollections.newConcurrentMap(); diff --git a/server/src/main/java/org/elasticsearch/ingest/ConditionalProcessor.java b/server/src/main/java/org/elasticsearch/ingest/ConditionalProcessor.java index 6921f14d8a4cc..95f524a921745 100644 --- a/server/src/main/java/org/elasticsearch/ingest/ConditionalProcessor.java +++ b/server/src/main/java/org/elasticsearch/ingest/ConditionalProcessor.java @@ -19,6 +19,7 @@ package org.elasticsearch.ingest; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.script.DynamicMap; import org.elasticsearch.script.IngestConditionalScript; @@ -48,7 +49,7 @@ public class ConditionalProcessor extends AbstractProcessor implements WrappingP private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); private static final Map> FUNCTIONS = org.elasticsearch.common.collect.Map.of( "_type", value -> { - deprecationLogger.deprecate("conditional-processor__type", + deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "conditional-processor__type", "[types removal] Looking up doc types [_type] in scripts is deprecated."); return value; }); diff --git a/server/src/main/java/org/elasticsearch/node/Node.java b/server/src/main/java/org/elasticsearch/node/Node.java index b3de250d9eed9..f90254b8136ac 100644 --- a/server/src/main/java/org/elasticsearch/node/Node.java +++ b/server/src/main/java/org/elasticsearch/node/Node.java @@ -72,6 +72,7 @@ import org.elasticsearch.common.inject.ModulesBuilder; import org.elasticsearch.common.io.stream.NamedWriteableRegistry; import org.elasticsearch.common.lease.Releasables; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.logging.HeaderWarning; import org.elasticsearch.common.logging.NodeAndClusterIdStateListener; @@ -326,6 +327,7 @@ protected Node(final Environment initialEnvironment, } else { logger.info("JVM home [{}]", System.getProperty("java.home")); deprecationLogger.deprecate( + DeprecationCategory.OTHER, "no-jdk", "no-jdk distributions that do not bundle a JDK are deprecated and will be removed in a future release"); } diff --git a/server/src/main/java/org/elasticsearch/rest/DeprecationRestHandler.java b/server/src/main/java/org/elasticsearch/rest/DeprecationRestHandler.java index 0581c77b32da8..02cc3e7e4f6ad 100644 --- a/server/src/main/java/org/elasticsearch/rest/DeprecationRestHandler.java +++ b/server/src/main/java/org/elasticsearch/rest/DeprecationRestHandler.java @@ -20,6 +20,7 @@ import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import java.util.Objects; @@ -57,7 +58,7 @@ public DeprecationRestHandler(RestHandler handler, String deprecationMessage, De */ @Override public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception { - deprecationLogger.deprecate("deprecated_route", deprecationMessage); + deprecationLogger.deprecate(DeprecationCategory.API, "deprecated_route", deprecationMessage); handler.handleRequest(request, channel, client); } diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestCloseIndexAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestCloseIndexAction.java index 763b7e1d91f9b..a78c78f7485af 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestCloseIndexAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestCloseIndexAction.java @@ -24,6 +24,7 @@ import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; @@ -64,7 +65,8 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC closeIndexRequest.indicesOptions(IndicesOptions.fromRequest(request, closeIndexRequest.indicesOptions())); String waitForActiveShards = request.param("wait_for_active_shards"); if (waitForActiveShards == null) { - deprecationLogger.deprecate("close-index-wait_for_active_shards-default", WAIT_FOR_ACTIVE_SHARDS_DEFAULT_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.API, "close-index-wait_for_active_shards-default", + WAIT_FOR_ACTIVE_SHARDS_DEFAULT_DEPRECATION_MESSAGE); } else if ("index-setting".equalsIgnoreCase(waitForActiveShards)) { closeIndexRequest.waitForActiveShards(ActiveShardCount.DEFAULT); } else { diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestCreateIndexAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestCreateIndexAction.java index 80cbbe86c53d7..108553620df84 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestCreateIndexAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestCreateIndexAction.java @@ -22,6 +22,7 @@ import org.elasticsearch.action.admin.indices.create.CreateIndexRequest; import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.client.node.NodeClient; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.XContentHelper; @@ -60,7 +61,7 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC DEFAULT_INCLUDE_TYPE_NAME_POLICY); if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER)) { - deprecationLogger.deprecate("create_index_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "create_index_with_types", TYPES_DEPRECATION_MESSAGE); } CreateIndexRequest createIndexRequest = new CreateIndexRequest(request.param("index")); diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestForceMergeAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestForceMergeAction.java index fce4518183aa5..171220af85630 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestForceMergeAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestForceMergeAction.java @@ -23,6 +23,7 @@ import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; @@ -59,7 +60,7 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC mergeRequest.onlyExpungeDeletes(request.paramAsBoolean("only_expunge_deletes", mergeRequest.onlyExpungeDeletes())); mergeRequest.flush(request.paramAsBoolean("flush", mergeRequest.flush())); if (mergeRequest.onlyExpungeDeletes() && mergeRequest.maxNumSegments() != ForceMergeRequest.Defaults.MAX_NUM_SEGMENTS) { - deprecationLogger.deprecate("force_merge_expunge_deletes_and_max_num_segments_deprecation", + deprecationLogger.deprecate(DeprecationCategory.API, "force_merge_expunge_deletes_and_max_num_segments_deprecation", "setting only_expunge_deletes and max_num_segments at the same time is deprecated and will be rejected in a future version"); } return channel -> client.admin().indices().forceMerge(mergeRequest, new RestToXContentListener<>(channel)); diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetFieldMappingAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetFieldMappingAction.java index 1e06c38443b47..c419c186f0a7a 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetFieldMappingAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetFieldMappingAction.java @@ -27,6 +27,7 @@ import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.rest.BaseRestHandler; @@ -80,7 +81,7 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC " is set to true."); } if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER)) { - deprecationLogger.deprecate("get_field_mapping_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "get_field_mapping_with_types", TYPES_DEPRECATION_MESSAGE); } GetFieldMappingsRequest getMappingsRequest = new GetFieldMappingsRequest(); @@ -88,7 +89,7 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC getMappingsRequest.indicesOptions(IndicesOptions.fromRequest(request, getMappingsRequest.indicesOptions())); if (request.hasParam("local")) { - deprecationLogger.deprecate("get_field_mapping_local", + deprecationLogger.deprecate(DeprecationCategory.API, "get_field_mapping_local", "Use [local] in get field mapping requests is deprecated. " + "The parameter will be removed in the next major version"); } diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndexTemplateAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndexTemplateAction.java index ab4fdc0d4d5b5..4eb5c24e754bf 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndexTemplateAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndexTemplateAction.java @@ -23,6 +23,7 @@ import org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.set.Sets; @@ -73,7 +74,7 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC final GetIndexTemplatesRequest getIndexTemplatesRequest = new GetIndexTemplatesRequest(names); if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER)) { - deprecationLogger.deprecate("get_index_template_include_type_name", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "get_index_template_include_type_name", TYPES_DEPRECATION_MESSAGE); } getIndexTemplatesRequest.local(request.paramAsBoolean("local", getIndexTemplatesRequest.local())); getIndexTemplatesRequest.masterNodeTimeout(request.paramAsTime("master_timeout", getIndexTemplatesRequest.masterNodeTimeout())); diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndicesAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndicesAction.java index 8b370a0a9cd11..65d785806f8b7 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndicesAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetIndicesAction.java @@ -24,6 +24,7 @@ import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.rest.BaseRestHandler; @@ -72,7 +73,7 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC String[] indices = Strings.splitStringByCommaToArray(request.param("index")); // starting with 7.0 we don't include types by default in the response to GET requests if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER) && request.method().equals(GET)) { - deprecationLogger.deprecate("get_indices_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "get_indices_with_types", TYPES_DEPRECATION_MESSAGE); } final GetIndexRequest getIndexRequest = new GetIndexRequest(); getIndexRequest.indices(indices); diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetMappingAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetMappingAction.java index 847a52ec5e137..74638596607fa 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetMappingAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestGetMappingAction.java @@ -32,6 +32,7 @@ import org.elasticsearch.cluster.metadata.MappingMetadata; import org.elasticsearch.common.Strings; import org.elasticsearch.common.collect.ImmutableOpenMap; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.util.set.Sets; @@ -100,14 +101,14 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, DEFAULT_INCLUDE_TYPE_NAME_POLICY); if (request.method().equals(HEAD)) { - deprecationLogger.deprecate("get_mapping_types_removal", + deprecationLogger.deprecate(DeprecationCategory.TYPES, "get_mapping_types_removal", "Type exists requests are deprecated, as types have been deprecated."); } else if (includeTypeName == false && types.length > 0) { throw new IllegalArgumentException("Types cannot be provided in get mapping requests, unless" + " include_type_name is set to true."); } if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER)) { - deprecationLogger.deprecate("get_mapping_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "get_mapping_with_types", TYPES_DEPRECATION_MESSAGE); } final GetMappingsRequest getMappingsRequest = new GetMappingsRequest(); diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutIndexTemplateAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutIndexTemplateAction.java index 2b7bfa0044786..50bd630a2a15d 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutIndexTemplateAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutIndexTemplateAction.java @@ -22,6 +22,7 @@ import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.rest.BaseRestHandler; @@ -64,10 +65,10 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC PutIndexTemplateRequest putRequest = new PutIndexTemplateRequest(request.param("name")); if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER)) { - deprecationLogger.deprecate("put_index_template_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "put_index_template_with_types", TYPES_DEPRECATION_MESSAGE); } if (request.hasParam("template")) { - deprecationLogger.deprecate("put_index_template_deprecated_parameter", + deprecationLogger.deprecate(DeprecationCategory.API, "put_index_template_deprecated_parameter", "Deprecated parameter [template] used, replaced by [index_patterns]"); putRequest.patterns(Collections.singletonList(request.param("template"))); } else { diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutMappingAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutMappingAction.java index a41cd549de942..2769249638096 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutMappingAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestPutMappingAction.java @@ -23,6 +23,7 @@ import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.index.mapper.MapperService; @@ -77,7 +78,7 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC final boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, DEFAULT_INCLUDE_TYPE_NAME_POLICY); if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER)) { - deprecationLogger.deprecate("put_mapping_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "put_mapping_with_types", TYPES_DEPRECATION_MESSAGE); } PutMappingRequest putMappingRequest = putMappingRequest(Strings.splitStringByCommaToArray(request.param("index"))); diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestResizeHandler.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestResizeHandler.java index 5c738d8f2dd1f..194367108ecfb 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestResizeHandler.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestResizeHandler.java @@ -27,6 +27,7 @@ import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Booleans; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; @@ -71,7 +72,7 @@ public final RestChannelConsumer prepareRequest(final RestRequest request, final throw new IllegalArgumentException("parameter [copy_settings] can not be explicitly set to [false]"); } } - deprecationLogger.deprecate("resize_deprecated_parameter", + deprecationLogger.deprecate(DeprecationCategory.API, "resize_deprecated_parameter", "parameter [copy_settings] is deprecated and will be removed in 8.0.0"); } resizeRequest.setCopySettings(copySettings); diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestRolloverIndexAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestRolloverIndexAction.java index bd64fb4a8752e..2c4c2fdc8618a 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestRolloverIndexAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestRolloverIndexAction.java @@ -22,6 +22,7 @@ import org.elasticsearch.action.admin.indices.rollover.RolloverRequest; import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.client.node.NodeClient; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.RestRequest; @@ -56,7 +57,7 @@ public String getName() { public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { final boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER, DEFAULT_INCLUDE_TYPE_NAME_POLICY); if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER)) { - deprecationLogger.deprecate("index_rollover_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "index_rollover_with_types", TYPES_DEPRECATION_MESSAGE); } RolloverRequest rolloverIndexRequest = new RolloverRequest(request.param("index"), request.param("new_index")); request.applyContentParser(parser -> rolloverIndexRequest.fromXContent(includeTypeName, parser)); diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestValidateQueryAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestValidateQueryAction.java index 25e2cf85ac8a0..43b94bde4b53f 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestValidateQueryAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/indices/RestValidateQueryAction.java @@ -26,6 +26,7 @@ import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.rest.BaseRestHandler; @@ -72,7 +73,7 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC validateQueryRequest.explain(request.paramAsBoolean("explain", false)); if (request.hasParam("type")) { - deprecationLogger.deprecate("validate_query_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "validate_query_with_types", TYPES_DEPRECATION_MESSAGE); validateQueryRequest.types(Strings.splitStringByCommaToArray(request.param("type"))); } diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java index d5406318ce58a..d357a92c6520b 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java @@ -39,6 +39,7 @@ import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.Strings; import org.elasticsearch.common.Table; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.time.DateFormatter; @@ -101,7 +102,7 @@ public RestChannelConsumer doCatRequest(final RestRequest request, final NodeCli final String[] indices = Strings.splitStringByCommaToArray(request.param("index")); final IndicesOptions indicesOptions = IndicesOptions.fromRequest(request, IndicesOptions.strictExpand()); if (request.hasParam("local")) { - DEPRECATION_LOGGER.deprecate("local", LOCAL_DEPRECATED_MESSAGE); + DEPRECATION_LOGGER.deprecate(DeprecationCategory.API, "local", LOCAL_DEPRECATED_MESSAGE); } final boolean local = request.paramAsBoolean("local", false); final TimeValue masterNodeTimeout = request.paramAsTime("master_timeout", DEFAULT_MASTER_NODE_TIMEOUT); diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java index fd0114a47315d..6c5e3349a5004 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestNodesAction.java @@ -33,6 +33,7 @@ import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.common.Strings; import org.elasticsearch.common.Table; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.network.NetworkAddress; import org.elasticsearch.common.transport.TransportAddress; @@ -94,7 +95,7 @@ public RestChannelConsumer doCatRequest(final RestRequest request, final NodeCli final ClusterStateRequest clusterStateRequest = new ClusterStateRequest(); clusterStateRequest.clear().nodes(true); if (request.hasParam("local")) { - deprecationLogger.deprecate("cat_nodes_local_parameter", LOCAL_DEPRECATED_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.API, "cat_nodes_local_parameter", LOCAL_DEPRECATED_MESSAGE); } clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local())); clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout())); diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestShardsAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestShardsAction.java index d01b1d370186a..d8b2360073bf8 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestShardsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestShardsAction.java @@ -30,6 +30,7 @@ import org.elasticsearch.cluster.routing.UnassignedInfo; import org.elasticsearch.common.Strings; import org.elasticsearch.common.Table; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.index.cache.query.QueryCacheStats; @@ -92,7 +93,7 @@ public RestChannelConsumer doCatRequest(final RestRequest request, final NodeCli final String[] indices = Strings.splitStringByCommaToArray(request.param("index")); final ClusterStateRequest clusterStateRequest = new ClusterStateRequest(); if (request.hasParam("local")) { - DEPRECATION_LOGGER.deprecate("local", LOCAL_DEPRECATED_MESSAGE); + DEPRECATION_LOGGER.deprecate(DeprecationCategory.API, "local", LOCAL_DEPRECATED_MESSAGE); } clusterStateRequest.local(request.paramAsBoolean("local", clusterStateRequest.local())); clusterStateRequest.masterNodeTimeout(request.paramAsTime("master_timeout", clusterStateRequest.masterNodeTimeout())); diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestBulkAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestBulkAction.java index 3ce8b84ffa2a0..4da2e2a5d40a4 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestBulkAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestBulkAction.java @@ -25,6 +25,7 @@ import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.client.Requests; import org.elasticsearch.client.node.NodeClient; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.mapper.MapperService; @@ -87,7 +88,7 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC if (defaultType == null) { defaultType = MapperService.SINGLE_MAPPING_NAME; } else { - deprecationLogger.deprecate("bulk_with_types", RestBulkAction.TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "bulk_with_types", RestBulkAction.TYPES_DEPRECATION_MESSAGE); } String defaultRouting = request.param("routing"); FetchSourceContext defaultFetchSourceContext = FetchSourceContext.parseFromRestRequest(request); diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestDeleteAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestDeleteAction.java index c609bb6c68b34..71df2566e1171 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestDeleteAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestDeleteAction.java @@ -22,6 +22,7 @@ import org.elasticsearch.action.delete.DeleteRequest; import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.client.node.NodeClient; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.index.VersionType; import org.elasticsearch.rest.BaseRestHandler; @@ -58,7 +59,7 @@ public String getName() { public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { DeleteRequest deleteRequest; if (request.hasParam("type")) { - deprecationLogger.deprecate("delete_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "delete_with_types", TYPES_DEPRECATION_MESSAGE); deleteRequest = new DeleteRequest(request.param("index"), request.param("type"), request.param("id")); } else { deleteRequest = new DeleteRequest(request.param("index"), request.param("id")); diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestGetAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestGetAction.java index ea8271c702dd8..26276ba7f7ccd 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestGetAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestGetAction.java @@ -23,6 +23,7 @@ import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.index.VersionType; import org.elasticsearch.rest.BaseRestHandler; @@ -66,7 +67,7 @@ public List routes() { public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { GetRequest getRequest; if (request.hasParam("type")) { - deprecationLogger.deprecate("get_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "get_with_types", TYPES_DEPRECATION_MESSAGE); getRequest = new GetRequest(request.param("index"), request.param("type"), request.param("id")); } else { getRequest = new GetRequest(request.param("index"), request.param("id")); diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestGetSourceAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestGetSourceAction.java index cfe43b331702a..f7186616bcea7 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestGetSourceAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestGetSourceAction.java @@ -25,6 +25,7 @@ import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.bytes.BytesReference; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentHelper; @@ -73,7 +74,7 @@ public String getName() { public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { final GetRequest getRequest; if (request.hasParam("type")) { - deprecationLogger.deprecate("get_source_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "get_source_with_types", TYPES_DEPRECATION_MESSAGE); getRequest = new GetRequest(request.param("index"), request.param("type"), request.param("id")); } else { getRequest = new GetRequest(request.param("index"), request.param("id")); diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java index 3494397689f1d..ffd5dba54e742 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java @@ -25,6 +25,7 @@ import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.node.DiscoveryNodes; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.index.VersionType; import org.elasticsearch.index.mapper.MapperService; @@ -129,7 +130,7 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC IndexRequest indexRequest; final String type = request.param("type"); if (type != null && type.equals(MapperService.SINGLE_MAPPING_NAME) == false) { - deprecationLogger.deprecate("index_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "index_with_types", TYPES_DEPRECATION_MESSAGE); indexRequest = new IndexRequest(request.param("index"), type, request.param("id")); } else { indexRequest = new IndexRequest(request.param("index")); diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestMultiGetAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestMultiGetAction.java index f7e88cf0084a6..223345ca2f39b 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestMultiGetAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestMultiGetAction.java @@ -22,6 +22,7 @@ import org.elasticsearch.action.get.MultiGetRequest; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentParser; @@ -69,7 +70,7 @@ public String getName() { @Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { if (request.param("type") != null) { - deprecationLogger.deprecate("mget_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "mget_with_types", TYPES_DEPRECATION_MESSAGE); } MultiGetRequest multiGetRequest = new MultiGetRequest(); @@ -94,7 +95,7 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC for (MultiGetRequest.Item item : multiGetRequest.getItems()) { if (item.type() != null) { - deprecationLogger.deprecate("multi_get_types_removal", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "multi_get_types_removal", TYPES_DEPRECATION_MESSAGE); break; } } diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestMultiTermVectorsAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestMultiTermVectorsAction.java index febba260c654f..7eb369cd17076 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestMultiTermVectorsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestMultiTermVectorsAction.java @@ -23,6 +23,7 @@ import org.elasticsearch.action.termvectors.TermVectorsRequest; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.rest.BaseRestHandler; @@ -66,7 +67,7 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC .index(request.param("index")); if (request.hasParam("type")) { - deprecationLogger.deprecate("mtermvectors_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "mtermvectors_with_types", TYPES_DEPRECATION_MESSAGE); template.type(request.param("type")); } else { template.type(MapperService.SINGLE_MAPPING_NAME); diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestTermVectorsAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestTermVectorsAction.java index 7725583f79c19..cd01f5b7c63a2 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestTermVectorsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestTermVectorsAction.java @@ -22,6 +22,7 @@ import org.elasticsearch.action.termvectors.TermVectorsRequest; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.VersionType; @@ -73,7 +74,7 @@ public String getName() { public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { TermVectorsRequest termVectorsRequest; if (request.hasParam("type")) { - deprecationLogger.deprecate("termvectors_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "termvectors_with_types", TYPES_DEPRECATION_MESSAGE); termVectorsRequest = new TermVectorsRequest(request.param("index"), request.param("type"), request.param("id")); diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestUpdateAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestUpdateAction.java index e9a59887f6c58..e8d82a4dfdffd 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestUpdateAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestUpdateAction.java @@ -25,6 +25,7 @@ import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.action.update.UpdateRequest; import org.elasticsearch.client.node.NodeClient; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.index.VersionType; import org.elasticsearch.rest.BaseRestHandler; @@ -63,7 +64,7 @@ public String getName() { public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { UpdateRequest updateRequest; if (request.hasParam("type")) { - deprecationLogger.deprecate("update_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "update_with_types", TYPES_DEPRECATION_MESSAGE); updateRequest = new UpdateRequest(request.param("index"), request.param("type"), request.param("id")); diff --git a/server/src/main/java/org/elasticsearch/rest/action/search/RestCountAction.java b/server/src/main/java/org/elasticsearch/rest/action/search/RestCountAction.java index 6f4f6c07b53f7..a1db5f62dac2f 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/search/RestCountAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/search/RestCountAction.java @@ -24,6 +24,7 @@ import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.index.query.QueryBuilder; @@ -90,7 +91,7 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC } if (request.hasParam("type")) { - deprecationLogger.deprecate("count_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "count_with_types", TYPES_DEPRECATION_MESSAGE); countRequest.types(Strings.splitStringByCommaToArray(request.param("type"))); } diff --git a/server/src/main/java/org/elasticsearch/rest/action/search/RestExplainAction.java b/server/src/main/java/org/elasticsearch/rest/action/search/RestExplainAction.java index ca5b16253f861..c1aeb26d7e3f4 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/search/RestExplainAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/search/RestExplainAction.java @@ -22,6 +22,7 @@ import org.elasticsearch.action.explain.ExplainRequest; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.rest.BaseRestHandler; @@ -65,7 +66,7 @@ public String getName() { public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { ExplainRequest explainRequest; if (request.hasParam("type")) { - deprecationLogger.deprecate("explain_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "explain_with_types", TYPES_DEPRECATION_MESSAGE); explainRequest = new ExplainRequest(request.param("index"), request.param("type"), request.param("id")); diff --git a/server/src/main/java/org/elasticsearch/rest/action/search/RestMultiSearchAction.java b/server/src/main/java/org/elasticsearch/rest/action/search/RestMultiSearchAction.java index abddc9ba4919d..b9091bb783a35 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/search/RestMultiSearchAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/search/RestMultiSearchAction.java @@ -28,6 +28,7 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.collect.Tuple; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContent; @@ -95,7 +96,7 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC // Emit a single deprecation message if any search request contains types. for (SearchRequest searchRequest : multiSearchRequest.requests()) { if (searchRequest.types().length > 0) { - deprecationLogger.deprecate("msearch_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "msearch_with_types", TYPES_DEPRECATION_MESSAGE); break; } } diff --git a/server/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java b/server/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java index 9c70c0908eec7..66da732beeb33 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/search/RestSearchAction.java @@ -30,6 +30,7 @@ import org.elasticsearch.common.Booleans; 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.xcontent.XContentParser; import org.elasticsearch.index.query.QueryBuilder; @@ -186,7 +187,7 @@ public static void parseSearchRequest(SearchRequest searchRequest, RestRequest r } if (request.hasParam("type")) { - deprecationLogger.deprecate("search_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "search_with_types", TYPES_DEPRECATION_MESSAGE); searchRequest.types(Strings.splitStringByCommaToArray(request.param("type"))); } searchRequest.routing(request.param("routing")); diff --git a/server/src/main/java/org/elasticsearch/script/AbstractSortScript.java b/server/src/main/java/org/elasticsearch/script/AbstractSortScript.java index c5b88ac0eefc3..cba88a48c6083 100644 --- a/server/src/main/java/org/elasticsearch/script/AbstractSortScript.java +++ b/server/src/main/java/org/elasticsearch/script/AbstractSortScript.java @@ -21,6 +21,7 @@ import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.search.Scorable; import org.elasticsearch.ElasticsearchException; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.lucene.ScorerAware; import org.elasticsearch.index.fielddata.ScriptDocValues; @@ -38,13 +39,13 @@ abstract class AbstractSortScript implements ScorerAware { private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); private static final Map> PARAMS_FUNCTIONS = org.elasticsearch.common.collect.Map.of( "doc", value -> { - deprecationLogger.deprecate("sort-script_doc", + deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "sort-script_doc", "Accessing variable [doc] via [params.doc] from within an sort-script " + "is deprecated in favor of directly accessing [doc]."); return value; }, "_doc", value -> { - deprecationLogger.deprecate("sort-script__doc", + deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "sort-script__doc", "Accessing variable [doc] via [params._doc] from within an sort-script " + "is deprecated in favor of directly accessing [doc]."); return value; diff --git a/server/src/main/java/org/elasticsearch/script/AggregationScript.java b/server/src/main/java/org/elasticsearch/script/AggregationScript.java index 0f02938f70827..62b4c9b92df41 100644 --- a/server/src/main/java/org/elasticsearch/script/AggregationScript.java +++ b/server/src/main/java/org/elasticsearch/script/AggregationScript.java @@ -21,6 +21,7 @@ import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.search.Scorable; import org.elasticsearch.ElasticsearchException; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.lucene.ScorerAware; import org.elasticsearch.index.fielddata.ScriptDocValues; @@ -42,13 +43,13 @@ public abstract class AggregationScript implements ScorerAware { private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); private static final Map> PARAMS_FUNCTIONS = org.elasticsearch.common.collect.Map.of( "doc", value -> { - deprecationLogger.deprecate("aggregation-script_doc", + deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "aggregation-script_doc", "Accessing variable [doc] via [params.doc] from within an aggregation-script " + "is deprecated in favor of directly accessing [doc]."); return value; }, "_doc", value -> { - deprecationLogger.deprecate("aggregation-script__doc", + deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "aggregation-script__doc", "Accessing variable [doc] via [params._doc] from within an aggregation-script " + "is deprecated in favor of directly accessing [doc]."); return value; diff --git a/server/src/main/java/org/elasticsearch/script/FieldScript.java b/server/src/main/java/org/elasticsearch/script/FieldScript.java index f06f24f5dee01..c6a66b5be024c 100644 --- a/server/src/main/java/org/elasticsearch/script/FieldScript.java +++ b/server/src/main/java/org/elasticsearch/script/FieldScript.java @@ -20,6 +20,7 @@ package org.elasticsearch.script; import org.apache.lucene.index.LeafReaderContext; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.index.fielddata.ScriptDocValues; import org.elasticsearch.search.lookup.LeafSearchLookup; @@ -41,13 +42,13 @@ public abstract class FieldScript { private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); private static final Map> PARAMS_FUNCTIONS = org.elasticsearch.common.collect.Map.of( "doc", value -> { - deprecationLogger.deprecate("field-script_doc", + deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "field-script_doc", "Accessing variable [doc] via [params.doc] from within an field-script " + "is deprecated in favor of directly accessing [doc]."); return value; }, "_doc", value -> { - deprecationLogger.deprecate("field-script__doc", + deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "field-script__doc", "Accessing variable [doc] via [params._doc] from within an field-script " + "is deprecated in favor of directly accessing [doc]."); return value; diff --git a/server/src/main/java/org/elasticsearch/script/JodaCompatibleZonedDateTime.java b/server/src/main/java/org/elasticsearch/script/JodaCompatibleZonedDateTime.java index ed5ab30a08213..f729aa6f28a25 100644 --- a/server/src/main/java/org/elasticsearch/script/JodaCompatibleZonedDateTime.java +++ b/server/src/main/java/org/elasticsearch/script/JodaCompatibleZonedDateTime.java @@ -21,6 +21,7 @@ import org.elasticsearch.common.SuppressForbidden; import org.elasticsearch.common.SuppressLoggerChecks; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.time.DateFormatter; import org.elasticsearch.common.time.DateFormatters; @@ -63,19 +64,20 @@ public class JodaCompatibleZonedDateTime private static final DateFormatter DATE_FORMATTER = DateFormatter.forPattern("strict_date_time"); private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(JodaCompatibleZonedDateTime.class); - private static void logDeprecated(String key, String message, Object... params) { + private static void logDeprecated(DeprecationCategory category, String key, String message, Object... params) { AccessController.doPrivileged(new PrivilegedAction() { @SuppressLoggerChecks(reason = "safely delegates to logger") @Override public Void run() { - deprecationLogger.deprecate(key, message, params); + deprecationLogger.deprecate(category, key, message, params); return null; } }); } private static void logDeprecatedMethod(String oldMethod, String newMethod) { - logDeprecated(oldMethod, "Use of the joda time method [{}] is deprecated. Use [{}] instead.", oldMethod, newMethod); + logDeprecated(DeprecationCategory.PARSING, oldMethod, "Use of the joda time method [{}] is deprecated. Use [{}] instead.", + oldMethod, newMethod); } private ZonedDateTime dt; @@ -518,7 +520,7 @@ public DayOfWeek getDayOfWeekEnum() { @Deprecated public int getDayOfWeek() { - logDeprecated("getDayOfWeek()", + logDeprecated(DeprecationCategory.PARSING, "getDayOfWeek()", "The return type of [getDayOfWeek()] will change to an enum in 7.0. Use getDayOfWeekEnum().getValue()."); return dt.getDayOfWeek().getValue(); } diff --git a/server/src/main/java/org/elasticsearch/script/ScoreScript.java b/server/src/main/java/org/elasticsearch/script/ScoreScript.java index d2c173baa6a9e..427216534602e 100644 --- a/server/src/main/java/org/elasticsearch/script/ScoreScript.java +++ b/server/src/main/java/org/elasticsearch/script/ScoreScript.java @@ -22,6 +22,7 @@ import org.apache.lucene.search.Explanation; import org.apache.lucene.search.Scorable; import org.elasticsearch.Version; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.index.fielddata.ScriptDocValues; import org.elasticsearch.search.lookup.LeafSearchLookup; @@ -67,13 +68,13 @@ public Explanation get(double score, Explanation subQueryExplanation) { private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); private static final Map> PARAMS_FUNCTIONS = org.elasticsearch.common.collect.Map.of( "doc", value -> { - deprecationLogger.deprecate("score-script_doc", + deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "score-script_doc", "Accessing variable [doc] via [params.doc] from within an score-script " + "is deprecated in favor of directly accessing [doc]."); return value; }, "_doc", value -> { - deprecationLogger.deprecate("score-script__doc", + deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "score-script__doc", "Accessing variable [doc] via [params._doc] from within an score-script " + "is deprecated in favor of directly accessing [doc]."); return value; diff --git a/server/src/main/java/org/elasticsearch/script/Script.java b/server/src/main/java/org/elasticsearch/script/Script.java index 0c79338e328e4..d21e39eda859f 100644 --- a/server/src/main/java/org/elasticsearch/script/Script.java +++ b/server/src/main/java/org/elasticsearch/script/Script.java @@ -27,6 +27,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.AbstractObjectParser; @@ -462,8 +463,8 @@ public static Script parse(Object config) { throw new ElasticsearchParseException("Value must be of type String: [" + parameterName + "]"); } } else { - deprecationLogger.deprecate("script_unsupported_fields", "script section does not support [" - + parameterName + "]"); + deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "script_unsupported_fields", + "script section does not support [" + parameterName + "]"); } } if (script == null) { diff --git a/server/src/main/java/org/elasticsearch/script/ScriptMetadata.java b/server/src/main/java/org/elasticsearch/script/ScriptMetadata.java index 4fbfe35afdf49..901c3c8352fd0 100644 --- a/server/src/main/java/org/elasticsearch/script/ScriptMetadata.java +++ b/server/src/main/java/org/elasticsearch/script/ScriptMetadata.java @@ -29,6 +29,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.ToXContentFragment; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -218,9 +219,11 @@ public static ScriptMetadata fromXContent(XContentParser parser) throws IOExcept if (source.getSource().isEmpty()) { if (source.getLang().equals(Script.DEFAULT_TEMPLATE_LANG)) { - deprecationLogger.deprecate("empty_templates", "empty templates should no longer be used"); + deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "empty_templates", + "empty templates should no longer be used"); } else { - deprecationLogger.deprecate("empty_scripts", "empty scripts should no longer be used"); + deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "empty_scripts", + "empty scripts should no longer be used"); } } } diff --git a/server/src/main/java/org/elasticsearch/script/ScriptedMetricAggContexts.java b/server/src/main/java/org/elasticsearch/script/ScriptedMetricAggContexts.java index 34173e7fbc877..1afb7eeeadc74 100644 --- a/server/src/main/java/org/elasticsearch/script/ScriptedMetricAggContexts.java +++ b/server/src/main/java/org/elasticsearch/script/ScriptedMetricAggContexts.java @@ -22,6 +22,7 @@ import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.search.Scorable; import org.elasticsearch.ElasticsearchException; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.index.fielddata.ScriptDocValues; import org.elasticsearch.search.lookup.LeafSearchLookup; @@ -68,18 +69,18 @@ public abstract static class MapScript { private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); private static final Map> PARAMS_FUNCTIONS = org.elasticsearch.common.collect.Map.of( "doc", value -> { - deprecationLogger.deprecate("map-script_doc", + deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "map-script_doc", "Accessing variable [doc] via [params.doc] from within an scripted metric agg map script " + "is deprecated in favor of directly accessing [doc]."); return value; }, "_doc", value -> { - deprecationLogger.deprecate("map-script__doc", + deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "map-script__doc", "Accessing variable [doc] via [params._doc] from within an scripted metric agg map script " + "is deprecated in favor of directly accessing [doc]."); return value; }, "_agg", value -> { - deprecationLogger.deprecate("map-script__agg", + deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "map-script__agg", "Accessing variable [_agg] via [params._agg] from within a scripted metric agg map script " + "is deprecated in favor of using [state]."); return value; diff --git a/server/src/main/java/org/elasticsearch/script/StoredScriptSource.java b/server/src/main/java/org/elasticsearch/script/StoredScriptSource.java index a56221e2515f2..337c72a0a79d3 100644 --- a/server/src/main/java/org/elasticsearch/script/StoredScriptSource.java +++ b/server/src/main/java/org/elasticsearch/script/StoredScriptSource.java @@ -29,6 +29,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.common.xcontent.NamedXContentRegistry; @@ -144,9 +145,11 @@ private StoredScriptSource build(boolean ignoreEmpty) { if (source == null) { if (ignoreEmpty || Script.DEFAULT_TEMPLATE_LANG.equals(lang)) { if (Script.DEFAULT_TEMPLATE_LANG.equals(lang)) { - deprecationLogger.deprecate("empty_templates", "empty templates should no longer be used"); + deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "empty_templates", + "empty templates should no longer be used"); } else { - deprecationLogger.deprecate("empty_scripts", "empty scripts should no longer be used"); + deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "empty_scripts", + "empty scripts should no longer be used"); } } else { throw new IllegalArgumentException("must specify source for stored script"); @@ -154,9 +157,11 @@ private StoredScriptSource build(boolean ignoreEmpty) { } else if (source.isEmpty()) { if (ignoreEmpty || Script.DEFAULT_TEMPLATE_LANG.equals(lang)) { if (Script.DEFAULT_TEMPLATE_LANG.equals(lang)) { - deprecationLogger.deprecate("empty_templates", "empty templates should no longer be used"); + deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "empty_templates", + "empty templates should no longer be used"); } else { - deprecationLogger.deprecate("empty_scripts", "empty scripts should no longer be used"); + deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "empty_scripts", + "empty scripts should no longer be used"); } } else { throw new IllegalArgumentException("source cannot be empty"); @@ -256,7 +261,7 @@ public static StoredScriptSource parse(BytesReference content, XContentType xCon token = parser.nextToken(); if (token == Token.END_OBJECT) { - deprecationLogger.deprecate("empty_templates", "empty templates should no longer be used"); + deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "empty_templates", "empty templates should no longer be used"); return new StoredScriptSource(Script.DEFAULT_TEMPLATE_LANG, "", Collections.emptyMap()); } diff --git a/server/src/main/java/org/elasticsearch/script/TermsSetQueryScript.java b/server/src/main/java/org/elasticsearch/script/TermsSetQueryScript.java index 440cb4c4b9960..ddb801cdbe3f0 100644 --- a/server/src/main/java/org/elasticsearch/script/TermsSetQueryScript.java +++ b/server/src/main/java/org/elasticsearch/script/TermsSetQueryScript.java @@ -19,6 +19,7 @@ package org.elasticsearch.script; import org.apache.lucene.index.LeafReaderContext; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.index.fielddata.ScriptDocValues; import org.elasticsearch.search.lookup.LeafSearchLookup; @@ -39,13 +40,13 @@ public abstract class TermsSetQueryScript { private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(DynamicMap.class); private static final Map> PARAMS_FUNCTIONS = org.elasticsearch.common.collect.Map.of( "doc", value -> { - deprecationLogger.deprecate("terms-set-query-script_doc", + deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "terms-set-query-script_doc", "Accessing variable [doc] via [params.doc] from within an terms-set-query-script " + "is deprecated in favor of directly accessing [doc]."); return value; }, "_doc", value -> { - deprecationLogger.deprecate("terms-set-query-script__doc", + deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "terms-set-query-script__doc", "Accessing variable [doc] via [params._doc] from within an terms-set-query-script " + "is deprecated in favor of directly accessing [doc]."); return value; diff --git a/server/src/main/java/org/elasticsearch/script/UpdateScript.java b/server/src/main/java/org/elasticsearch/script/UpdateScript.java index 656315d6bcb03..b1fa5d6aeac12 100644 --- a/server/src/main/java/org/elasticsearch/script/UpdateScript.java +++ b/server/src/main/java/org/elasticsearch/script/UpdateScript.java @@ -20,6 +20,7 @@ package org.elasticsearch.script; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import java.util.Map; @@ -34,7 +35,7 @@ public abstract class UpdateScript { DeprecationLogger.getLogger(DynamicMap.class); private static final Map> PARAMS_FUNCTIONS = org.elasticsearch.common.collect.Map.of( "_type", value -> { - deprecationLogger.deprecate("update-script", + deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "update-script", "[types removal] Looking up doc types [_type] in scripts is deprecated."); return value; }); diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/InternalOrder.java b/server/src/main/java/org/elasticsearch/search/aggregations/InternalOrder.java index 1e5cd789a0a62..cdef5dcb326f1 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/InternalOrder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/InternalOrder.java @@ -22,6 +22,7 @@ import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.util.Comparators; import org.elasticsearch.common.xcontent.XContent; @@ -577,7 +578,7 @@ public static BucketOrder parseOrderParam(XContentParser parser) throws IOExcept } // _term and _time order deprecated in 6.0; replaced by _key if ("_term".equals(orderKey) || "_time".equals(orderKey)) { - deprecationLogger.deprecate("aggregation_order_key", + deprecationLogger.deprecate(DeprecationCategory.AGGREGATIONS, "aggregation_order_key", "Deprecated aggregation order key [{}] used, replaced by [_key]", orderKey); } switch (orderKey) { diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateIntervalWrapper.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateIntervalWrapper.java index 3c7bfc9de7661..f241d279a636c 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateIntervalWrapper.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/DateIntervalWrapper.java @@ -27,6 +27,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.ObjectParser; @@ -135,7 +136,7 @@ public IntervalTypeEnum getIntervalType() { /** Get the current interval in milliseconds that is set on this builder. */ @Deprecated public long interval() { - DEPRECATION_LOGGER.deprecate("date-interval-getter", DEPRECATION_TEXT); + DEPRECATION_LOGGER.deprecate(DeprecationCategory.AGGREGATIONS, "date-interval-getter", DEPRECATION_TEXT); if (intervalType.equals(IntervalTypeEnum.LEGACY_INTERVAL)) { return TimeValue.parseTimeValue(dateHistogramInterval.toString(), "interval").getMillis(); } @@ -156,14 +157,14 @@ public void interval(long interval) { throw new IllegalArgumentException("[interval] must be 1 or greater for aggregation [date_histogram]"); } setIntervalType(IntervalTypeEnum.LEGACY_INTERVAL); - DEPRECATION_LOGGER.deprecate("date-interval-setter", DEPRECATION_TEXT); + DEPRECATION_LOGGER.deprecate(DeprecationCategory.AGGREGATIONS, "date-interval-setter", DEPRECATION_TEXT); this.dateHistogramInterval = new DateHistogramInterval(interval + "ms"); } /** Get the current date interval that is set on this builder. */ @Deprecated public DateHistogramInterval dateHistogramInterval() { - DEPRECATION_LOGGER.deprecate("date-histogram-interval-getter", DEPRECATION_TEXT); + DEPRECATION_LOGGER.deprecate(DeprecationCategory.AGGREGATIONS, "date-histogram-interval-getter", DEPRECATION_TEXT); if (intervalType.equals(IntervalTypeEnum.LEGACY_DATE_HISTO)) { return dateHistogramInterval; } @@ -184,7 +185,7 @@ public void dateHistogramInterval(DateHistogramInterval dateHistogramInterval) { throw new IllegalArgumentException("[dateHistogramInterval] must not be null: [date_histogram]"); } setIntervalType(IntervalTypeEnum.LEGACY_DATE_HISTO); - DEPRECATION_LOGGER.deprecate("date-histogram-interval-setter", DEPRECATION_TEXT); + DEPRECATION_LOGGER.deprecate(DeprecationCategory.AGGREGATIONS, "date-histogram-interval-setter", DEPRECATION_TEXT); this.dateHistogramInterval = dateHistogramInterval; } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/SignificantTermsAggregatorFactory.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/SignificantTermsAggregatorFactory.java index 9f186dd3d76b1..a3d3c0470c1e3 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/SignificantTermsAggregatorFactory.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/SignificantTermsAggregatorFactory.java @@ -20,6 +20,7 @@ package org.elasticsearch.search.aggregations.bucket.terms; import org.elasticsearch.common.ParseField; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.search.DocValueFormat; @@ -332,7 +333,7 @@ public static ExecutionMode fromString(String value, final DeprecationLogger dep if ("global_ordinals".equals(value)) { return GLOBAL_ORDINALS; } else if ("global_ordinals_hash".equals(value)) { - deprecationLogger.deprecate("global_ordinals_hash", + deprecationLogger.deprecate(DeprecationCategory.AGGREGATIONS, "global_ordinals_hash", "global_ordinals_hash is deprecated. Please use [global_ordinals] instead."); return GLOBAL_ORDINALS; } else if ("map".equals(value)) { diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/PercentilesAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/PercentilesAggregationBuilder.java index 7b7eee1d858bf..3dc33a1f2c2d3 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/metrics/PercentilesAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/metrics/PercentilesAggregationBuilder.java @@ -21,6 +21,7 @@ import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.ConstructingObjectParser; import org.elasticsearch.common.xcontent.XContentParser; @@ -122,7 +123,8 @@ private static double[] validatePercentiles(double[] percents, String aggName) { } if (percent == previousPercent) { - deprecationLogger.deprecate("percents", "percent [{}] has been specified more than once, percents must be unique", percent); + deprecationLogger.deprecate(DeprecationCategory.AGGREGATIONS, "percents", + "percent [{}] has been specified more than once, percents must be unique", percent); } previousPercent = percent; } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/MovAvgPipelineAggregationBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/MovAvgPipelineAggregationBuilder.java index 4dce1f4d0c904..ba0986603c978 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/MovAvgPipelineAggregationBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/pipeline/MovAvgPipelineAggregationBuilder.java @@ -19,21 +19,11 @@ package org.elasticsearch.search.aggregations.pipeline; -import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregator.Parser.BUCKETS_PATH; -import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregator.Parser.FORMAT; -import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregator.Parser.GAP_POLICY; - -import java.io.IOException; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; - import org.elasticsearch.common.ParseField; import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.ParseFieldRegistry; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -41,6 +31,17 @@ import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.aggregations.pipeline.BucketHelpers.GapPolicy; +import java.io.IOException; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregator.Parser.BUCKETS_PATH; +import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregator.Parser.FORMAT; +import static org.elasticsearch.search.aggregations.pipeline.PipelineAggregator.Parser.GAP_POLICY; + public class MovAvgPipelineAggregationBuilder extends AbstractPipelineAggregationBuilder { public static final String NAME = "moving_avg"; @@ -299,7 +300,7 @@ public static MovAvgPipelineAggregationBuilder parse( Integer predict = null; Boolean minimize = null; - DEPRECATION_LOGGER.deprecate("moving_avg_aggregation", + DEPRECATION_LOGGER.deprecate(DeprecationCategory.AGGREGATIONS, "moving_avg_aggregation", "The moving_avg aggregation has been deprecated in favor of the moving_fn aggregation."); while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { diff --git a/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java b/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java index ec1620b7e4f85..7103c8983155f 100644 --- a/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/builder/SearchSourceBuilder.java @@ -29,6 +29,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.ToXContentFragment; @@ -1202,7 +1203,7 @@ public void parseXContent(XContentParser parser, boolean checkTrailingTokens) th scriptFields.add(new ScriptField(parser)); } } else if (INDICES_BOOST_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { - deprecationLogger.deprecate("indices_boost_object_format", + deprecationLogger.deprecate(DeprecationCategory.API, "indices_boost_object_format", "Object format in indices_boost is deprecated, please use array format instead"); while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { if (token == XContentParser.Token.FIELD_NAME) { diff --git a/server/src/main/java/org/elasticsearch/search/fetch/subphase/FetchDocValuesPhase.java b/server/src/main/java/org/elasticsearch/search/fetch/subphase/FetchDocValuesPhase.java index 8da4d0067e435..1575afcefb843 100644 --- a/server/src/main/java/org/elasticsearch/search/fetch/subphase/FetchDocValuesPhase.java +++ b/server/src/main/java/org/elasticsearch/search/fetch/subphase/FetchDocValuesPhase.java @@ -20,6 +20,7 @@ import org.apache.lucene.index.LeafReaderContext; import org.elasticsearch.common.document.DocumentField; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.index.mapper.DocValueFetcher; import org.elasticsearch.index.mapper.MappedFieldType; @@ -52,7 +53,7 @@ public FetchSubPhaseProcessor getProcessor(FetchContext context) { if (context.docValuesContext().fields().stream() .map(f -> f.format) .anyMatch(USE_DEFAULT_FORMAT::equals)) { - DEPRECATION_LOGGER.deprecate("explicit_default_format", + DEPRECATION_LOGGER.deprecate(DeprecationCategory.API, "explicit_default_format", "[" + USE_DEFAULT_FORMAT + "] is a special format that was only used to " + "ease the transition to 7.x. It has become the default and shouldn't be set explicitly anymore."); } diff --git a/server/src/main/java/org/elasticsearch/search/lookup/LeafDocLookup.java b/server/src/main/java/org/elasticsearch/search/lookup/LeafDocLookup.java index 523823cdab646..361c69308d610 100644 --- a/server/src/main/java/org/elasticsearch/search/lookup/LeafDocLookup.java +++ b/server/src/main/java/org/elasticsearch/search/lookup/LeafDocLookup.java @@ -20,6 +20,7 @@ import org.apache.lucene.index.LeafReaderContext; import org.elasticsearch.ExceptionsHelper; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.ScriptDocValues; @@ -64,7 +65,7 @@ public void setDocument(int docId) { public ScriptDocValues get(Object key) { // deprecate _type if ("_type".equals(key)) { - DEPRECATION_LOGGER.deprecate(TYPES_DEPRECATION_KEY, TYPES_DEPRECATION_MESSAGE); + DEPRECATION_LOGGER.deprecate(DeprecationCategory.SCRIPTING, TYPES_DEPRECATION_KEY, TYPES_DEPRECATION_MESSAGE); } // assume its a string... String fieldName = key.toString(); diff --git a/server/src/main/java/org/elasticsearch/search/slice/SliceBuilder.java b/server/src/main/java/org/elasticsearch/search/slice/SliceBuilder.java index 492796bec71b8..6a7c33cdae061 100644 --- a/server/src/main/java/org/elasticsearch/search/slice/SliceBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/slice/SliceBuilder.java @@ -28,6 +28,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.ObjectParser; import org.elasticsearch.common.xcontent.ToXContentObject; @@ -225,7 +226,7 @@ public Query toFilter(ShardSearchRequest request, SearchExecutionContext context if (context.getIndexSettings().getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { throw new IllegalArgumentException("Computing slices on the [_uid] field is illegal for 7.x indices, use [_id] instead"); } - DEPRECATION_LOG.deprecate("slice_on_uid", + DEPRECATION_LOG.deprecate(DeprecationCategory.API, "slice_on_uid", "Computing slices on the [_uid] field is deprecated for 6.x indices, use [_id] instead"); useTermQuery = true; } else if (IdFieldMapper.NAME.equals(field)) { diff --git a/server/src/main/java/org/elasticsearch/search/sort/FieldSortBuilder.java b/server/src/main/java/org/elasticsearch/search/sort/FieldSortBuilder.java index c02e5aa84baaf..3dcd23bf0e169 100644 --- a/server/src/main/java/org/elasticsearch/search/sort/FieldSortBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/sort/FieldSortBuilder.java @@ -30,6 +30,7 @@ import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.time.DateMathParser; import org.elasticsearch.common.time.DateUtils; @@ -710,7 +711,7 @@ public static FieldSortBuilder fromXContent(XContentParser parser, String fieldN static { PARSER.declareField(FieldSortBuilder::missing, XContentParser::objectText, MISSING, ValueType.VALUE); PARSER.declareString((fieldSortBuilder, nestedPath) -> { - deprecationLogger.deprecate("field_sort_nested_path", + deprecationLogger.deprecate(DeprecationCategory.API, "field_sort_nested_path", "[nested_path] has been deprecated in favor of the [nested] parameter"); fieldSortBuilder.setNestedPath(nestedPath); }, NESTED_PATH_FIELD); @@ -718,7 +719,7 @@ public static FieldSortBuilder fromXContent(XContentParser parser, String fieldN PARSER.declareString((b, v) -> b.order(SortOrder.fromString(v)) , ORDER_FIELD); PARSER.declareString((b, v) -> b.sortMode(SortMode.fromString(v)), SORT_MODE); PARSER.declareObject(FieldSortBuilder::setNestedFilter, (p, c) -> { - deprecationLogger.deprecate("field_sort_nested_filter", + deprecationLogger.deprecate(DeprecationCategory.API, "field_sort_nested_filter", "[nested_filter] has been deprecated in favour for the [nested] parameter"); return SortBuilder.parseNestedFilter(p); }, NESTED_FILTER_FIELD); diff --git a/server/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java b/server/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java index e82fd09aaa75a..16f6302c3bb95 100644 --- a/server/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java @@ -37,6 +37,7 @@ import org.elasticsearch.common.geo.GeoUtils; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.unit.DistanceUnit; import org.elasticsearch.common.util.BigArrays; @@ -493,7 +494,7 @@ public static GeoDistanceSortBuilder fromXContent(XContentParser parser, String fieldName = currentName; } else if (token == XContentParser.Token.START_OBJECT) { if (NESTED_FILTER_FIELD.match(currentName, parser.getDeprecationHandler())) { - deprecationLogger.deprecate("geo_distance_nested_filter", + deprecationLogger.deprecate(DeprecationCategory.API, "geo_distance_nested_filter", "[nested_filter] has been deprecated in favour of the [nested] parameter"); nestedFilter = parseInnerQueryBuilder(parser); } else if (NESTED_FIELD.match(currentName, parser.getDeprecationHandler())) { @@ -524,7 +525,7 @@ public static GeoDistanceSortBuilder fromXContent(XContentParser parser, String } else if (SORTMODE_FIELD.match(currentName, parser.getDeprecationHandler())) { sortMode = SortMode.fromString(parser.text()); } else if (NESTED_PATH_FIELD.match(currentName, parser.getDeprecationHandler())) { - deprecationLogger.deprecate("geo_distance_nested_path", + deprecationLogger.deprecate(DeprecationCategory.API, "geo_distance_nested_path", "[nested_path] has been deprecated in favour of the [nested] parameter"); nestedPath = parser.text(); } else if (IGNORE_UNMAPPED.match(currentName, parser.getDeprecationHandler())) { diff --git a/server/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java b/server/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java index 0371d834be93d..15711a6b40cae 100644 --- a/server/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/sort/ScriptSortBuilder.java @@ -30,6 +30,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.util.BigArrays; import org.elasticsearch.common.xcontent.ConstructingObjectParser; @@ -280,12 +281,12 @@ public XContentBuilder toXContent(XContentBuilder builder, Params builderParams) PARSER.declareString((b, v) -> b.order(SortOrder.fromString(v)), ORDER_FIELD); PARSER.declareString((b, v) -> b.sortMode(SortMode.fromString(v)), SORTMODE_FIELD); PARSER.declareString((fieldSortBuilder, nestedPath) -> { - deprecationLogger.deprecate("script_nested_path", + deprecationLogger.deprecate(DeprecationCategory.API, "script_nested_path", "[nested_path] has been deprecated in favor of the [nested] parameter"); fieldSortBuilder.setNestedPath(nestedPath); }, NESTED_PATH_FIELD); PARSER.declareObject(ScriptSortBuilder::setNestedFilter, (p, c) -> { - deprecationLogger.deprecate("script_nested_filter", + deprecationLogger.deprecate(DeprecationCategory.API, "script_nested_filter", "[nested_filter] has been deprecated in favour for the [nested] parameter"); return SortBuilder.parseNestedFilter(p); }, NESTED_FILTER_FIELD); diff --git a/server/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoContextMapping.java b/server/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoContextMapping.java index 17fa9b23f48b1..c5eb5de15e062 100644 --- a/server/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoContextMapping.java +++ b/server/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoContextMapping.java @@ -28,6 +28,7 @@ import org.elasticsearch.Version; import org.elasticsearch.common.geo.GeoPoint; import org.elasticsearch.common.geo.GeoUtils; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.unit.DistanceUnit; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -289,7 +290,7 @@ public void validateReferences(Version indexVersionCreated, Function h DatafeedConfig.Builder builder = new DatafeedConfig.Builder(datafeedConfig); if (jobId != null) { if (datafeedConfig.getJobId() != null && datafeedConfig.getJobId().equals(jobId) == false) { - deprecationLogger.deprecate("update_datafeed_job_id", DEPRECATION_MESSAGE_ON_JOB_ID_UPDATE); + deprecationLogger.deprecate(DeprecationCategory.API, "update_datafeed_job_id", DEPRECATION_MESSAGE_ON_JOB_ID_UPDATE); } builder.setJobId(jobId); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/permission/IndicesPermission.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/permission/IndicesPermission.java index 7dcf5da046574..f9bd26036a8d5 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/permission/IndicesPermission.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/authz/permission/IndicesPermission.java @@ -13,6 +13,7 @@ import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.bytes.BytesReference; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.regex.Regex; import org.elasticsearch.xpack.core.security.authz.accesscontrol.IndicesAccessControl; @@ -237,11 +238,19 @@ public Map authorize(String act for (String privilegeName : group.privilege.name()) { if (PRIVILEGE_NAME_SET_BWC_ALLOW_MAPPING_UPDATE.contains(privilegeName)) { bwcDeprecationLogActions.add(() -> { - deprecationLogger.deprecate("[" + indexOrAlias + "] mapping update for ingest " + - "privilege [" + privilegeName + "]", "the index privilege [" + privilegeName + "] allowed" + - " the update mapping action [" + action + "] on index [" + indexOrAlias + "], this " + - "privilege will not permit mapping updates in the next major release - users who require " + - "access to update mappings must be granted explicit privileges"); + deprecationLogger.deprecate( + DeprecationCategory.SECURITY, + "[" + indexOrAlias + "] mapping update for ingest privilege [" + privilegeName + "]", + "the index privilege [" + + privilegeName + + "] allowed the update mapping action [" + + action + + "] on index [" + + indexOrAlias + + "], this " + + "privilege will not permit mapping updates in the next major release - users who require " + + "access to update mappings must be granted explicit privileges" + ); }); } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/SSLService.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/SSLService.java index f70de1c094d4b..7d9445cef6b09 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/SSLService.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/SSLService.java @@ -17,6 +17,7 @@ import org.elasticsearch.bootstrap.JavaVersion; import org.elasticsearch.common.CheckedSupplier; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.logging.LoggerMessageFormat; import org.elasticsearch.common.settings.Settings; @@ -544,7 +545,8 @@ private void validateServerConfiguration(String prefix) { // Client Authentication _should_ be required, but if someone turns it off, then this check is no longer relevant final SSLConfigurationSettings configurationSettings = SSLConfigurationSettings.withPrefix(prefix + "."); if (isConfigurationValidForServerUsage(configuration) == false) { - deprecationLogger.deprecate("invalid_ssl_configuration", "invalid SSL configuration for " + prefix + + deprecationLogger.deprecate(DeprecationCategory.SECURITY, "invalid_ssl_configuration", + "invalid SSL configuration for " + prefix + " - server ssl configuration requires a key and certificate, but these have not been configured; you must set either " + "[" + configurationSettings.x509KeyPair.keystorePath.getKey() + "], or both [" + configurationSettings.x509KeyPair.keyPath.getKey() + "] and [" + @@ -556,7 +558,7 @@ private void validateServerConfiguration(String prefix) { .sorted() .collect(Collectors.toList()); if (sslSettingNames.isEmpty() == false) { - deprecationLogger.deprecate("invalid_ssl_configuration", + deprecationLogger.deprecate(DeprecationCategory.SECURITY, "invalid_ssl_configuration", "invalid configuration for " + prefix + " - [" + enabledSetting + "] is not set, but the following settings have been configured in elasticsearch.yml : [" + Strings.collectionToCommaDelimitedString(sslSettingNames) + "]"); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/action/GetTransformAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/action/GetTransformAction.java index 897be99e725c6..3340061a8e4ef 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/action/GetTransformAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/action/GetTransformAction.java @@ -11,6 +11,7 @@ import org.elasticsearch.common.ParseField; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -121,7 +122,12 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws builder.field(TransformField.COUNT.getPreferredName(), invalidTransforms.size()); builder.field(TransformField.TRANSFORMS.getPreferredName(), invalidTransforms); builder.endObject(); - deprecationLogger.deprecate("invalid_transforms", INVALID_TRANSFORMS_DEPRECATION_WARNING, invalidTransforms.size()); + deprecationLogger.deprecate( + DeprecationCategory.OTHER, + "invalid_transforms", + INVALID_TRANSFORMS_DEPRECATION_WARNING, + invalidTransforms.size() + ); } builder.endObject(); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/transforms/pivot/PivotConfig.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/transforms/pivot/PivotConfig.java index 8fccb6c14a472..f8bdf21057741 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/transforms/pivot/PivotConfig.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/transforms/pivot/PivotConfig.java @@ -11,6 +11,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.io.stream.Writeable; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.ConstructingObjectParser; import org.elasticsearch.common.xcontent.ToXContentObject; @@ -86,6 +87,7 @@ public PivotConfig(final GroupConfig groups, final AggregationConfig aggregation if (maxPageSearchSize != null) { deprecationLogger.deprecate( + DeprecationCategory.API, TransformField.MAX_PAGE_SEARCH_SIZE.getPreferredName(), "[max_page_search_size] is deprecated inside pivot please use settings instead" ); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/MockDeprecatedAggregationBuilder.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/MockDeprecatedAggregationBuilder.java index 4eb87702dd073..344b74617ae16 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/MockDeprecatedAggregationBuilder.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/MockDeprecatedAggregationBuilder.java @@ -8,6 +8,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -91,7 +92,7 @@ protected XContentBuilder doXContentBody(XContentBuilder builder, Params params) } public static MockDeprecatedAggregationBuilder fromXContent(XContentParser p) { - deprecationLogger.deprecate("deprecated_mock", DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.OTHER, "deprecated_mock", DEPRECATION_MESSAGE); return new MockDeprecatedAggregationBuilder(); } } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/MockDeprecatedQueryBuilder.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/MockDeprecatedQueryBuilder.java index 18aef3c9985c9..b428b6820855d 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/MockDeprecatedQueryBuilder.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/transform/transforms/MockDeprecatedQueryBuilder.java @@ -10,6 +10,7 @@ import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.lucene.search.Queries; import org.elasticsearch.common.xcontent.ObjectParser; @@ -45,7 +46,7 @@ public MockDeprecatedQueryBuilder(StreamInput in) throws IOException { public static MockDeprecatedQueryBuilder fromXContent(XContentParser parser) { try { - deprecationLogger.deprecate("deprecated_mock", DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.OTHER, "deprecated_mock", DEPRECATION_MESSAGE); return PARSER.apply(parser, null); } catch (IllegalArgumentException e) { diff --git a/x-pack/plugin/deprecation/qa/rest/src/main/java/org/elasticsearch/xpack/deprecation/TestDeprecatedQueryBuilder.java b/x-pack/plugin/deprecation/qa/rest/src/main/java/org/elasticsearch/xpack/deprecation/TestDeprecatedQueryBuilder.java index b5be2011860f2..83e0e5629bb3f 100644 --- a/x-pack/plugin/deprecation/qa/rest/src/main/java/org/elasticsearch/xpack/deprecation/TestDeprecatedQueryBuilder.java +++ b/x-pack/plugin/deprecation/qa/rest/src/main/java/org/elasticsearch/xpack/deprecation/TestDeprecatedQueryBuilder.java @@ -10,6 +10,7 @@ import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.lucene.search.Queries; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -65,7 +66,13 @@ public String getWriteableName() { @Override protected Query doToQuery(SearchExecutionContext context) throws IOException { - deprecationLogger.deprecate(NAME, "[{}] query is deprecated, but used on [{}] index", NAME, context.index().getName()); + deprecationLogger.deprecate( + DeprecationCategory.OTHER, + NAME, + "[{}] query is deprecated, but used on [{}] index", + NAME, + context.index().getName() + ); return Queries.newMatchAllQuery(); } diff --git a/x-pack/plugin/deprecation/qa/rest/src/main/java/org/elasticsearch/xpack/deprecation/TestDeprecationHeaderRestAction.java b/x-pack/plugin/deprecation/qa/rest/src/main/java/org/elasticsearch/xpack/deprecation/TestDeprecationHeaderRestAction.java index 4d1d35aa6c366..31a53b273e7f7 100644 --- a/x-pack/plugin/deprecation/qa/rest/src/main/java/org/elasticsearch/xpack/deprecation/TestDeprecationHeaderRestAction.java +++ b/x-pack/plugin/deprecation/qa/rest/src/main/java/org/elasticsearch/xpack/deprecation/TestDeprecationHeaderRestAction.java @@ -8,6 +8,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; import org.elasticsearch.client.node.NodeClient; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; @@ -103,7 +104,7 @@ public RestChannelConsumer prepareRequest(RestRequest request, NodeClient client final Map source = parser.map(); if (source.containsKey("deprecated_settings")) { - deprecationLogger.deprecate("deprecated_settings", DEPRECATED_USAGE); + deprecationLogger.deprecate(DeprecationCategory.OTHER, "deprecated_settings", DEPRECATED_USAGE); settings = (List) source.get("deprecated_settings"); } else { diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/EcsJsonLayout.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/EcsJsonLayout.java index 7c91dc3e89bc3..a7d32a613689c 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/EcsJsonLayout.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/logging/EcsJsonLayout.java @@ -66,8 +66,9 @@ protected String pattern(String dataset, String[] esMessageFields) { map.put("ecs.version", inQuotes(ECS_VERSION)); Map ecsKeyReplacements = new HashMap<>(); - ecsKeyReplacements.put("x-opaque-id", "elasticsearch.http.request.x_opaque_id"); + ecsKeyReplacements.put("category", "elasticsearch.event.category"); ecsKeyReplacements.put("key", "event.code"); + ecsKeyReplacements.put("x-opaque-id", "elasticsearch.http.request.x_opaque_id"); for (String key : esMessageFields) { map.put(ecsKeyReplacements.getOrDefault(key, key), inQuotes("%ESMessageField{" + key + "}")); diff --git a/x-pack/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java b/x-pack/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java index 327b09fbfd063..99dfc4334f421 100644 --- a/x-pack/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java +++ b/x-pack/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java @@ -10,6 +10,7 @@ import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentParser; @@ -113,7 +114,7 @@ public RestChannelConsumer doPrepareRequest(final RestRequest request, final XPa } if (request.hasParam("type")) { - deprecationLogger.deprecate("graph_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "graph_with_types", TYPES_DEPRECATION_MESSAGE); graphRequest.types(Strings.splitStringByCommaToArray(request.param("type"))); } return channel -> client.es().execute(INSTANCE, graphRequest, new RestToXContentListener<>(channel)); diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/JobManager.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/JobManager.java index 32329b821d6ed..e0d72b23aeee5 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/JobManager.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/JobManager.java @@ -18,6 +18,7 @@ import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.CheckedConsumer; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.ByteSizeValue; @@ -246,7 +247,7 @@ public void putJob(PutJobAction.Request request, AnalysisRegistry analysisRegist Job job = jobBuilder.build(new Date()); if (job.getDataDescription() != null && job.getDataDescription().getFormat() == DataDescription.DataFormat.DELIMITED) { - deprecationLogger.deprecate("ml_create_job_delimited_data", + deprecationLogger.deprecate(DeprecationCategory.API, "ml_create_job_delimited_data", "Creating jobs with delimited data format is deprecated. Please use xcontent instead."); } diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestGetTrainedModelsAction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestGetTrainedModelsAction.java index 1301566c45b07..dc48c028e2626 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestGetTrainedModelsAction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/rest/inference/RestGetTrainedModelsAction.java @@ -8,6 +8,7 @@ import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.cluster.metadata.Metadata; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.ToXContentObject; @@ -79,6 +80,7 @@ protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient final GetTrainedModelsAction.Request request; if (restRequest.hasParam(GetTrainedModelsAction.Request.INCLUDE_MODEL_DEFINITION)) { deprecationLogger.deprecate( + DeprecationCategory.API, GetTrainedModelsAction.Request.INCLUDE_MODEL_DEFINITION, "[{}] parameter is deprecated! Use [include=definition] instead.", GetTrainedModelsAction.Request.INCLUDE_MODEL_DEFINITION); diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/utils/DomainSplitFunction.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/utils/DomainSplitFunction.java index 2d6d2fc273c92..090856fcca81a 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/utils/DomainSplitFunction.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/utils/DomainSplitFunction.java @@ -6,6 +6,7 @@ package org.elasticsearch.xpack.ml.utils; import org.elasticsearch.common.io.Streams; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import java.io.InputStream; @@ -161,7 +162,7 @@ private static String topPrivateDomain(String name, List parts, int publ public static List domainSplit(String host, Map params) { // NOTE: we don't check SpecialPermission because this will be called (indirectly) from scripts AccessController.doPrivileged((PrivilegedAction) () -> { - deprecationLogger.deprecate("domainSplit", + deprecationLogger.deprecate(DeprecationCategory.API, "domainSplit", "Method [domainSplit] taking params is deprecated. Remove the params argument."); return null; }); diff --git a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportPutRollupJobAction.java b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportPutRollupJobAction.java index 155e66a59aaea..60280b7303e9a 100644 --- a/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportPutRollupJobAction.java +++ b/x-pack/plugin/rollup/src/main/java/org/elasticsearch/xpack/rollup/action/TransportPutRollupJobAction.java @@ -34,6 +34,7 @@ import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.CheckedConsumer; import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.time.DateUtils; import org.elasticsearch.common.unit.TimeValue; @@ -111,7 +112,7 @@ static void checkForDeprecatedTZ(PutRollupJobAction.Request request) { String timeZone = request.getConfig().getGroupConfig().getDateHistogram().getTimeZone(); String modernTZ = DateUtils.DEPRECATED_LONG_TIMEZONES.get(timeZone); if (modernTZ != null) { - deprecationLogger.deprecate("deprecated_timezone", + deprecationLogger.deprecate(DeprecationCategory.API, "deprecated_timezone", "Creating Rollup job [" + request.getConfig().getId() + "] with timezone [" + timeZone + "], but [" + timeZone + "] has been deprecated by the IANA. Use [" + modernTZ +"] instead."); } diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ApiKeyService.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ApiKeyService.java index 4a3f53fbf7384..25a9adff1afca 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ApiKeyService.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ApiKeyService.java @@ -43,6 +43,7 @@ import org.elasticsearch.common.cache.CacheBuilder; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.hash.MessageDigests; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Setting; @@ -86,12 +87,13 @@ import org.elasticsearch.xpack.core.security.authc.support.Hasher; import org.elasticsearch.xpack.core.security.authz.RoleDescriptor; import org.elasticsearch.xpack.core.security.user.User; -import org.elasticsearch.xpack.security.support.InvalidationCountingCacheWrapper; import org.elasticsearch.xpack.security.support.CacheInvalidatorRegistry; import org.elasticsearch.xpack.security.support.FeatureNotEnabledException; import org.elasticsearch.xpack.security.support.FeatureNotEnabledException.Feature; +import org.elasticsearch.xpack.security.support.InvalidationCountingCacheWrapper; import org.elasticsearch.xpack.security.support.SecurityIndexManager; +import javax.crypto.SecretKeyFactory; import java.io.Closeable; import java.io.IOException; import java.io.UncheckedIOException; @@ -117,12 +119,11 @@ import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Collectors; -import javax.crypto.SecretKeyFactory; -import static org.elasticsearch.index.mapper.MapperService.SINGLE_MAPPING_NAME; +import static org.elasticsearch.action.bulk.TransportSingleItemBulkWriteAction.toSingleItemBulkRequest; import static org.elasticsearch.common.xcontent.ConstructingObjectParser.constructorArg; import static org.elasticsearch.common.xcontent.ConstructingObjectParser.optionalConstructorArg; -import static org.elasticsearch.action.bulk.TransportSingleItemBulkWriteAction.toSingleItemBulkRequest; +import static org.elasticsearch.index.mapper.MapperService.SINGLE_MAPPING_NAME; import static org.elasticsearch.search.SearchService.DEFAULT_KEEPALIVE_SETTING; import static org.elasticsearch.xpack.core.ClientHelper.SECURITY_ORIGIN; import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin; @@ -782,21 +783,21 @@ private ApiKeyLoggingDeprecationHandler(DeprecationLogger logger, String apiKeyI @Override public void usedDeprecatedName(String parserName, Supplier location, String usedName, String modernName) { String prefix = parserName == null ? "" : "[" + parserName + "][" + location.get() + "] "; - deprecationLogger.deprecate("api_key_field", + deprecationLogger.deprecate(DeprecationCategory.SECURITY, "api_key_field", "{}Deprecated field [{}] used in api key [{}], expected [{}] instead", prefix, usedName, apiKeyId, modernName); } @Override public void usedDeprecatedField(String parserName, Supplier location, String usedName, String replacedWith) { String prefix = parserName == null ? "" : "[" + parserName + "][" + location.get() + "] "; - deprecationLogger.deprecate("api_key_field", + deprecationLogger.deprecate(DeprecationCategory.SECURITY, "api_key_field", "{}Deprecated field [{}] used in api key [{}], replaced by [{}]", prefix, usedName, apiKeyId, replacedWith); } @Override public void usedDeprecatedField(String parserName, Supplier location, String usedName) { String prefix = parserName == null ? "" : "[" + parserName + "][" + location.get() + "] "; - deprecationLogger.deprecate("api_key_field", + deprecationLogger.deprecate(DeprecationCategory.SECURITY, "api_key_field", "{}Deprecated field [{}] used in api key [{}], which is unused and will be removed entirely", prefix, usedName, apiKeyId); } } diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/Realms.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/Realms.java index 0c9e034eb0e0b..673e482887971 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/Realms.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/Realms.java @@ -10,6 +10,7 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.common.Strings; import org.elasticsearch.common.collect.MapBuilder; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.CountDown; @@ -348,8 +349,8 @@ public static boolean isRealmTypeAvailable(XPackLicenseState licenseState, Strin private void logDeprecationIfFound(Set missingOrderRealmSettingKeys, Map> orderToRealmOrderSettingKeys) { if (missingOrderRealmSettingKeys.size() > 0) { - deprecationLogger.deprecate("unordered_realm_config", "Found realms without order config: [{}]. " + - "In next major release, node will fail to start with missing realm order.", + deprecationLogger.deprecate(DeprecationCategory.SECURITY, "unordered_realm_config", + "Found realms without order config: [{}]. In next major release, node will fail to start with missing realm order.", String.join("; ", missingOrderRealmSettingKeys) ); } @@ -360,7 +361,7 @@ private void logDeprecationIfFound(Set missingOrderRealmSettingKeys, Map .sorted() .collect(Collectors.toList()); if (false == duplicatedRealmOrderSettingKeys.isEmpty()) { - deprecationLogger.deprecate("duplicate_realm_order", + deprecationLogger.deprecate(DeprecationCategory.SECURITY, "duplicate_realm_order", "Found multiple realms configured with the same order: [{}]. " + "In next major release, node will fail to start with duplicated realm order.", String.join("; ", duplicatedRealmOrderSettingKeys)); diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealm.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealm.java index a0f408999871c..e23941d647a74 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealm.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealm.java @@ -9,6 +9,7 @@ import org.apache.logging.log4j.util.Supplier; import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.KeyStoreWrapper; import org.elasticsearch.common.settings.SecureSetting; @@ -232,8 +233,8 @@ private void getUserInfo(final String username, ActionListener private void logDeprecatedUser(final User user){ Map metadata = user.metadata(); if (Boolean.TRUE.equals(metadata.get(MetadataUtils.DEPRECATED_METADATA_KEY))) { - deprecationLogger.deprecate("deprecated_user-" + user.principal(), "The user [" + user.principal() + - "] is deprecated and will be removed in a future version of Elasticsearch. " + + deprecationLogger.deprecate(DeprecationCategory.SECURITY, "deprecated_user-" + user.principal(), + "The user [" + user.principal() + "] is deprecated and will be removed in a future version of Elasticsearch. " + metadata.get(MetadataUtils.DEPRECATED_REASON_METADATA_KEY)); } } diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactory.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactory.java index f0114339751ee..6c2e4b9deead1 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactory.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/ActiveDirectorySessionFactory.java @@ -20,6 +20,7 @@ import org.elasticsearch.action.ActionRunnable; import org.elasticsearch.common.cache.Cache; import org.elasticsearch.common.cache.CacheBuilder; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Setting; @@ -518,7 +519,8 @@ static class UpnADAuthenticator extends ADAuthenticator { super(config, timeout, ignoreReferralErrors, logger, groupsResolver, metadataResolver, domainDN, ActiveDirectorySessionFactorySettings.AD_UPN_USER_SEARCH_FILTER_SETTING, UPN_USER_FILTER, threadPool); if (userSearchFilter.contains("{0}")) { - deprecationLogger.deprecate("ldap_settings", "The use of the account name variable {0} in the setting [" + deprecationLogger.deprecate(DeprecationCategory.SECURITY, "ldap_settings", + "The use of the account name variable {0} in the setting [" + RealmSettings.getFullSettingKey(config, ActiveDirectorySessionFactorySettings.AD_UPN_USER_SEARCH_FILTER_SETTING) + "] has been deprecated and will be removed in a future version!"); } diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactory.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactory.java index e57a10988ccbf..eaa71286a48c4 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactory.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/ldap/support/SessionFactory.java @@ -14,6 +14,7 @@ import org.apache.logging.log4j.LogManager; import org.elasticsearch.action.ActionListener; import org.elasticsearch.common.Strings; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.unit.TimeValue; @@ -159,7 +160,7 @@ protected static LDAPConnectionOptions connectionOptions(RealmConfig config, } else if (hostnameVerificationExists) { final String fullSettingKey = RealmSettings.getFullSettingKey(config, SessionFactorySettings.HOSTNAME_VERIFICATION_SETTING); final String deprecationKey = "deprecated_setting_" + fullSettingKey.replace('.', '_'); - DeprecationLogger.getLogger(logger.getName()).deprecate(deprecationKey, + DeprecationLogger.getLogger(logger.getName()).deprecate(DeprecationCategory.SECURITY, deprecationKey, "the setting [{}] has been deprecated and will be removed in a future version. use [{}] instead", fullSettingKey, RealmSettings.getFullSettingKey(config, SSLConfigurationSettings.VERIFICATION_MODE_SETTING_REALM)); if (config.getSetting(SessionFactorySettings.HOSTNAME_VERIFICATION_SETTING)) { diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStore.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStore.java index 50d08209dbb46..3ec8e89eb2481 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStore.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStore.java @@ -18,6 +18,7 @@ import org.elasticsearch.common.cache.CacheBuilder; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.hash.MessageDigests; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting.Property; @@ -195,8 +196,8 @@ void logDeprecatedRoles(Set roleDescriptors) { .forEach(rd -> { String reason = Objects.toString( rd.getMetadata().get(MetadataUtils.DEPRECATED_REASON_METADATA_KEY), "Please check the documentation"); - deprecationLogger.deprecate("deprecated_role-" + rd.getName(), "The role [" + rd.getName() + - "] is deprecated and will be removed in a future version of Elasticsearch. " + reason); + deprecationLogger.deprecate(DeprecationCategory.SECURITY, "deprecated_role-" + rd.getName(), + "The role [" + rd.getName() + "] is deprecated and will be removed in a future version of Elasticsearch. " + reason); }); } diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/DeprecationRoleDescriptorConsumer.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/DeprecationRoleDescriptorConsumer.java index 596f048c87b95..47331698a0c41 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/DeprecationRoleDescriptorConsumer.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/DeprecationRoleDescriptorConsumer.java @@ -13,6 +13,7 @@ import org.elasticsearch.cluster.metadata.IndexAbstraction; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.service.ClusterService; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.util.concurrent.AbstractRunnable; import org.elasticsearch.threadpool.ThreadPool; @@ -205,7 +206,7 @@ private void logDeprecatedPermission(RoleDescriptor roleDescriptor) { if (false == inferiorIndexNames.isEmpty()) { final String logMessage = String.format(Locale.ROOT, ROLE_PERMISSION_DEPRECATION_STANZA, roleDescriptor.getName(), aliasName, String.join(", ", inferiorIndexNames)); - deprecationLogger.deprecate("index_permissions_on_alias", logMessage); + deprecationLogger.deprecate(DeprecationCategory.SECURITY, "index_permissions_on_alias", logMessage); } } } diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/DeprecationRoleDescriptorConsumerTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/DeprecationRoleDescriptorConsumerTests.java index c41e70ac084b0..fb55fe83f56e1 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/DeprecationRoleDescriptorConsumerTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/DeprecationRoleDescriptorConsumerTests.java @@ -12,6 +12,7 @@ import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.cluster.metadata.Metadata; import org.elasticsearch.cluster.service.ClusterService; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; @@ -296,7 +297,7 @@ private RoleDescriptor.IndicesPrivileges indexPrivileges(String priv, String... } private void verifyLogger(DeprecationLogger deprecationLogger, String roleName, String aliasName, String indexNames) { - verify(deprecationLogger).deprecate("index_permissions_on_alias", + verify(deprecationLogger).deprecate(DeprecationCategory.SECURITY, "index_permissions_on_alias", "Role [" + roleName + "] contains index privileges covering the [" + aliasName + "] alias but which do not cover some of the indices that it points to [" + indexNames + "]. Granting privileges over an" + " alias and hence granting privileges over all the indices that the alias points to is deprecated and will be removed" diff --git a/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/query/ShapeQueryBuilder.java b/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/query/ShapeQueryBuilder.java index 716d7cf1c2ae0..4dc4029cc61da 100644 --- a/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/query/ShapeQueryBuilder.java +++ b/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/query/ShapeQueryBuilder.java @@ -12,6 +12,7 @@ import org.elasticsearch.common.geo.parsers.ShapeParser; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -166,8 +167,7 @@ public static ShapeQueryBuilder fromXContent(XContentParser parser) throws IOExc ShapeQueryBuilder builder; if (pgsqb.type != null) { - deprecationLogger.deprecate( - "geo_share_query_with_types", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "geo_share_query_with_types", TYPES_DEPRECATION_MESSAGE); } if (pgsqb.shape != null) { diff --git a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/mapper/SparseVectorFieldMapper.java b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/mapper/SparseVectorFieldMapper.java index 571eafd51a213..d7761c58005a5 100644 --- a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/mapper/SparseVectorFieldMapper.java +++ b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/mapper/SparseVectorFieldMapper.java @@ -13,6 +13,7 @@ import org.apache.lucene.util.ArrayUtil; import org.apache.lucene.util.BytesRef; import org.elasticsearch.Version; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.XContentParser.Token; import org.elasticsearch.index.fielddata.IndexFieldData; @@ -75,7 +76,7 @@ name, new SparseVectorFieldType(buildFullName(contentPath), meta.getValue()), } public static final TypeParser PARSER = new TypeParser((n, c) -> { - deprecationLogger.deprecate("sparse_vector", DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.API, "sparse_vector", DEPRECATION_MESSAGE); return new Builder(n, c.indexVersionCreated()); }); diff --git a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/query/ScoreScriptUtils.java b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/query/ScoreScriptUtils.java index 7316c6afb8781..a55dd8994b5c9 100644 --- a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/query/ScoreScriptUtils.java +++ b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/query/ScoreScriptUtils.java @@ -10,6 +10,7 @@ import org.apache.lucene.util.BytesRef; import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.Version; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.script.ScoreScript; import org.elasticsearch.xpack.vectors.mapper.SparseVectorFieldMapper; @@ -79,7 +80,7 @@ public DenseVectorFunction(ScoreScript scoreScript, docValues = (DenseVectorScriptDocValues) scoreScript.getDoc().get(fieldName); } else if (field instanceof DenseVectorScriptDocValues) { docValues = (DenseVectorScriptDocValues) field; - deprecationLogger.deprecate("vector_function_signature", DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "vector_function_signature", DEPRECATION_MESSAGE); } else { throw new IllegalArgumentException("For vector functions, the 'field' argument must be of type String or " + "VectorScriptDocValues"); @@ -237,13 +238,14 @@ public SparseVectorFunction(ScoreScript scoreScript, docValues = (SparseVectorScriptDocValues) scoreScript.getDoc().get(fieldName); } else if (field instanceof SparseVectorScriptDocValues) { docValues = (SparseVectorScriptDocValues) field; - deprecationLogger.deprecate("vector_function_signature", DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.SCRIPTING, "vector_function_signature", DEPRECATION_MESSAGE); } else { throw new IllegalArgumentException("For vector functions, the 'field' argument must be of type String or " + "VectorScriptDocValues"); } - deprecationLogger.deprecate("sparse_vector_function", SparseVectorFieldMapper.DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.MAPPINGS, "sparse_vector_function", + SparseVectorFieldMapper.DEPRECATION_MESSAGE); } BytesRef getEncodedVector() { diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/IndexAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/IndexAction.java index b880c3d8cafba..9574e7144128c 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/IndexAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/IndexAction.java @@ -10,6 +10,7 @@ import org.elasticsearch.action.support.WriteRequest.RefreshPolicy; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.ParseField; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.time.DateUtils; import org.elasticsearch.common.unit.TimeValue; @@ -179,7 +180,7 @@ public static IndexAction parse(String watchId, String actionId, XContentParser } } else if (token == XContentParser.Token.VALUE_STRING) { if (Field.DOC_TYPE.match(currentFieldName, parser.getDeprecationHandler())) { - deprecationLogger.deprecate("watcher_index_action", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "watcher_index_action", TYPES_DEPRECATION_MESSAGE); docType = parser.text(); } else if (Field.DOC_ID.match(currentFieldName, parser.getDeprecationHandler())) { docId = parser.text(); diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java index d9a61611e4b93..8e436c8a1ea04 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/rest/action/RestWatcherStatsAction.java @@ -8,6 +8,7 @@ import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.LogManager; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.Strings; import org.elasticsearch.rest.RestRequest; @@ -60,7 +61,8 @@ protected RestChannelConsumer doPrepareRequest(final RestRequest restRequest, Wa } if (metrics.contains("pending_watches")) { - deprecationLogger.deprecate("pending_watches", "The pending_watches parameter is deprecated, use queued_watches instead"); + deprecationLogger.deprecate(DeprecationCategory.API, "pending_watches", + "The pending_watches parameter is deprecated, use queued_watches instead"); } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequest.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequest.java index 753fc9e98df15..07a415ef2059e 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequest.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequest.java @@ -13,6 +13,7 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; +import org.elasticsearch.common.logging.DeprecationCategory; import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -196,7 +197,7 @@ public static WatcherSearchTemplateRequest fromXContent(XContentParser parser, S } } } else if (TYPES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { - deprecationLogger.deprecate("watcher_search_input", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "watcher_search_input", TYPES_DEPRECATION_MESSAGE); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { if (token == XContentParser.Token.VALUE_STRING) { types.add(parser.textOrNull()); @@ -228,7 +229,7 @@ public static WatcherSearchTemplateRequest fromXContent(XContentParser parser, S String indicesStr = parser.text(); indices.addAll(Arrays.asList(Strings.delimitedListToStringArray(indicesStr, ",", " \t"))); } else if (TYPES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { - deprecationLogger.deprecate("watcher_search_input", TYPES_DEPRECATION_MESSAGE); + deprecationLogger.deprecate(DeprecationCategory.TYPES, "watcher_search_input", TYPES_DEPRECATION_MESSAGE); String typesStr = parser.text(); types.addAll(Arrays.asList(Strings.delimitedListToStringArray(typesStr, ",", " \t"))); } else if (SEARCH_TYPE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { From 7334dfe4a1df351818fd79069459d7caeaaa2e14 Mon Sep 17 00:00:00 2001 From: Rory Hunter Date: Wed, 27 Jan 2021 16:42:35 +0000 Subject: [PATCH 4/5] Fixes --- server/src/main/java/org/elasticsearch/common/joda/Joda.java | 5 +++-- .../java/org/elasticsearch/index/mapper/FieldMapper.java | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/common/joda/Joda.java b/server/src/main/java/org/elasticsearch/common/joda/Joda.java index 9595f92fb3650..f517dc5e2d1c3 100644 --- a/server/src/main/java/org/elasticsearch/common/joda/Joda.java +++ b/server/src/main/java/org/elasticsearch/common/joda/Joda.java @@ -405,8 +405,9 @@ public int parseInto(DateTimeParserBucket bucket, String text, int position) { " in epoch time formats is deprecated and will not be supported in the next major version of Elasticsearch."); } if (scientificNotation.matcher(text).find()) { - getDeprecationLogger().deprecate(DeprecationCategory.PARSING, "epoch-scientific-notation", "Use of scientific notation" + - " in epoch time formats is deprecated and will not be supported in the next major version of Elasticsearch."); + getDeprecationLogger().deprecate(DeprecationCategory.PARSING, "epoch-scientific-notation", + "Use of scientific notation in epoch time formats is deprecated and will not be supported in the " + + "next major version of Elasticsearch."); } DateTime dt = new DateTime(millis, DateTimeZone.UTC); bucket.saveField(DateTimeFieldType.year(), dt.getYear()); diff --git a/server/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java index 3b11753f7fb0d..7848c79665a78 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java @@ -986,7 +986,7 @@ public final void parse(String name, ParserContext parserContext, Map Date: Fri, 29 Jan 2021 13:12:36 +0000 Subject: [PATCH 5/5] Address review feedback --- .../main/java/org/elasticsearch/bootstrap/Bootstrap.java | 4 ++-- .../org/elasticsearch/index/mapper/DateFieldMapper.java | 4 ++-- .../elasticsearch/script/JodaCompatibleZonedDateTime.java | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java b/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java index 91d5eacfef5ee..683a4b2a9d7b2 100644 --- a/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java +++ b/server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java @@ -375,8 +375,8 @@ static void init( "The Java option es.xcontent.strict_duplicate_detection is set to [%s]; " + "this option is deprecated and non-functional and should be removed from Java configuration.", BootstrapInfo.getSystemProperties().get("es.xcontent.strict_duplicate_detection")); - DeprecationLogger.getLogger(Bootstrap.class).deprecate(DeprecationCategory.OTHER, "strict_duplicate_detection_setting_removed", - message); + DeprecationLogger.getLogger(Bootstrap.class).deprecate(DeprecationCategory.SETTINGS, + "strict_duplicate_detection_setting_removed", message); } if (environment.pidFile() != null) { try { diff --git a/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java index 7b9786264f4fc..ff32822003697 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java @@ -279,8 +279,8 @@ private Long parseNullValue(DateFieldType fieldType) { return fieldType.parse(nullValue.getValue()); } catch (Exception e) { DEPRECATION_LOGGER.deprecate(DeprecationCategory.MAPPINGS, "date_mapper_null_field", - "Error parsing [" + nullValue.getValue() - + "] as date in [null_value] on field [" + name() + "]); [null_value] will be ignored"); + "Error parsing [" + nullValue.getValue() + "] as date in [null_value] on field [" + name() + "]);" + + " [null_value] will be ignored"); return null; } } diff --git a/server/src/main/java/org/elasticsearch/script/JodaCompatibleZonedDateTime.java b/server/src/main/java/org/elasticsearch/script/JodaCompatibleZonedDateTime.java index f729aa6f28a25..b1effc30add5f 100644 --- a/server/src/main/java/org/elasticsearch/script/JodaCompatibleZonedDateTime.java +++ b/server/src/main/java/org/elasticsearch/script/JodaCompatibleZonedDateTime.java @@ -64,19 +64,19 @@ public class JodaCompatibleZonedDateTime private static final DateFormatter DATE_FORMATTER = DateFormatter.forPattern("strict_date_time"); private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(JodaCompatibleZonedDateTime.class); - private static void logDeprecated(DeprecationCategory category, String key, String message, Object... params) { + private static void logDeprecated(String key, String message, Object... params) { AccessController.doPrivileged(new PrivilegedAction() { @SuppressLoggerChecks(reason = "safely delegates to logger") @Override public Void run() { - deprecationLogger.deprecate(category, key, message, params); + deprecationLogger.deprecate(DeprecationCategory.PARSING, key, message, params); return null; } }); } private static void logDeprecatedMethod(String oldMethod, String newMethod) { - logDeprecated(DeprecationCategory.PARSING, oldMethod, "Use of the joda time method [{}] is deprecated. Use [{}] instead.", + logDeprecated(oldMethod, "Use of the joda time method [{}] is deprecated. Use [{}] instead.", oldMethod, newMethod); } @@ -520,7 +520,7 @@ public DayOfWeek getDayOfWeekEnum() { @Deprecated public int getDayOfWeek() { - logDeprecated(DeprecationCategory.PARSING, "getDayOfWeek()", + logDeprecated("getDayOfWeek()", "The return type of [getDayOfWeek()] will change to an enum in 7.0. Use getDayOfWeekEnum().getValue()."); return dt.getDayOfWeek().getValue(); }