From cf6f3fc728dbffaad91cd5a2a7e1b07d53d10095 Mon Sep 17 00:00:00 2001 From: Henning Andersen Date: Tue, 3 Dec 2019 19:26:09 +0100 Subject: [PATCH 1/5] Reindex resolve indices early Resolve indices before starting to reindex. This ensures that the list of indices does not change when failing over (TBD). The one exception to this is aliases, which we still need to access through the alias. In addition, resolved index patterns are sorted by create-date and otherwise the listed order is preserved. This ensures that once we reindex one index at a time, we will get reasonable time locality for time based indices. The resolved list of indices will also by used to do searching one index (or index group) at a time, improving search performance (since we use sort) and allowing us to do more fine-grained checkpoint and track progress (TBD). Relates #42612 --- .../common/xcontent/AbstractObjectParser.java | 1 + .../common/xcontent/ObjectParserTests.java | 11 +- .../index/reindex/ReindexTaskParams.java | 18 +- .../TransportStartReindexTaskAction.java | 178 +++++++++++++++++- .../index/reindex/ReindexTaskParamsTests.java | 88 +++++++++ .../TransportStartReindexTaskActionTests.java | 135 +++++++++++++ 6 files changed, 427 insertions(+), 4 deletions(-) create mode 100644 modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexTaskParamsTests.java create mode 100644 modules/reindex/src/test/java/org/elasticsearch/index/reindex/TransportStartReindexTaskActionTests.java diff --git a/libs/x-content/src/main/java/org/elasticsearch/common/xcontent/AbstractObjectParser.java b/libs/x-content/src/main/java/org/elasticsearch/common/xcontent/AbstractObjectParser.java index fcf1446e53c44..2501a1b2e90c5 100644 --- a/libs/x-content/src/main/java/org/elasticsearch/common/xcontent/AbstractObjectParser.java +++ b/libs/x-content/src/main/java/org/elasticsearch/common/xcontent/AbstractObjectParser.java @@ -225,6 +225,7 @@ private static List parseArray(XContentParser parser, IOSupplier suppl while (parser.nextToken() != XContentParser.Token.END_ARRAY) { if (parser.currentToken().isValue() || parser.currentToken() == XContentParser.Token.VALUE_NULL + || parser.currentToken() == XContentParser.Token.START_ARRAY || parser.currentToken() == XContentParser.Token.START_OBJECT) { list.add(supplier.get()); } else { diff --git a/libs/x-content/src/test/java/org/elasticsearch/common/xcontent/ObjectParserTests.java b/libs/x-content/src/test/java/org/elasticsearch/common/xcontent/ObjectParserTests.java index a2c45eceb8d58..c573c45265543 100644 --- a/libs/x-content/src/test/java/org/elasticsearch/common/xcontent/ObjectParserTests.java +++ b/libs/x-content/src/test/java/org/elasticsearch/common/xcontent/ObjectParserTests.java @@ -585,13 +585,15 @@ class TestStruct { public void testArraysOfGenericValues() throws IOException { XContentParser parser = createParser( JsonXContent.jsonXContent, - "{ \"test_array\": [ 1, null, \"3\", 4.2], \"int_array\": [ 1, 2, 3] }" + "{ \"test_array\": [ 1, null, \"3\", 4.2], \"int_array\": [ 1, 2, 3], \"multi_array\": [ [1, 2], [3, 4] ] }" ); class TestStruct { List testArray = new ArrayList<>(); List ints = new ArrayList<>(); + List > multis = new ArrayList<>(); + public void setInts(List ints) { this.ints = ints; } @@ -599,6 +601,10 @@ public void setInts(List ints) { public void setArray(List testArray) { this.testArray = testArray; } + + public void setMultis(List> multis) { + this.multis = multis; + } } ObjectParser objectParser = new ObjectParser<>("foo"); TestStruct s = new TestStruct(); @@ -606,9 +612,12 @@ public void setArray(List testArray) { objectParser.declareFieldArray(TestStruct::setArray, (p, c) -> XContentParserUtils.parseFieldsValue(p), new ParseField("test_array"), ValueType.VALUE_ARRAY); objectParser.declareIntArray(TestStruct::setInts, new ParseField("int_array")); + objectParser.declareFieldArray(TestStruct::setMultis, (p, c) -> (List) XContentParserUtils.parseFieldsValue(p), + new ParseField("multi_array"), ValueType.OBJECT_ARRAY); objectParser.parse(parser, s, null); assertEquals(s.testArray, Arrays.asList(1, null, "3", 4.2)); assertEquals(s.ints, Arrays.asList(1, 2, 3)); + assertEquals(s.multis, Arrays.asList(Arrays.asList(1, 2), Arrays.asList(3, 4))); parser = createParser(JsonXContent.jsonXContent, "{\"test_array\": 42}"); s = new TestStruct(); diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexTaskParams.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexTaskParams.java index e8788730b56b1..1e9cd3c7958db 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexTaskParams.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexTaskParams.java @@ -29,6 +29,8 @@ import org.elasticsearch.persistent.PersistentTaskParams; import java.io.IOException; +import java.util.Collection; +import java.util.List; import java.util.Map; public class ReindexTaskParams implements PersistentTaskParams { @@ -37,26 +39,32 @@ public class ReindexTaskParams implements PersistentTaskParams { @SuppressWarnings("unchecked") public static final ConstructingObjectParser PARSER - = new ConstructingObjectParser<>(NAME, a -> new ReindexTaskParams((Boolean) a[0], (Map) a[1])); + = new ConstructingObjectParser<>(NAME, a -> new ReindexTaskParams((Boolean) a[0], (List>) a[1], + (Map) a[2])); private static String STORE_RESULT = "store_result"; private static String HEADERS = "headers"; + private static String INDEX_GROUPS = "index_groups"; static { PARSER.declareBoolean(ConstructingObjectParser.constructorArg(), new ParseField(STORE_RESULT)); + PARSER.declareObjectArray(ConstructingObjectParser.constructorArg(), (p, c) -> p.list(), new ParseField(INDEX_GROUPS)); PARSER.declareObject(ConstructingObjectParser.constructorArg(), (p, c) -> p.mapStrings(), new ParseField(HEADERS)); } private final boolean storeResult; + private final List> indexGroups; private final Map headers; - public ReindexTaskParams(boolean storeResult, Map headers) { + public ReindexTaskParams(boolean storeResult, List> indexGroups, Map headers) { this.storeResult = storeResult; + this.indexGroups = indexGroups; this.headers = headers; } public ReindexTaskParams(StreamInput in) throws IOException { storeResult = in.readBoolean(); + indexGroups = in.readList(StreamInput::readStringList); headers = in.readMap(StreamInput::readString, StreamInput::readString); } @@ -74,6 +82,7 @@ public Version getMinimalSupportedVersion() { @Override public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(storeResult); + out.writeCollection(indexGroups, StreamOutput::writeStringCollection); out.writeMap(headers, StreamOutput::writeString, StreamOutput::writeString); } @@ -81,6 +90,7 @@ public void writeTo(StreamOutput out) throws IOException { public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); builder.field(STORE_RESULT, storeResult); + builder.field(INDEX_GROUPS, indexGroups); builder.field(HEADERS, headers); return builder.endObject(); } @@ -89,6 +99,10 @@ public boolean shouldStoreResult() { return storeResult; } + public List> getIndexGroups() { + return indexGroups; + } + public Map getHeaders() { return headers; } diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/TransportStartReindexTaskAction.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/TransportStartReindexTaskAction.java index 8d831305304cc..39fb237e1326a 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/TransportStartReindexTaskAction.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/TransportStartReindexTaskAction.java @@ -26,6 +26,9 @@ import org.elasticsearch.action.support.AutoCreateIndex; import org.elasticsearch.action.support.HandledTransportAction; import org.elasticsearch.client.Client; +import org.elasticsearch.cluster.ClusterState; +import org.elasticsearch.cluster.metadata.AliasOrIndex; +import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.UUIDs; @@ -33,6 +36,7 @@ import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; +import org.elasticsearch.common.util.set.Sets; import org.elasticsearch.common.xcontent.NamedXContentRegistry; import org.elasticsearch.persistent.PersistentTasksCustomMetaData; import org.elasticsearch.persistent.PersistentTasksService; @@ -41,10 +45,18 @@ import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportService; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.SortedMap; import java.util.function.Predicate; import java.util.stream.Collectors; +import java.util.stream.Stream; public class TransportStartReindexTaskAction extends HandledTransportAction { @@ -52,6 +64,8 @@ public class TransportStartReindexTaskAction private final List headersToInclude; private final ThreadPool threadPool; private final PersistentTasksService persistentTasksService; + private final IndexNameExpressionResolver indexNameExpressionResolver; + private final ClusterService clusterService; private final ReindexValidator reindexValidator; private final ReindexIndexClient reindexIndexClient; @@ -63,6 +77,8 @@ public TransportStartReindexTaskAction(Settings settings, Client client, Transpo super(StartReindexTaskAction.NAME, transportService, actionFilters, StartReindexTaskAction.Request::new); this.headersToInclude = ReindexHeaders.REINDEX_INCLUDED_HEADERS.get(settings); this.threadPool = threadPool; + this.indexNameExpressionResolver = indexNameExpressionResolver; + this.clusterService = clusterService; this.reindexValidator = new ReindexValidator(settings, clusterService, indexNameExpressionResolver, autoCreateIndex); this.persistentTasksService = persistentTasksService; this.reindexIndexClient = new ReindexIndexClient(client, clusterService, xContentRegistry); @@ -87,7 +103,7 @@ protected void doExecute(Task task, StartReindexTaskAction.Request request, Acti // In the current implementation, we only need to store task results if we do not wait for completion boolean storeTaskResult = request.getWaitForCompletion() == false; - ReindexTaskParams job = new ReindexTaskParams(storeTaskResult, included); + ReindexTaskParams job = new ReindexTaskParams(storeTaskResult, resolveIndexPatterns(request.getReindexRequest()), included); ReindexTaskStateDoc reindexState = new ReindexTaskStateDoc(request.getReindexRequest()); reindexIndexClient.createReindexTaskDoc(generatedId, reindexState, new ActionListener<>() { @@ -212,4 +228,164 @@ private boolean isDone(ReindexPersistentTaskState state) { return state != null && state.isDone(); } } + + /** + * Resolve index patterns to ensure they do not start resolving differently during reindex failovers. + * Do not resolve aliases, since accessing the underlying indices is not semantically equivalent to accessing the alias. + * Within each index pattern, sort the resolved indices by create date, since this ensures that if we reindex from a pattern of indices, + * destination will receive oldest data first. This is in particular important if destination does rollover and it is time-based data. + * + * @return list of groups of indices/aliases that must be searched together. + */ + private List> resolveIndexPatterns(ReindexRequest request) { + return resolveIndexPatterns(request, clusterService.state(), indexNameExpressionResolver); + } + + // visible for testing + static List> resolveIndexPatterns(ReindexRequest request, ClusterState clusterState, + IndexNameExpressionResolver indexNameResolver) { + if (request.getRemoteInfo() == null) { + return resolveIndexPatterns(request.getSearchRequest().indices(), clusterState, indexNameResolver); + } else { + return Collections.emptyList(); + } + } + + private static List> resolveIndexPatterns(String[] indices, ClusterState clusterState, + IndexNameExpressionResolver indexNameResolver) { + Set resolvedNames = indexNameResolver.resolveExpressions(clusterState, indices); + + List groups = Arrays.stream(indices) + .flatMap(expression -> resolveSingleIndexExpression(expression, resolvedNames::contains,clusterState, indexNameResolver)) + .collect(Collectors.toList()); + + return resolveGroups(groups).stream().map(IndexGroup::newResolvedGroup).collect(Collectors.toList()); + } + + private static List resolveGroups(List groups) { + List result = new ArrayList<>(groups); + + // n^2, but OK since data volume is low. + // reverse order since we bubble data towards the lower index end. + for (int i = result.size() - 1; i >= 0; --i) { + IndexGroup current = result.get(i); + for (int j = i - 1; current != null && j >= 0; --j) { + IndexGroup earlier = result.get(j); + Tuple collapsed = earlier.collapse(current); + result.set(j, collapsed.v1()); + current = collapsed.v2(); + } + result.set(i, current); + } + + return result.stream().filter(Objects::nonNull).collect(Collectors.toList()); + } + + private static Stream resolveSingleIndexExpression(String expression, Predicate predicate, + ClusterState clusterState, + IndexNameExpressionResolver indexNameExpressionResolver) { + SortedMap lookup = clusterState.getMetaData().getAliasAndIndexLookup(); + Comparator createDateIndexOrder = (i1, i2) -> { + if (i1.isAlias() && i2.isAlias()) { + return ((AliasOrIndex.Alias) i1).getAliasName().compareTo(((AliasOrIndex.Alias) i2).getAliasName()); + } + if (i1.isAlias() != i2.isAlias()) { + return Boolean.compare(i1.isAlias(), i2.isAlias()); + } + + assert i1.getIndices().size() == 1; + assert i2.getIndices().size() == 1; + IndexMetaData indexMetaData1 = i1.getIndices().get(0); + IndexMetaData indexMetaData2 = i2.getIndices().get(0); + int compare = Long.compare(indexMetaData1.getCreationDate(), indexMetaData2.getCreationDate()); + return compare != 0 ? compare : indexMetaData1.getIndex().getName().compareTo(indexMetaData2.getIndex().getName()); + }; + + return indexNameExpressionResolver.resolveExpressions(clusterState, expression).stream() + .filter(predicate).map(lookup::get).sorted(createDateIndexOrder).map(IndexGroup::create); + } + + /** + * Immutable group of indices and aliases. + */ + private static class IndexGroup { + private final Set indices; + private final Set allIndices; + private final Set aliases; + private final List orderedIndices; + + private IndexGroup(List indices, Set aliases) { + orderedIndices = indices; + this.indices = indices.stream().collect(Collectors.toUnmodifiableSet()); + this.aliases = aliases; + this.allIndices = Stream.concat(indices.stream(), + aliases.stream().flatMap(aliasOrIndex -> aliasOrIndex.getIndices().stream()) + .map(imd -> imd.getIndex().getName()) + ).collect(Collectors.toUnmodifiableSet()); + } + + private IndexGroup(IndexGroup group1, IndexGroup group2) { + this(Stream.concat(group1.orderedIndices.stream(), group2.orderedIndices.stream()).collect(Collectors.toList()), + Stream.concat(group1.aliases.stream(), group2.aliases.stream()) + .collect(Collectors.toSet())); + } + + public static IndexGroup create(AliasOrIndex aliasOrIndex) { + if (aliasOrIndex.isAlias()) { + return new IndexGroup(Collections.emptyList(), Collections.singleton((AliasOrIndex.Alias) aliasOrIndex)); + } else { + return new IndexGroup(Collections.singletonList(aliasOrIndex.getIndices().get(0).getIndex().getName()), + Collections.emptySet()); + } + } + + private Tuple collapse(IndexGroup other) { + if (other == this) { + return Tuple.tuple(this, this); + } + + if (aliasOverlap(this.aliases, other.allIndices) || aliasOverlap(other.aliases, this.allIndices)) { + return Tuple.tuple(new IndexGroup(this, other), null); + } + + Set intersection = Sets.intersection(indices, other.indices); + assert intersection.isEmpty() == false || Sets.intersection(allIndices, other.allIndices).isEmpty(); + assert intersection.isEmpty() || Sets.intersection(allIndices, other.allIndices).isEmpty() == false; + return Tuple.tuple(this.add(intersection, orderedIndices), other.subtract(intersection)); + } + + private IndexGroup add(Set intersection, List order) { + if (intersection.isEmpty()) { + return this; + } + + List indices = + Stream.concat(this.orderedIndices.stream(), order.stream().filter(intersection::contains)).collect(Collectors.toList()); + return new IndexGroup(indices, aliases); + } + + private IndexGroup subtract(Set intersection) { + if (intersection.isEmpty()) { + return this; + } + + List indices = + this.orderedIndices.stream().filter(Predicate.not(intersection::contains)).collect(Collectors.toList()); + + if (indices.isEmpty()) { + return null; + } + return new IndexGroup(indices, aliases); + } + + private static boolean aliasOverlap(Set aliases, Set indices) { + return aliases.stream() + .flatMap(aliasOrIndex -> aliasOrIndex.getIndices().stream()).map(imd -> imd.getIndex().getName()) + .anyMatch(indices::contains); + } + + public Set newResolvedGroup() { + return Stream.concat(indices.stream(), aliases.stream().map(AliasOrIndex.Alias::getAliasName)).collect(Collectors.toSet()); + } + } } diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexTaskParamsTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexTaskParamsTests.java new file mode 100644 index 0000000000000..4e79993011ec8 --- /dev/null +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexTaskParamsTests.java @@ -0,0 +1,88 @@ +/* + * 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.index.reindex; + +import org.elasticsearch.common.io.stream.BytesStreamOutput; +import org.elasticsearch.common.io.stream.StreamInput; +import org.elasticsearch.common.xcontent.XContentParser; +import org.elasticsearch.test.AbstractXContentTestCase; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + + +// todo: test more then the index_groups field. +public class ReindexTaskParamsTests extends AbstractXContentTestCase { + + @Override + protected ReindexTaskParams createTestInstance() { + return new ReindexTaskParams(randomBoolean(), + IntStream.range(0, randomInt(20)).mapToObj(i -> setOrListOfStrings()).collect(Collectors.toList()), + new HashMap<>()); + } + + private Collection setOrListOfStrings() { + Set strings = randomUnique(() -> randomAlphaOfLength(10), randomInt(10)); + if (randomBoolean()) { + return strings; + } else { + return new ArrayList<>(strings); + } + } + + @Override + protected ReindexTaskParams doParseInstance(XContentParser parser) throws IOException { + return ReindexTaskParams.fromXContent(parser); + } + + @Override + protected boolean supportsUnknownFields() { + return false; + } + + @Override + protected void assertEqualInstances(ReindexTaskParams expectedInstance, ReindexTaskParams newInstance) { + assertNotSame(newInstance, expectedInstance); + + List> expectedGroups = expectedInstance.getIndexGroups().stream().map(HashSet::new).collect(Collectors.toList()); + List> newGroups = expectedInstance.getIndexGroups().stream().map(HashSet::new).collect(Collectors.toList()); + + assertEquals(expectedGroups, newGroups); + } + + public void testSerialization() throws IOException { + ReindexTaskParams before = createTestInstance(); + + final BytesStreamOutput out = new BytesStreamOutput(); + before.writeTo(out); + + final StreamInput in = out.bytes().streamInput(); + + ReindexTaskParams after = new ReindexTaskParams(in); + + assertEqualInstances(before, after); + } +} diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/TransportStartReindexTaskActionTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/TransportStartReindexTaskActionTests.java new file mode 100644 index 0000000000000..e47350c116c4c --- /dev/null +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/TransportStartReindexTaskActionTests.java @@ -0,0 +1,135 @@ +/* + * 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.index.reindex; + +import org.elasticsearch.Version; +import org.elasticsearch.cluster.ClusterName; +import org.elasticsearch.cluster.ClusterState; +import org.elasticsearch.cluster.metadata.AliasMetaData; +import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; +import org.elasticsearch.cluster.metadata.MetaData; +import org.elasticsearch.common.bytes.BytesArray; +import org.elasticsearch.common.unit.TimeValue; +import org.elasticsearch.test.ESTestCase; + +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Set; +import java.util.concurrent.atomic.AtomicLong; +import java.util.function.Function; +import java.util.function.LongSupplier; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class TransportStartReindexTaskActionTests extends ESTestCase { + + public void testResolveIndexPatternOrder() { + final AtomicLong time = new AtomicLong(randomLongBetween(0, 1L << 33)); + + LongSupplier timeSupplier = () -> time.getAndAdd(randomLongBetween(0, 2)); + MetaData.Builder builder = MetaData.builder(); + int count = randomInt(9); + IntStream.range(0, count).mapToObj(i -> indexMetaData("b-0" + i, timeSupplier.getAsLong())).forEach(builder::put); + IntStream.range(0, count).mapToObj(i -> indexMetaData("c-0" + (9 - i), timeSupplier.getAsLong())).forEach(builder::put); + ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT).metaData(builder).build(); + + List> expectedCs = IntStream.range(0, count).mapToObj(i -> "c-0" + (9 - i)) + .sorted(Comparator.comparingLong(n -> + clusterState.metaData().getIndices().get(n).getCreationDate()).thenComparing(Function.identity())) + .map(Set::of).collect(Collectors.toList()); + List> expectedBs = IntStream.range(0, count).mapToObj(i -> "b-0" + i) + .map(Set::of).collect(Collectors.toList()); + + List> expectedCB = Stream.concat(expectedCs.stream(), expectedBs.stream()).collect(Collectors.toList()); + List> expectedBC = Stream.concat(expectedBs.stream(), expectedCs.stream()).collect(Collectors.toList()); + + checkResolved(clusterState, expectedCB, "c-*", "b-*"); + checkResolved(clusterState, expectedCB, "c-*", "*"); + checkResolved(clusterState, expectedBC, "*"); + checkResolved(clusterState, expectedBC, "*", "c-*"); + checkResolved(clusterState, expectedBC, "*", "c-*", "b-*"); + checkResolved(clusterState, expectedCs, "c-*"); + checkResolved(clusterState, expectedBs, "b-*"); + } + + public void testAliasOverlap() { + MetaData.Builder builder = MetaData.builder(); + builder.put(indexMetaData("b", 0).putAlias(AliasMetaData.builder("a")).putAlias(AliasMetaData.builder("a2"))); + builder.put(indexMetaData("c", 0)); + builder.put(indexMetaData("d", 0).putAlias(AliasMetaData.builder("a2"))); + builder.put(indexMetaData("nothit", 0)); + ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT).metaData(builder).build(); + + checkResolved(clusterState, Arrays.asList(Set.of("b", "a"), Set.of("c")), "b", "c", "a"); + checkResolved(clusterState, Arrays.asList(Set.of("b", "a"), Set.of("c")), "a", "c", "b"); + checkResolved(clusterState, Arrays.asList(Set.of("b", "a"), Set.of("c")), "a", "b", "c"); + checkResolved(clusterState, Arrays.asList(Set.of("c"), Set.of("b", "a")), "c", "a", "b"); + checkResolved(clusterState, Arrays.asList(Set.of("a", "a2"), Set.of("c")), "a", "c", "a2"); + checkResolved(clusterState, Arrays.asList(Set.of("b", "a", "a2"), Set.of("c")), "b", "c", "a", "a2"); + checkResolved(clusterState, Arrays.asList(Set.of("b", "d", "a", "a2"), Set.of("c")), "b", "c", "d", "a", "a2"); + checkResolved(clusterState, Arrays.asList(Set.of("b", "d", "a", "a2"), Set.of("c")), "b", "c", "d", "a*"); + } + + public void testIndexOverlap() { + MetaData.Builder builder = MetaData.builder(); + builder.put(indexMetaData("aa", 0)); + builder.put(indexMetaData("ab", 0)); + builder.put(indexMetaData("ab2", 0)); + builder.put(indexMetaData("nothit", 0)); + ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT).metaData(builder).build(); + + checkResolved(clusterState, Arrays.asList(Set.of("aa"), Set.of("ab"), Set.of("ab2")), "aa", "ab", "a*"); + checkResolved(clusterState, Arrays.asList(Set.of("ab"), Set.of("aa"), Set.of("ab2")), "ab", "a*"); + checkResolved(clusterState, Arrays.asList(Set.of("aa"), Set.of("ab"), Set.of("ab2")), "aa", "ab", "ab*"); + checkResolved(clusterState, Arrays.asList(Set.of("aa"), Set.of("ab"), Set.of("ab2")), "aa", "aa*", "ab*"); + } + + public void testRemoteReindex() { + MetaData.Builder builder = MetaData.builder(); + builder.put(indexMetaData("a", 0)); + ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT).metaData(builder).build(); + + ReindexRequest request = new ReindexRequest().setSourceIndices("*"); + request.setRemoteInfo(new RemoteInfo("http", "localhost", -1, "/", new BytesArray("{}"), "me", "me", Collections.emptyMap(), + TimeValue.ZERO, TimeValue.ZERO)); + List> resolved = TransportStartReindexTaskAction.resolveIndexPatterns(request, + clusterState, + new IndexNameExpressionResolver()); + + assertEquals(Collections.emptyList(), resolved); + } + + private IndexMetaData.Builder indexMetaData(String name, long creationDate) { + return IndexMetaData.builder(name).settings(settings(Version.CURRENT)) + .creationDate(creationDate).numberOfShards(1).numberOfReplicas(0); + } + + private void checkResolved(ClusterState clusterState, List> expected, String... input) { + ReindexRequest request = new ReindexRequest().setSourceIndices(input); + List> resolved = TransportStartReindexTaskAction.resolveIndexPatterns(request, + clusterState, + new IndexNameExpressionResolver()); + + assertEquals(expected, resolved); + } +} From 48f7a8d8f8007e34a4af4ae4201da2088ce2e81f Mon Sep 17 00:00:00 2001 From: Henning Andersen Date: Thu, 5 Dec 2019 11:04:37 +0100 Subject: [PATCH 2/5] Fix test compilation. --- .../elasticsearch/common/xcontent/ObjectParserTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/x-content/src/test/java/org/elasticsearch/common/xcontent/ObjectParserTests.java b/libs/x-content/src/test/java/org/elasticsearch/common/xcontent/ObjectParserTests.java index c573c45265543..def2ce32849cb 100644 --- a/libs/x-content/src/test/java/org/elasticsearch/common/xcontent/ObjectParserTests.java +++ b/libs/x-content/src/test/java/org/elasticsearch/common/xcontent/ObjectParserTests.java @@ -592,7 +592,7 @@ class TestStruct { List ints = new ArrayList<>(); - List > multis = new ArrayList<>(); + List > multis = new ArrayList<>(); public void setInts(List ints) { this.ints = ints; @@ -602,7 +602,7 @@ public void setArray(List testArray) { this.testArray = testArray; } - public void setMultis(List> multis) { + public void setMultis(List> multis) { this.multis = multis; } } @@ -612,7 +612,7 @@ public void setMultis(List> multis) { objectParser.declareFieldArray(TestStruct::setArray, (p, c) -> XContentParserUtils.parseFieldsValue(p), new ParseField("test_array"), ValueType.VALUE_ARRAY); objectParser.declareIntArray(TestStruct::setInts, new ParseField("int_array")); - objectParser.declareFieldArray(TestStruct::setMultis, (p, c) -> (List) XContentParserUtils.parseFieldsValue(p), + objectParser.declareFieldArray(TestStruct::setMultis, (p, c) -> p.list(), new ParseField("multi_array"), ValueType.OBJECT_ARRAY); objectParser.parse(parser, s, null); assertEquals(s.testArray, Arrays.asList(1, null, "3", 4.2)); From 33d8fd4ce0f41b8bf43453feacfc74108d618fe2 Mon Sep 17 00:00:00 2001 From: Henning Andersen Date: Tue, 10 Dec 2019 15:22:05 +0100 Subject: [PATCH 3/5] How could I.... --- .../index/reindex/ReindexTaskParams.java | 18 +------- .../index/reindex/ReindexTaskStateDoc.java | 41 +++++++++++++------ .../TransportStartReindexTaskAction.java | 5 ++- .../reindex/ReindexIndexClientTests.java | 3 +- ...sts.java => ReindexTaskStateDocTests.java} | 31 ++++---------- .../reindex/ReindexTaskStateUpdaterTests.java | 2 +- 6 files changed, 44 insertions(+), 56 deletions(-) rename modules/reindex/src/test/java/org/elasticsearch/index/reindex/{ReindexTaskParamsTests.java => ReindexTaskStateDocTests.java} (66%) diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexTaskParams.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexTaskParams.java index 1e9cd3c7958db..e8788730b56b1 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexTaskParams.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexTaskParams.java @@ -29,8 +29,6 @@ import org.elasticsearch.persistent.PersistentTaskParams; import java.io.IOException; -import java.util.Collection; -import java.util.List; import java.util.Map; public class ReindexTaskParams implements PersistentTaskParams { @@ -39,32 +37,26 @@ public class ReindexTaskParams implements PersistentTaskParams { @SuppressWarnings("unchecked") public static final ConstructingObjectParser PARSER - = new ConstructingObjectParser<>(NAME, a -> new ReindexTaskParams((Boolean) a[0], (List>) a[1], - (Map) a[2])); + = new ConstructingObjectParser<>(NAME, a -> new ReindexTaskParams((Boolean) a[0], (Map) a[1])); private static String STORE_RESULT = "store_result"; private static String HEADERS = "headers"; - private static String INDEX_GROUPS = "index_groups"; static { PARSER.declareBoolean(ConstructingObjectParser.constructorArg(), new ParseField(STORE_RESULT)); - PARSER.declareObjectArray(ConstructingObjectParser.constructorArg(), (p, c) -> p.list(), new ParseField(INDEX_GROUPS)); PARSER.declareObject(ConstructingObjectParser.constructorArg(), (p, c) -> p.mapStrings(), new ParseField(HEADERS)); } private final boolean storeResult; - private final List> indexGroups; private final Map headers; - public ReindexTaskParams(boolean storeResult, List> indexGroups, Map headers) { + public ReindexTaskParams(boolean storeResult, Map headers) { this.storeResult = storeResult; - this.indexGroups = indexGroups; this.headers = headers; } public ReindexTaskParams(StreamInput in) throws IOException { storeResult = in.readBoolean(); - indexGroups = in.readList(StreamInput::readStringList); headers = in.readMap(StreamInput::readString, StreamInput::readString); } @@ -82,7 +74,6 @@ public Version getMinimalSupportedVersion() { @Override public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(storeResult); - out.writeCollection(indexGroups, StreamOutput::writeStringCollection); out.writeMap(headers, StreamOutput::writeString, StreamOutput::writeString); } @@ -90,7 +81,6 @@ public void writeTo(StreamOutput out) throws IOException { public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); builder.field(STORE_RESULT, storeResult); - builder.field(INDEX_GROUPS, indexGroups); builder.field(HEADERS, headers); return builder.endObject(); } @@ -99,10 +89,6 @@ public boolean shouldStoreResult() { return storeResult; } - public List> getIndexGroups() { - return indexGroups; - } - public Map getHeaders() { return headers; } diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexTaskStateDoc.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexTaskStateDoc.java index a8f1befd9b8d1..00eae5c658a33 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexTaskStateDoc.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexTaskStateDoc.java @@ -29,14 +29,20 @@ import org.elasticsearch.rest.RestStatus; import java.io.IOException; +import java.util.Collection; +import java.util.List; +import java.util.Set; public class ReindexTaskStateDoc implements ToXContentObject { + @SuppressWarnings("unchecked") public static final ConstructingObjectParser PARSER = - new ConstructingObjectParser<>("reindex/index_state", a -> new ReindexTaskStateDoc((ReindexRequest) a[0], (Long) a[1], - (BulkByScrollResponse) a[2], (ElasticsearchException) a[3], (Integer) a[4], (ScrollableHitSource.Checkpoint) a[5])); + new ConstructingObjectParser<>("reindex/index_state", a -> new ReindexTaskStateDoc((ReindexRequest) a[0], (List>) a[1], + (Long) a[2], (BulkByScrollResponse) a[3], (ElasticsearchException) a[4], (Integer) a[5], + (ScrollableHitSource.Checkpoint) a[6])); private static final String REINDEX_REQUEST = "request"; + private static final String INDEX_GROUPS = "index_groups"; private static final String ALLOCATION = "allocation"; private static final String REINDEX_RESPONSE = "response"; private static final String REINDEX_EXCEPTION = "exception"; @@ -46,6 +52,7 @@ public class ReindexTaskStateDoc implements ToXContentObject { static { PARSER.declareObject(ConstructingObjectParser.constructorArg(), (p, c) -> ReindexRequest.fromXContentWithParams(p), new ParseField(REINDEX_REQUEST)); + PARSER.declareObjectArray(ConstructingObjectParser.constructorArg(), (p, c) -> p.list(), new ParseField(INDEX_GROUPS)); PARSER.declareLong(ConstructingObjectParser.optionalConstructorArg(), new ParseField(ALLOCATION)); PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), (p, c) -> BulkByScrollResponse.fromXContent(p), new ParseField(REINDEX_RESPONSE)); @@ -57,32 +64,35 @@ public class ReindexTaskStateDoc implements ToXContentObject { } private final ReindexRequest reindexRequest; + private final List> indexGroups; private final Long allocationId; private final BulkByScrollResponse reindexResponse; private final ElasticsearchException exception; private final RestStatus failureStatusCode; private final ScrollableHitSource.Checkpoint checkpoint; - public ReindexTaskStateDoc(ReindexRequest reindexRequest) { - this(reindexRequest, null, null, null, (RestStatus) null, null); + public ReindexTaskStateDoc(ReindexRequest reindexRequest, List> indexGroups) { + this(reindexRequest, indexGroups, null, null, null, (RestStatus) null, null); } - public ReindexTaskStateDoc(ReindexRequest reindexRequest, @Nullable Long allocationId, + public ReindexTaskStateDoc(ReindexRequest reindexRequest, List> indexGroups, @Nullable Long allocationId, @Nullable BulkByScrollResponse reindexResponse, @Nullable ElasticsearchException exception, @Nullable Integer failureStatusCode, ScrollableHitSource.Checkpoint checkpoint) { - this(reindexRequest, allocationId, reindexResponse, exception, + this(reindexRequest, indexGroups, allocationId, reindexResponse, exception, failureStatusCode == null ? null : RestStatus.fromCode(failureStatusCode), checkpoint); } - public ReindexTaskStateDoc(ReindexRequest reindexRequest, @Nullable Long allocationId, + public ReindexTaskStateDoc(ReindexRequest reindexRequest, List> indexGroups, @Nullable Long allocationId, @Nullable BulkByScrollResponse reindexResponse, @Nullable ElasticsearchException exception, @Nullable ScrollableHitSource.Checkpoint checkpoint) { - this(reindexRequest, allocationId, reindexResponse, exception, exception != null ? exception.status() : null, checkpoint); + this(reindexRequest, indexGroups, allocationId, reindexResponse, + exception, exception != null ? exception.status() : null, checkpoint); } - private ReindexTaskStateDoc(ReindexRequest reindexRequest, @Nullable Long allocationId, + private ReindexTaskStateDoc(ReindexRequest reindexRequest, List> indexGroups, @Nullable Long allocationId, @Nullable BulkByScrollResponse reindexResponse, @Nullable ElasticsearchException exception, @Nullable RestStatus failureStatusCode, @Nullable ScrollableHitSource.Checkpoint checkpoint) { + this.indexGroups = indexGroups; this.allocationId = allocationId; assert (reindexResponse == null) || (exception == null) : "Either response or exception must be null"; this.reindexRequest = reindexRequest; @@ -97,6 +107,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws builder.startObject(); builder.field(REINDEX_REQUEST); reindexRequest.toXContent(builder, params, true); + builder.field(INDEX_GROUPS, indexGroups); if (allocationId != null) { builder.field(ALLOCATION, allocationId); } @@ -128,6 +139,10 @@ public ReindexRequest getReindexRequest() { return reindexRequest; } + public List> getIndexGroups() { + return indexGroups; + } + public BulkByScrollResponse getReindexResponse() { return reindexResponse; } @@ -150,15 +165,17 @@ public Long getAllocationId() { public ReindexTaskStateDoc withCheckpoint(ScrollableHitSource.Checkpoint checkpoint, BulkByScrollTask.Status status) { // todo: also store and resume from status. - return new ReindexTaskStateDoc(reindexRequest, allocationId, reindexResponse, exception, failureStatusCode, checkpoint); + return new ReindexTaskStateDoc(reindexRequest, indexGroups, allocationId, reindexResponse, + exception, failureStatusCode, checkpoint); } public ReindexTaskStateDoc withNewAllocation(long newAllocationId) { - return new ReindexTaskStateDoc(reindexRequest, newAllocationId, reindexResponse, exception, failureStatusCode, checkpoint); + return new ReindexTaskStateDoc(reindexRequest, indexGroups, newAllocationId, reindexResponse, + exception, failureStatusCode, checkpoint); } public ReindexTaskStateDoc withFinishedState(@Nullable BulkByScrollResponse reindexResponse, @Nullable ElasticsearchException exception) { - return new ReindexTaskStateDoc(reindexRequest, allocationId, reindexResponse, exception, checkpoint); + return new ReindexTaskStateDoc(reindexRequest, indexGroups, allocationId, reindexResponse, exception, checkpoint); } } diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/TransportStartReindexTaskAction.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/TransportStartReindexTaskAction.java index 39fb237e1326a..34e55f2a947b7 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/TransportStartReindexTaskAction.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/TransportStartReindexTaskAction.java @@ -103,9 +103,10 @@ protected void doExecute(Task task, StartReindexTaskAction.Request request, Acti // In the current implementation, we only need to store task results if we do not wait for completion boolean storeTaskResult = request.getWaitForCompletion() == false; - ReindexTaskParams job = new ReindexTaskParams(storeTaskResult, resolveIndexPatterns(request.getReindexRequest()), included); + ReindexTaskParams job = new ReindexTaskParams(storeTaskResult, included); - ReindexTaskStateDoc reindexState = new ReindexTaskStateDoc(request.getReindexRequest()); + ReindexTaskStateDoc reindexState = + new ReindexTaskStateDoc(request.getReindexRequest(), resolveIndexPatterns(request.getReindexRequest())); reindexIndexClient.createReindexTaskDoc(generatedId, reindexState, new ActionListener<>() { @Override public void onResponse(ReindexTaskState taskState) { diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexIndexClientTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexIndexClientTests.java index dc9da953b172b..a4c57eddb4e05 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexIndexClientTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexIndexClientTests.java @@ -24,6 +24,7 @@ import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.test.ESSingleNodeTestCase; +import java.util.Collections; import java.util.concurrent.TimeUnit; import static org.elasticsearch.index.reindex.ReindexIndexClient.REINDEX_ALIAS; @@ -36,7 +37,7 @@ public void testAliasAndIndexCreated() { ReindexIndexClient client = new ReindexIndexClient(client(), getInstanceFromNode(ClusterService.class), null); PlainActionFuture future = new PlainActionFuture<>(); - client.createReindexTaskDoc(randomAlphaOfLength(5), new ReindexTaskStateDoc(new ReindexRequest()), future); + client.createReindexTaskDoc(randomAlphaOfLength(5), new ReindexTaskStateDoc(new ReindexRequest(), Collections.emptyList()), future); future.actionGet(10, TimeUnit.SECONDS); GetAliasesResponse aliases = client().admin().indices().prepareGetAliases(REINDEX_ALIAS).get(); diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexTaskParamsTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexTaskStateDocTests.java similarity index 66% rename from modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexTaskParamsTests.java rename to modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexTaskStateDocTests.java index 4e79993011ec8..7200424cca465 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexTaskParamsTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexTaskStateDocTests.java @@ -18,15 +18,12 @@ */ package org.elasticsearch.index.reindex; -import org.elasticsearch.common.io.stream.BytesStreamOutput; -import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.test.AbstractXContentTestCase; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; -import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -35,13 +32,12 @@ // todo: test more then the index_groups field. -public class ReindexTaskParamsTests extends AbstractXContentTestCase { +public class ReindexTaskStateDocTests extends AbstractXContentTestCase { @Override - protected ReindexTaskParams createTestInstance() { - return new ReindexTaskParams(randomBoolean(), - IntStream.range(0, randomInt(20)).mapToObj(i -> setOrListOfStrings()).collect(Collectors.toList()), - new HashMap<>()); + protected ReindexTaskStateDoc createTestInstance() { + return new ReindexTaskStateDoc(new ReindexRequest().setDestIndex("test"), + IntStream.range(0, randomInt(20)).mapToObj(i -> setOrListOfStrings()).collect(Collectors.toList())); } private Collection setOrListOfStrings() { @@ -54,8 +50,8 @@ private Collection setOrListOfStrings() { } @Override - protected ReindexTaskParams doParseInstance(XContentParser parser) throws IOException { - return ReindexTaskParams.fromXContent(parser); + protected ReindexTaskStateDoc doParseInstance(XContentParser parser) throws IOException { + return ReindexTaskStateDoc.fromXContent(parser); } @Override @@ -64,7 +60,7 @@ protected boolean supportsUnknownFields() { } @Override - protected void assertEqualInstances(ReindexTaskParams expectedInstance, ReindexTaskParams newInstance) { + protected void assertEqualInstances(ReindexTaskStateDoc expectedInstance, ReindexTaskStateDoc newInstance) { assertNotSame(newInstance, expectedInstance); List> expectedGroups = expectedInstance.getIndexGroups().stream().map(HashSet::new).collect(Collectors.toList()); @@ -72,17 +68,4 @@ protected void assertEqualInstances(ReindexTaskParams expectedInstance, ReindexT assertEquals(expectedGroups, newGroups); } - - public void testSerialization() throws IOException { - ReindexTaskParams before = createTestInstance(); - - final BytesStreamOutput out = new BytesStreamOutput(); - before.writeTo(out); - - final StreamInput in = out.bytes().streamInput(); - - ReindexTaskParams after = new ReindexTaskParams(in); - - assertEqualInstances(before, after); - } } diff --git a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexTaskStateUpdaterTests.java b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexTaskStateUpdaterTests.java index b36c77dc12a92..cfcd74a061aa3 100644 --- a/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexTaskStateUpdaterTests.java +++ b/modules/reindex/src/test/java/org/elasticsearch/index/reindex/ReindexTaskStateUpdaterTests.java @@ -266,7 +266,7 @@ private void createDoc(ReindexIndexClient client, String taskId) { reindex().source("source").destination("dest").refresh(true).request().setCheckpointInterval(TimeValue.ZERO); PlainActionFuture future = PlainActionFuture.newFuture(); - client.createReindexTaskDoc(taskId, new ReindexTaskStateDoc(request), future); + client.createReindexTaskDoc(taskId, new ReindexTaskStateDoc(request, Collections.emptyList()), future); future.actionGet(); } From bef64e353ef9a79ec3e752e81e2215120814f5fa Mon Sep 17 00:00:00 2001 From: Henning Andersen Date: Tue, 10 Dec 2019 15:25:58 +0100 Subject: [PATCH 4/5] Fixed unchecked cast. --- .../org/elasticsearch/index/reindex/ReindexTaskStateDoc.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexTaskStateDoc.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexTaskStateDoc.java index 00eae5c658a33..fa48a076d3121 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexTaskStateDoc.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexTaskStateDoc.java @@ -37,7 +37,7 @@ public class ReindexTaskStateDoc implements ToXContentObject { @SuppressWarnings("unchecked") public static final ConstructingObjectParser PARSER = - new ConstructingObjectParser<>("reindex/index_state", a -> new ReindexTaskStateDoc((ReindexRequest) a[0], (List>) a[1], + new ConstructingObjectParser<>("reindex/index_state", a -> new ReindexTaskStateDoc((ReindexRequest) a[0], (List>) a[1], (Long) a[2], (BulkByScrollResponse) a[3], (ElasticsearchException) a[4], (Integer) a[5], (ScrollableHitSource.Checkpoint) a[6])); From ae2bef578fa81f4b489ce94fb97a1a6821052361 Mon Sep 17 00:00:00 2001 From: Henning Andersen Date: Tue, 10 Dec 2019 15:57:44 +0100 Subject: [PATCH 5/5] checkstyle --- .../org/elasticsearch/index/reindex/ReindexTaskStateDoc.java | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexTaskStateDoc.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexTaskStateDoc.java index fa48a076d3121..e436b67d05b96 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexTaskStateDoc.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexTaskStateDoc.java @@ -31,7 +31,6 @@ import java.io.IOException; import java.util.Collection; import java.util.List; -import java.util.Set; public class ReindexTaskStateDoc implements ToXContentObject {