-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Snapshot: Migrate TransportRequestHandler to TransportMasterNodeAction #27165
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
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1f6bf50
Snapshot: Use TransportMasterNodeAction to update
dnhatn 37b8050
Revert "Snapshot: Use TransportMasterNodeAction to update"
dnhatn 82a98ef
Merge branch 'master' into snapshot-migrate-transport
dnhatn 97c4724
Uses two handlers
dnhatn 82aedcc
Merge branch 'master' into snapshot-migrate-transport
dnhatn 06292d1
add a disruption test
dnhatn ea7ec38
post update messages to the local node
dnhatn cb73eea
try posting status forever
dnhatn 85da45d
do not use sleep
dnhatn 57daa0d
Merge branch 'master' into snapshot-migrate-transport
dnhatn 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
115 changes: 115 additions & 0 deletions
115
core/src/test/java/org/elasticsearch/snapshots/SnapshotShardsServiceIT.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,115 @@ | ||
| /* | ||
| * 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.snapshots; | ||
|
|
||
| import org.elasticsearch.action.admin.cluster.snapshots.get.GetSnapshotsResponse; | ||
| import org.elasticsearch.common.settings.Settings; | ||
| import org.elasticsearch.common.unit.ByteSizeUnit; | ||
| import org.elasticsearch.common.unit.TimeValue; | ||
| import org.elasticsearch.index.snapshots.IndexShardSnapshotStatus; | ||
| import org.elasticsearch.plugins.Plugin; | ||
| import org.elasticsearch.snapshots.mockstore.MockRepository; | ||
| import org.elasticsearch.test.ESIntegTestCase; | ||
| import org.elasticsearch.test.disruption.NetworkDisruption; | ||
| import org.elasticsearch.test.transport.MockTransportService; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.Collection; | ||
| import java.util.List; | ||
| import java.util.concurrent.TimeUnit; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; | ||
| import static org.hamcrest.Matchers.equalTo; | ||
| import static org.hamcrest.Matchers.everyItem; | ||
| import static org.hamcrest.Matchers.hasSize; | ||
|
|
||
| @ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST, numDataNodes = 0, transportClientRatio = 0) | ||
| public class SnapshotShardsServiceIT extends AbstractSnapshotIntegTestCase { | ||
|
|
||
| @Override | ||
| protected Collection<Class<? extends Plugin>> nodePlugins() { | ||
| return Arrays.asList(MockRepository.Plugin.class, MockTransportService.TestPlugin.class); | ||
| } | ||
|
|
||
| public void testRetryPostingSnapshotStatusMessages() throws Exception { | ||
| String masterNode = internalCluster().startMasterOnlyNode(); | ||
| String dataNode = internalCluster().startDataOnlyNode(); | ||
|
|
||
| logger.info("--> creating repository"); | ||
| assertAcked(client().admin().cluster().preparePutRepository("test-repo") | ||
| .setType("mock").setSettings(Settings.builder() | ||
| .put("location", randomRepoPath()) | ||
| .put("compress", randomBoolean()) | ||
| .put("chunk_size", randomIntBetween(100, 1000), ByteSizeUnit.BYTES))); | ||
|
|
||
| final int shards = between(1, 10); | ||
| assertAcked(prepareCreate("test-index", 0, Settings.builder().put("number_of_shards", shards).put("number_of_replicas", 0))); | ||
| ensureGreen(); | ||
| final int numDocs = scaledRandomIntBetween(50, 100); | ||
| for (int i = 0; i < numDocs; i++) { | ||
| index("test-index", "doc", Integer.toString(i)); | ||
| } | ||
|
|
||
| logger.info("--> blocking repository"); | ||
| String blockedNode = blockNodeWithIndex("test-repo", "test-index"); | ||
| dataNodeClient().admin().cluster().prepareCreateSnapshot("test-repo", "test-snap") | ||
| .setWaitForCompletion(false) | ||
| .setIndices("test-index") | ||
| .get(); | ||
| waitForBlock(blockedNode, "test-repo", TimeValue.timeValueSeconds(60)); | ||
|
|
||
| final SnapshotId snapshotId = client().admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-snap") | ||
| .get().getSnapshots().get(0).snapshotId(); | ||
|
|
||
| logger.info("--> start disrupting cluster"); | ||
| final NetworkDisruption networkDisruption = new NetworkDisruption(new NetworkDisruption.TwoPartitions(masterNode, dataNode), | ||
| NetworkDisruption.NetworkDelay.random(random())); | ||
| internalCluster().setDisruptionScheme(networkDisruption); | ||
| networkDisruption.startDisrupting(); | ||
|
|
||
| logger.info("--> unblocking repository"); | ||
| unblockNode("test-repo", blockedNode); | ||
|
|
||
| // Retrieve snapshot status from the data node. | ||
| SnapshotShardsService snapshotShardsService = internalCluster().getInstance(SnapshotShardsService.class, blockedNode); | ||
| assertBusy(() -> { | ||
| final Snapshot snapshot = new Snapshot("test-repo", snapshotId); | ||
| List<IndexShardSnapshotStatus.Stage> stages = snapshotShardsService.currentSnapshotShards(snapshot) | ||
| .values().stream().map(IndexShardSnapshotStatus::stage).collect(Collectors.toList()); | ||
| assertThat(stages, hasSize(shards)); | ||
| assertThat(stages, everyItem(equalTo(IndexShardSnapshotStatus.Stage.DONE))); | ||
| }); | ||
|
|
||
| logger.info("--> stop disrupting cluster"); | ||
| networkDisruption.stopDisrupting(); | ||
| internalCluster().clearDisruptionScheme(true); | ||
|
|
||
| assertBusy(() -> { | ||
| GetSnapshotsResponse snapshotsStatusResponse = client().admin().cluster() | ||
| .prepareGetSnapshots("test-repo") | ||
| .setSnapshots("test-snap").get(); | ||
| SnapshotInfo snapshotInfo = snapshotsStatusResponse.getSnapshots().get(0); | ||
| logger.info("Snapshot status [{}], successfulShards [{}]", snapshotInfo.state(), snapshotInfo.successfulShards()); | ||
| assertThat(snapshotInfo.state(), equalTo(SnapshotState.SUCCESS)); | ||
| assertThat(snapshotInfo.successfulShards(), equalTo(shards)); | ||
| }, 10, TimeUnit.SECONDS); | ||
| } | ||
| } |
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.
again, masterNodeTimeout?
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.
Done