-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Use CcrRepository to init follower index
#35719
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 108 commits into
elastic:master
from
Tim-Brooks:ccr_recover_from_repository
Jan 29, 2019
Merged
Changes from all commits
Commits
Show all changes
108 commits
Select commit
Hold shift + click to select a range
22589ef
WIP
Tim-Brooks 37aa475
WIP
Tim-Brooks 4da9aa8
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks ad65ffa
WIP
Tim-Brooks af6fbd2
Fix indention
Tim-Brooks 63cc5cf
WIP
Tim-Brooks ddbe0ce
WIP
Tim-Brooks dfe7561
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks c235a02
WIP
Tim-Brooks bdb0a57
Work on implementing private restore API
Tim-Brooks d6c0c39
WIP
Tim-Brooks 9b09b56
WIP
Tim-Brooks 45d0658
WIP
Tim-Brooks 465a0d6
WIP
Tim-Brooks 105fb0f
WIP
Tim-Brooks 01909a5
Get basic tests
Tim-Brooks 5f3ea03
Automatically creat repo
Tim-Brooks 7096eb1
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks d93c3d7
WIP
Tim-Brooks c6cd205
Cleanups
Tim-Brooks bb548f2
checkstyle
Tim-Brooks 1f9dcc8
Teardown repo
Tim-Brooks 99cf6dc
Add comment
Tim-Brooks 4c9162c
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks 025edf1
Fix license
Tim-Brooks a3b2fe4
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks 5b52303
Fix test
Tim-Brooks f690c9b
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks b075faa
Cleanups
Tim-Brooks 12b6ed5
Cleanups
Tim-Brooks fa7016d
Fix
Tim-Brooks 74ea309
Remove extra setting
Tim-Brooks 66a749e
WIP
Tim-Brooks dd99b08
WIP
Tim-Brooks 4c1928a
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks 1734ad8
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks ebf8609
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks 9073151
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks d43dc41
Update work
Tim-Brooks d34efc3
Fix some tests
Tim-Brooks 4bf5909
Fix checkstyle
Tim-Brooks 2b4ab70
Mute test
Tim-Brooks f52defd
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks 40bd59f
Catch
Tim-Brooks 8508beb
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks 6e3ff69
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks 53a2305
Cleanup unused
Tim-Brooks a89902a
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks f99d64a
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks d56a382
WIP
Tim-Brooks 3f3afcb
WIP
Tim-Brooks aee4c42
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks 1970f27
Fix tests
Tim-Brooks 2ff72b8
Revert
Tim-Brooks 3b5893b
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks 93a0f6a
Fix
Tim-Brooks 221fd22
Wait on active shards
Tim-Brooks 3725471
Changes
Tim-Brooks bdf7533
WIP
Tim-Brooks c25daf5
Fix checkstyle
Tim-Brooks db2218f
Fix test
Tim-Brooks 413ccc7
Fix tests
Tim-Brooks f3e9792
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks 267088b
Changes
Tim-Brooks 68d7401
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks a98ab13
Changes
Tim-Brooks 2032be5
Changes
Tim-Brooks f10b43b
Changes
Tim-Brooks 9c37120
Fix whitespace
Tim-Brooks d128082
Changes
Tim-Brooks 97337f8
Changes
Tim-Brooks e1a58eb
Fix
Tim-Brooks e157f52
Fix tests
Tim-Brooks c9ee981
Fix
Tim-Brooks 107ddfd
Change rest api
Tim-Brooks 95bbc84
Fix
Tim-Brooks d8439ff
Improve test
Tim-Brooks a568d3d
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks 80e0548
Changes
Tim-Brooks d5ec701
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks cc14be5
Change
Tim-Brooks aab2aa1
Fix test
Tim-Brooks a291142
Fix test
Tim-Brooks d670028
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks d25401e
Fix test
Tim-Brooks ebf812d
Changes
Tim-Brooks f4e0ca8
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks cc64413
Changes
Tim-Brooks acf3ebe
Changes
Tim-Brooks bb6402a
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks c5c2d40
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks 065ab72
Do not pull all metadata
Tim-Brooks d91cf24
Listener changes
Tim-Brooks 6232914
WIP
Tim-Brooks 9da1fb4
Changes
Tim-Brooks eb819d2
Changes
Tim-Brooks b8d9215
Changes
Tim-Brooks a0b89e0
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks 5fdcd6a
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks 297280e
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks 59f3d98
Change
Tim-Brooks e4e87f2
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks 1a2177f
Changes
Tim-Brooks 0b526e4
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks a630a4d
Fix test
Tim-Brooks 5385fb2
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks fceaf22
Merge remote-tracking branch 'upstream/master' into ccr_recover_from_…
Tim-Brooks 9519a2e
Changes
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
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
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
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
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
87 changes: 87 additions & 0 deletions
87
...org/elasticsearch/action/admin/cluster/snapshots/restore/RestoreClusterStateListener.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,87 @@ | ||
| /* | ||
| * 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.action.admin.cluster.snapshots.restore; | ||
|
|
||
| import org.apache.logging.log4j.LogManager; | ||
| import org.apache.logging.log4j.Logger; | ||
| import org.elasticsearch.action.ActionListener; | ||
| import org.elasticsearch.cluster.ClusterChangedEvent; | ||
| import org.elasticsearch.cluster.ClusterStateListener; | ||
| import org.elasticsearch.cluster.RestoreInProgress; | ||
| import org.elasticsearch.cluster.service.ClusterService; | ||
| import org.elasticsearch.common.collect.ImmutableOpenMap; | ||
| import org.elasticsearch.index.shard.ShardId; | ||
| import org.elasticsearch.snapshots.RestoreInfo; | ||
| import org.elasticsearch.snapshots.RestoreService; | ||
|
|
||
| import static org.elasticsearch.snapshots.RestoreService.restoreInProgress; | ||
|
|
||
| public class RestoreClusterStateListener implements ClusterStateListener { | ||
|
|
||
| private static final Logger logger = LogManager.getLogger(RestoreClusterStateListener.class); | ||
|
|
||
| private final ClusterService clusterService; | ||
| private final String uuid; | ||
| private final ActionListener<RestoreSnapshotResponse> listener; | ||
|
|
||
|
|
||
| private RestoreClusterStateListener(ClusterService clusterService, RestoreService.RestoreCompletionResponse response, | ||
| ActionListener<RestoreSnapshotResponse> listener) { | ||
| this.clusterService = clusterService; | ||
| this.uuid = response.getUuid(); | ||
| this.listener = listener; | ||
| } | ||
|
|
||
| @Override | ||
| public void clusterChanged(ClusterChangedEvent changedEvent) { | ||
| final RestoreInProgress.Entry prevEntry = restoreInProgress(changedEvent.previousState(), uuid); | ||
| final RestoreInProgress.Entry newEntry = restoreInProgress(changedEvent.state(), uuid); | ||
| if (prevEntry == null) { | ||
| // When there is a master failure after a restore has been started, this listener might not be registered | ||
| // on the current master and as such it might miss some intermediary cluster states due to batching. | ||
| // Clean up listener in that case and acknowledge completion of restore operation to client. | ||
| clusterService.removeListener(this); | ||
| listener.onResponse(new RestoreSnapshotResponse(null)); | ||
| } else if (newEntry == null) { | ||
| clusterService.removeListener(this); | ||
| ImmutableOpenMap<ShardId, RestoreInProgress.ShardRestoreStatus> shards = prevEntry.shards(); | ||
| assert prevEntry.state().completed() : "expected completed snapshot state but was " + prevEntry.state(); | ||
| assert RestoreService.completed(shards) : "expected all restore entries to be completed"; | ||
| RestoreInfo ri = new RestoreInfo(prevEntry.snapshot().getSnapshotId().getName(), | ||
| prevEntry.indices(), | ||
| shards.size(), | ||
| shards.size() - RestoreService.failedShards(shards)); | ||
| RestoreSnapshotResponse response = new RestoreSnapshotResponse(ri); | ||
| logger.debug("restore of [{}] completed", prevEntry.snapshot().getSnapshotId()); | ||
| listener.onResponse(response); | ||
| } else { | ||
| // restore not completed yet, wait for next cluster state update | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Creates a cluster state listener and registers it with the cluster service. The listener passed as a | ||
| * parameter will be called when the restore is complete. | ||
| */ | ||
| public static void createAndRegisterListener(ClusterService clusterService, RestoreService.RestoreCompletionResponse response, | ||
| ActionListener<RestoreSnapshotResponse> listener) { | ||
| clusterService.addListener(new RestoreClusterStateListener(clusterService, response, listener)); | ||
| } | ||
| } | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps do the the addListener call as well here so that it's more standalone?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I aded a static method that creates the class and registers it. I'm not wild about creating classes just for the side-effects in the ctor.