-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Make reindexing managed by a persistent task #43382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Tim-Brooks
merged 66 commits into
elastic:reindex_v2
from
Tim-Brooks:persistent_reindex
Jul 18, 2019
Merged
Changes from all commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
e3191f1
WIP
Tim-Brooks c5cf831
Work on task
Tim-Brooks d3f76d9
Merge remote-tracking branch 'upstream/master' into persistent_reindex
Tim-Brooks 03c55d6
WIP
Tim-Brooks 8a29bb7
WIP
Tim-Brooks 7272fc0
WIP
Tim-Brooks 15d6a45
Changes
Tim-Brooks a8fdc23
Merge remote-tracking branch 'upstream/master' into persistent_reindex
Tim-Brooks 7dc09e3
Changes
Tim-Brooks addb374
Changes
Tim-Brooks 6e856c4
Merge remote-tracking branch 'upstream/master' into persistent_reindex
Tim-Brooks 7265547
WIP
Tim-Brooks e354574
Merge remote-tracking branch 'upstream/master' into persistent_reindex
Tim-Brooks 2037fdc
Merge remote-tracking branch 'upstream/master' into persistent_reindex
Tim-Brooks a8ffa25
Work on test
Tim-Brooks 4023500
REmove
Tim-Brooks 22ba62b
Changes
Tim-Brooks 1fb3f57
Change
Tim-Brooks ccb1a00
Merge remote-tracking branch 'upstream/master' into persistent_reindex
Tim-Brooks 02c3e59
License
Tim-Brooks 9ee47c9
Security changes
Tim-Brooks 0db2bae
Security fixes
Tim-Brooks b394a10
Small cleanup
Tim-Brooks 544365a
Change
Tim-Brooks b578938
Changes
Tim-Brooks 03e38d9
Merge remote-tracking branch 'upstream/reindex_v2' into persistent_re…
Tim-Brooks 4941da5
Changes
Tim-Brooks e852a72
Changes
Tim-Brooks 0065306
WIP
Tim-Brooks 852a6b0
Merge branch 'reindex_v2' into persistent_reindex
Tim-Brooks 5274f9a
Changes
Tim-Brooks 19a4636
Merge remote-tracking branch 'upstream/master' into persistent_reindex
Tim-Brooks 1bdf6e2
Changes
Tim-Brooks c8cf5e2
Merge branch 'reindex_v2' into persistent_reindex
Tim-Brooks d691b83
Change
Tim-Brooks 599a3b0
Merge remote-tracking branch 'upstream/master' into persistent_reindex
Tim-Brooks 67a82cf
Fixes
Tim-Brooks 65ed892
Changes
Tim-Brooks 6f9d1bb
Work on serialization
Tim-Brooks b9cca0b
Change
Tim-Brooks 0db4a2b
Merge remote-tracking branch 'upstream/reindex_v2' into persistent_re…
Tim-Brooks fd55935
Changes
Tim-Brooks 6b9a1f8
Change assertion
Tim-Brooks 321a790
Store task
Tim-Brooks 15fe610
Changes
Tim-Brooks ab39730
WIP
Tim-Brooks 82f338a
Changes
Tim-Brooks 8b9c7b6
Change
Tim-Brooks 5995437
Propogate headers
Tim-Brooks 99b906a
Changes
Tim-Brooks a3e7f1f
Fix
Tim-Brooks 1c26b82
Rethrottle
Tim-Brooks 59c671f
Add validation
Tim-Brooks ff67a35
Changes
Tim-Brooks 1e3de1a
Tests
Tim-Brooks 9dc3c1a
Fix test
Tim-Brooks d42bd72
Merge branch 'reindex_v2' into persistent_reindex
Tim-Brooks 41837ff
Change
Tim-Brooks a847c4e
Dispatch
Tim-Brooks ce5ec9b
Wait
Tim-Brooks 6b59df0
Merge branch 'reindex_v2' into persistent_reindex
Tim-Brooks 68586d9
Changes
Tim-Brooks f347160
Review changes
Tim-Brooks 9fd28bf
Changes
Tim-Brooks 555c8a0
Merge branch 'reindex_v2' into persistent_reindex
Tim-Brooks b1beb76
Fix
Tim-Brooks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
150 changes: 150 additions & 0 deletions
150
modules/reindex/src/main/java/org/elasticsearch/index/reindex/StartReindexJobAction.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| /* | ||
| * 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.action.ActionRequestValidationException; | ||
| import org.elasticsearch.action.ActionResponse; | ||
| import org.elasticsearch.action.ActionType; | ||
| import org.elasticsearch.action.CompositeIndicesRequest; | ||
| import org.elasticsearch.action.support.master.AcknowledgedRequest; | ||
| import org.elasticsearch.common.Nullable; | ||
| import org.elasticsearch.common.ParseField; | ||
| import org.elasticsearch.common.io.stream.StreamInput; | ||
| import org.elasticsearch.common.io.stream.StreamOutput; | ||
| import org.elasticsearch.common.xcontent.ConstructingObjectParser; | ||
| import org.elasticsearch.common.xcontent.ToXContentObject; | ||
| import org.elasticsearch.common.xcontent.XContentBuilder; | ||
| import org.elasticsearch.common.xcontent.XContentParser; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| public class StartReindexJobAction extends ActionType<StartReindexJobAction.Response> { | ||
|
|
||
| public static final StartReindexJobAction INSTANCE = new StartReindexJobAction(); | ||
| // TODO: Name | ||
| public static final String NAME = "indices:data/write/start_reindex"; | ||
Tim-Brooks marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| private StartReindexJobAction() { | ||
| super(NAME, Response::new); | ||
| } | ||
|
|
||
| public static class Request extends AcknowledgedRequest<Request> implements ToXContentObject, CompositeIndicesRequest { | ||
|
|
||
| private final ReindexRequest reindexRequest; | ||
| private final boolean waitForCompletion; | ||
|
|
||
|
|
||
| public Request(ReindexRequest reindexRequest) { | ||
| this(reindexRequest, false); | ||
| } | ||
|
|
||
| public Request(ReindexRequest reindexRequest, boolean waitForCompletion) { | ||
| this.reindexRequest = reindexRequest; | ||
| this.waitForCompletion = waitForCompletion; | ||
| } | ||
|
|
||
| public Request(StreamInput in) throws IOException { | ||
| super(in); | ||
| reindexRequest = new ReindexRequest(in); | ||
| waitForCompletion = in.readBoolean(); | ||
| } | ||
|
|
||
| @Override | ||
| public void writeTo(StreamOutput out) throws IOException { | ||
| super.writeTo(out); | ||
| reindexRequest.writeTo(out); | ||
| out.writeBoolean(waitForCompletion); | ||
| } | ||
|
|
||
| @Override | ||
| public ActionRequestValidationException validate() { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public XContentBuilder toXContent(XContentBuilder builder, Params params) { | ||
| return builder; | ||
| } | ||
|
|
||
| public ReindexRequest getReindexRequest() { | ||
| return reindexRequest; | ||
| } | ||
|
|
||
| public boolean getWaitForCompletion() { | ||
| return waitForCompletion; | ||
| } | ||
| } | ||
|
|
||
| public static class Response extends ActionResponse { | ||
|
|
||
| static final ParseField TASK_ID = new ParseField("task_id"); | ||
| static final ParseField REINDEX_RESPONSE = new ParseField("reindex_response"); | ||
|
|
||
| private static final ConstructingObjectParser<Response, Void> PARSER = new ConstructingObjectParser<>( | ||
| "start_reindex_response", true, args -> new Response((String) args[0], (BulkByScrollResponse) args[1])); | ||
|
|
||
| static { | ||
| PARSER.declareString(ConstructingObjectParser.constructorArg(), TASK_ID); | ||
| PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), | ||
| (parser, context) -> BulkByScrollResponse.fromXContent(parser), REINDEX_RESPONSE); | ||
| } | ||
|
|
||
| private final String taskId; | ||
| @Nullable private final BulkByScrollResponse reindexResponse; | ||
|
|
||
| public Response(String taskId) { | ||
| this(taskId, null); | ||
| } | ||
|
|
||
| public Response(String taskId, BulkByScrollResponse reindexResponse) { | ||
| this.taskId = taskId; | ||
| this.reindexResponse = reindexResponse; | ||
| } | ||
|
|
||
| public Response(StreamInput in) throws IOException { | ||
| super(in); | ||
| taskId = in.readString(); | ||
| reindexResponse = in.readOptionalWriteable(BulkByScrollResponse::new); | ||
| } | ||
|
|
||
| @Override | ||
| public void readFrom(StreamInput in) { | ||
| throw new UnsupportedOperationException(); | ||
| } | ||
|
|
||
| @Override | ||
| public void writeTo(StreamOutput out) throws IOException { | ||
| out.writeString(taskId); | ||
| out.writeOptionalWriteable(reindexResponse); | ||
| } | ||
|
|
||
| public String getTaskId() { | ||
| return taskId; | ||
| } | ||
|
|
||
| public BulkByScrollResponse getReindexResponse() { | ||
| return reindexResponse; | ||
| } | ||
|
|
||
| public static Response fromXContent(final XContentParser parser) throws IOException { | ||
| return PARSER.parse(parser, null); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.