19
19
20
20
package org .elasticsearch .discovery ;
21
21
22
+ import java .nio .file .Path ;
22
23
import org .elasticsearch .cluster .ClusterState ;
23
24
import org .elasticsearch .cluster .block .ClusterBlock ;
24
25
import org .elasticsearch .cluster .block .ClusterBlockLevel ;
33
34
import org .elasticsearch .env .NodeEnvironment ;
34
35
import org .elasticsearch .plugins .Plugin ;
35
36
import org .elasticsearch .test .ESIntegTestCase ;
36
- import org .elasticsearch .test .discovery .ClusterDiscoveryConfiguration ;
37
+ import org .elasticsearch .test .InternalTestCluster ;
38
+ import org .elasticsearch .test .NodeConfigurationSource ;
37
39
import org .elasticsearch .test .discovery .TestZenDiscovery ;
38
40
import org .elasticsearch .test .disruption .NetworkDisruption ;
39
41
import org .elasticsearch .test .disruption .NetworkDisruption .Bridge ;
52
54
import java .util .HashSet ;
53
55
import java .util .List ;
54
56
import java .util .Set ;
55
- import java .util .concurrent .ExecutionException ;
56
57
import java .util .concurrent .TimeUnit ;
57
58
59
+ import static org .elasticsearch .discovery .DiscoveryModule .DISCOVERY_HOSTS_PROVIDER_SETTING ;
58
60
import static org .hamcrest .Matchers .equalTo ;
59
61
import static org .hamcrest .Matchers .not ;
60
62
61
63
public abstract class AbstractDisruptionTestCase extends ESIntegTestCase {
62
64
63
65
static final TimeValue DISRUPTION_HEALING_OVERHEAD = TimeValue .timeValueSeconds (40 ); // we use 30s as timeout in many places.
64
66
65
- private ClusterDiscoveryConfiguration discoveryConfig ;
67
+ private NodeConfigurationSource discoveryConfig ;
66
68
67
69
@ Override
68
70
protected Settings nodeSettings (int nodeOrdinal ) {
@@ -116,18 +118,14 @@ protected void beforeIndexDeletion() throws Exception {
116
118
}
117
119
}
118
120
119
- List <String > startCluster (int numberOfNodes ) throws ExecutionException , InterruptedException {
121
+ List <String > startCluster (int numberOfNodes ) {
120
122
return startCluster (numberOfNodes , -1 );
121
123
}
122
124
123
- List <String > startCluster (int numberOfNodes , int minimumMasterNode ) throws ExecutionException , InterruptedException {
124
- return startCluster (numberOfNodes , minimumMasterNode , null );
125
- }
126
-
127
- List <String > startCluster (int numberOfNodes , int minimumMasterNode , @ Nullable int [] unicastHostsOrdinals ) throws
128
- ExecutionException , InterruptedException {
129
- configureCluster (numberOfNodes , unicastHostsOrdinals , minimumMasterNode );
130
- List <String > nodes = internalCluster ().startNodes (numberOfNodes );
125
+ List <String > startCluster (int numberOfNodes , int minimumMasterNode ) {
126
+ configureCluster (numberOfNodes , minimumMasterNode );
127
+ InternalTestCluster internalCluster = internalCluster ();
128
+ List <String > nodes = internalCluster .startNodes (numberOfNodes );
131
129
ensureStableCluster (numberOfNodes );
132
130
133
131
// TODO: this is a temporary solution so that nodes will not base their reaction to a partition based on previous successful results
@@ -154,20 +152,11 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
154
152
return Arrays .asList (MockTransportService .TestPlugin .class );
155
153
}
156
154
157
- void configureCluster (
158
- int numberOfNodes ,
159
- @ Nullable int [] unicastHostsOrdinals ,
160
- int minimumMasterNode
161
- ) throws ExecutionException , InterruptedException {
162
- configureCluster (DEFAULT_SETTINGS , numberOfNodes , unicastHostsOrdinals , minimumMasterNode );
155
+ void configureCluster (int numberOfNodes , int minimumMasterNode ) {
156
+ configureCluster (DEFAULT_SETTINGS , numberOfNodes , minimumMasterNode );
163
157
}
164
158
165
- void configureCluster (
166
- Settings settings ,
167
- int numberOfNodes ,
168
- @ Nullable int [] unicastHostsOrdinals ,
169
- int minimumMasterNode
170
- ) throws ExecutionException , InterruptedException {
159
+ void configureCluster (Settings settings , int numberOfNodes , int minimumMasterNode ) {
171
160
if (minimumMasterNode < 0 ) {
172
161
minimumMasterNode = numberOfNodes / 2 + 1 ;
173
162
}
@@ -177,14 +166,21 @@ void configureCluster(
177
166
.put (settings )
178
167
.put (NodeEnvironment .MAX_LOCAL_STORAGE_NODES_SETTING .getKey (), numberOfNodes )
179
168
.put (ElectMasterService .DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING .getKey (), minimumMasterNode )
169
+ .putList (DISCOVERY_HOSTS_PROVIDER_SETTING .getKey (), "file" )
180
170
.build ();
181
171
182
172
if (discoveryConfig == null ) {
183
- if (unicastHostsOrdinals == null ) {
184
- discoveryConfig = new ClusterDiscoveryConfiguration .UnicastZen (numberOfNodes , nodeSettings );
185
- } else {
186
- discoveryConfig = new ClusterDiscoveryConfiguration .UnicastZen (numberOfNodes , nodeSettings , unicastHostsOrdinals );
187
- }
173
+ discoveryConfig = new NodeConfigurationSource () {
174
+ @ Override
175
+ public Settings nodeSettings (final int nodeOrdinal ) {
176
+ return nodeSettings ;
177
+ }
178
+
179
+ @ Override
180
+ public Path nodeConfigPath (final int nodeOrdinal ) {
181
+ return null ;
182
+ }
183
+ };
188
184
}
189
185
}
190
186
0 commit comments