-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Resolve the index in the snapshotting thread * Added test for routing table - snapshot state mismatch
- Loading branch information
1 parent
76c14db
commit 290fbe5
Showing
3 changed files
with
137 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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
89 changes: 89 additions & 0 deletions
89
...ramework/src/main/java/org/elasticsearch/test/disruption/BusyMasterServiceDisruption.java
This file contains 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,89 @@ | ||
/* | ||
* 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.test.disruption; | ||
|
||
import org.elasticsearch.cluster.ClusterState; | ||
import org.elasticsearch.cluster.ClusterStateUpdateTask; | ||
import org.elasticsearch.cluster.service.ClusterService; | ||
import org.elasticsearch.common.Priority; | ||
import org.elasticsearch.common.unit.TimeValue; | ||
import org.elasticsearch.test.InternalTestCluster; | ||
import java.util.Random; | ||
import java.util.concurrent.atomic.AtomicBoolean; | ||
|
||
public class BusyMasterServiceDisruption extends SingleNodeDisruption { | ||
private final AtomicBoolean active = new AtomicBoolean(); | ||
private final Priority priority; | ||
|
||
public BusyMasterServiceDisruption(Random random, Priority priority) { | ||
super(random); | ||
this.priority = priority; | ||
} | ||
|
||
@Override | ||
public void startDisrupting() { | ||
disruptedNode = cluster.getMasterName(); | ||
final String disruptionNodeCopy = disruptedNode; | ||
if (disruptionNodeCopy == null) { | ||
return; | ||
} | ||
ClusterService clusterService = cluster.getInstance(ClusterService.class, disruptionNodeCopy); | ||
if (clusterService == null) { | ||
return; | ||
} | ||
logger.info("making master service busy on node [{}] at priority [{}]", disruptionNodeCopy, priority); | ||
active.set(true); | ||
submitTask(clusterService); | ||
} | ||
|
||
private void submitTask(ClusterService clusterService) { | ||
clusterService.getMasterService().submitStateUpdateTask( | ||
"service_disruption_block", | ||
new ClusterStateUpdateTask(priority) { | ||
@Override | ||
public ClusterState execute(ClusterState currentState) { | ||
if (active.get()) { | ||
submitTask(clusterService); | ||
} | ||
return currentState; | ||
} | ||
|
||
@Override | ||
public void onFailure(String source, Exception e) { | ||
logger.error("unexpected error during disruption", e); | ||
} | ||
} | ||
); | ||
} | ||
|
||
@Override | ||
public void stopDisrupting() { | ||
active.set(false); | ||
} | ||
|
||
@Override | ||
public void removeAndEnsureHealthy(InternalTestCluster cluster) { | ||
removeFromCluster(cluster); | ||
} | ||
|
||
@Override | ||
public TimeValue expectedTimeToHeal() { | ||
return TimeValue.timeValueMinutes(0); | ||
} | ||
} |