From 3443d69883b45a28679221b4d53f80cb1b320521 Mon Sep 17 00:00:00 2001 From: Dimitris Athanasiou Date: Fri, 24 Jan 2020 09:51:48 +0200 Subject: [PATCH] [7.x][ML] Rename DataFrameAnalyticsIndex to DestinationIndex (#51353) (#51356) As we prepare to introduce a new index for storing additional information about data frame analytics jobs (e.g. intrumentation), renaming this class to `DestinationIndex` better captures what it does and leaves its prior name available for a more suitable use. Backport of #51353 Co-authored-by: Elastic Machine --- .../xpack/ml/dataframe/DataFrameAnalyticsManager.java | 6 +++--- ...aFrameAnalyticsIndex.java => DestinationIndex.java} | 6 +++--- .../ml/dataframe/extractor/DataFrameDataExtractor.java | 4 ++-- .../dataframe/extractor/ExtractedFieldsDetector.java | 4 ++-- ...yticsIndexTests.java => DestinationIndexTests.java} | 10 +++++----- 5 files changed, 15 insertions(+), 15 deletions(-) rename x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/{DataFrameAnalyticsIndex.java => DestinationIndex.java} (98%) rename x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/dataframe/{DataFrameAnalyticsIndexTests.java => DestinationIndexTests.java} (98%) diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsManager.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsManager.java index 788f5a3be33..e48485f6218 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsManager.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsManager.java @@ -186,7 +186,7 @@ public class DataFrameAnalyticsManager { reindexRequest.setSourceQuery(config.getSource().getParsedQuery()); reindexRequest.getSearchRequest().source().fetchSource(config.getSource().getSourceFiltering()); reindexRequest.setDestIndex(config.getDest().getIndex()); - reindexRequest.setScript(new Script("ctx._source." + DataFrameAnalyticsIndex.ID_COPY + " = ctx._id")); + reindexRequest.setScript(new Script("ctx._source." + DestinationIndex.ID_COPY + " = ctx._id")); final ThreadContext threadContext = client.threadPool().getThreadContext(); final Supplier supplier = threadContext.newRestorableContext(false); @@ -206,7 +206,7 @@ public class DataFrameAnalyticsManager { config.getId(), Messages.getMessage(Messages.DATA_FRAME_ANALYTICS_AUDIT_REUSING_DEST_INDEX, indexResponse.indices()[0])); LOGGER.info("[{}] Using existing destination index [{}]", config.getId(), indexResponse.indices()[0]); - DataFrameAnalyticsIndex.updateMappingsToDestIndex(client, config, indexResponse, ActionListener.wrap( + DestinationIndex.updateMappingsToDestIndex(client, config, indexResponse, ActionListener.wrap( acknowledgedResponse -> copyIndexCreatedListener.onResponse(null), copyIndexCreatedListener::onFailure )); @@ -217,7 +217,7 @@ public class DataFrameAnalyticsManager { config.getId(), Messages.getMessage(Messages.DATA_FRAME_ANALYTICS_AUDIT_CREATING_DEST_INDEX, config.getDest().getIndex())); LOGGER.info("[{}] Creating destination index [{}]", config.getId(), config.getDest().getIndex()); - DataFrameAnalyticsIndex.createDestinationIndex(client, Clock.systemUTC(), config, copyIndexCreatedListener); + DestinationIndex.createDestinationIndex(client, Clock.systemUTC(), config, copyIndexCreatedListener); } else { copyIndexCreatedListener.onFailure(e); } diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsIndex.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DestinationIndex.java similarity index 98% rename from x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsIndex.java rename to x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DestinationIndex.java index f7387aa4da9..feadf14aee2 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsIndex.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/DestinationIndex.java @@ -43,9 +43,9 @@ import java.util.function.Supplier; import static org.elasticsearch.xpack.core.ClientHelper.ML_ORIGIN; /** - * {@link DataFrameAnalyticsIndex} class encapsulates logic for creating destination index based on source index metadata. + * {@link DestinationIndex} class encapsulates logic for creating destination index based on source index metadata. */ -public final class DataFrameAnalyticsIndex { +public final class DestinationIndex { public static final String ID_COPY = "ml__id_copy"; @@ -66,7 +66,7 @@ public final class DataFrameAnalyticsIndex { */ private static final String[] PRESERVED_SETTINGS = new String[] {"index.number_of_shards", "index.number_of_replicas"}; - private DataFrameAnalyticsIndex() {} + private DestinationIndex() {} /** * Creates destination index based on source index metadata. diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/extractor/DataFrameDataExtractor.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/extractor/DataFrameDataExtractor.java index 7448a1af6eb..a2ce8cf60d4 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/extractor/DataFrameDataExtractor.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/extractor/DataFrameDataExtractor.java @@ -24,7 +24,7 @@ import org.elasticsearch.search.fetch.StoredFieldsContext; import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.xpack.core.ClientHelper; import org.elasticsearch.xpack.core.ml.dataframe.analyses.DataFrameAnalysis; -import org.elasticsearch.xpack.ml.dataframe.DataFrameAnalyticsIndex; +import org.elasticsearch.xpack.ml.dataframe.DestinationIndex; import org.elasticsearch.xpack.ml.extractor.ExtractedField; import java.io.IOException; @@ -131,7 +131,7 @@ public class DataFrameDataExtractor { .setScroll(SCROLL_TIMEOUT) // This ensures the search throws if there are failures and the scroll context gets cleared automatically .setAllowPartialSearchResults(false) - .addSort(DataFrameAnalyticsIndex.ID_COPY, SortOrder.ASC) + .addSort(DestinationIndex.ID_COPY, SortOrder.ASC) .setIndices(context.indices) .setSize(context.scrollSize) .setQuery(context.query); diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/extractor/ExtractedFieldsDetector.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/extractor/ExtractedFieldsDetector.java index 59bf379fbd6..be5ea6b83ea 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/extractor/ExtractedFieldsDetector.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/dataframe/extractor/ExtractedFieldsDetector.java @@ -26,7 +26,7 @@ import org.elasticsearch.xpack.core.ml.dataframe.explain.FieldSelection; import org.elasticsearch.xpack.core.ml.job.messages.Messages; import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper; import org.elasticsearch.xpack.core.ml.utils.NameResolver; -import org.elasticsearch.xpack.ml.dataframe.DataFrameAnalyticsIndex; +import org.elasticsearch.xpack.ml.dataframe.DestinationIndex; import org.elasticsearch.xpack.ml.extractor.ExtractedField; import org.elasticsearch.xpack.ml.extractor.ExtractedFields; @@ -52,7 +52,7 @@ public class ExtractedFieldsDetector { * Fields to ignore. These are mostly internal meta fields. */ private static final List IGNORE_FIELDS = Arrays.asList("_id", "_field_names", "_index", "_parent", "_routing", "_seq_no", - "_source", "_type", "_uid", "_version", "_feature", "_ignored", DataFrameAnalyticsIndex.ID_COPY); + "_source", "_type", "_uid", "_version", "_feature", "_ignored", DestinationIndex.ID_COPY); private final String[] index; private final DataFrameAnalyticsConfig config; diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsIndexTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/dataframe/DestinationIndexTests.java similarity index 98% rename from x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsIndexTests.java rename to x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/dataframe/DestinationIndexTests.java index 785dbe869d8..b12914cd758 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/dataframe/DataFrameAnalyticsIndexTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/dataframe/DestinationIndexTests.java @@ -68,7 +68,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; -public class DataFrameAnalyticsIndexTests extends ESTestCase { +public class DestinationIndexTests extends ESTestCase { private static final String ANALYTICS_ID = "some-analytics-id"; private static final String[] SOURCE_INDEX = new String[] {"source-index"}; @@ -155,7 +155,7 @@ public class DataFrameAnalyticsIndexTests extends ESTestCase { doAnswer(callListenerOnResponse(getMappingsResponse)) .when(client).execute(eq(GetMappingsAction.INSTANCE), getMappingsRequestCaptor.capture(), any()); - DataFrameAnalyticsIndex.createDestinationIndex( + DestinationIndex.createDestinationIndex( client, clock, config, @@ -246,7 +246,7 @@ public class DataFrameAnalyticsIndexTests extends ESTestCase { doAnswer(callListenerOnResponse(getSettingsResponse)).when(client).execute(eq(GetSettingsAction.INSTANCE), any(), any()); doAnswer(callListenerOnResponse(getMappingsResponse)).when(client).execute(eq(GetMappingsAction.INSTANCE), any(), any()); - DataFrameAnalyticsIndex.createDestinationIndex( + DestinationIndex.createDestinationIndex( client, clock, config, @@ -290,7 +290,7 @@ public class DataFrameAnalyticsIndexTests extends ESTestCase { doAnswer(callListenerOnResponse(new AcknowledgedResponse(true))) .when(client).execute(eq(PutMappingAction.INSTANCE), putMappingRequestCaptor.capture(), any()); - DataFrameAnalyticsIndex.updateMappingsToDestIndex( + DestinationIndex.updateMappingsToDestIndex( client, config, getIndexResponse, @@ -362,7 +362,7 @@ public class DataFrameAnalyticsIndexTests extends ESTestCase { ElasticsearchStatusException e = expectThrows( ElasticsearchStatusException.class, - () -> DataFrameAnalyticsIndex.updateMappingsToDestIndex( + () -> DestinationIndex.updateMappingsToDestIndex( client, config, getIndexResponse, ActionListener.wrap(Assert::fail))); assertThat( e.getMessage(),