Remove Settings.settingsBuilder.

We have both `Settings.settingsBuilder` and `Settings.builder` that do exactly
the same thing, so we should keep only one. I kept `Settings.builder` since it
has my preference but also it is the one that we use in examples of the Java API.
This commit is contained in:
Adrien Grand 2016-04-08 14:59:56 +02:00
parent df8a971966
commit 42526ac28e
295 changed files with 1056 additions and 1212 deletions

View File

@ -148,7 +148,7 @@ public class PutRepositoryRequest extends AcknowledgedRequest<PutRepositoryReque
* @return this request * @return this request
*/ */
public PutRepositoryRequest settings(String source) { public PutRepositoryRequest settings(String source) {
this.settings = Settings.settingsBuilder().loadFromSource(source).build(); this.settings = Settings.builder().loadFromSource(source).build();
return this; return this;
} }

View File

@ -85,7 +85,7 @@ public class ClusterUpdateSettingsRequest extends AcknowledgedRequest<ClusterUpd
* Sets the source containing the transient settings to be updated. They will not survive a full cluster restart * Sets the source containing the transient settings to be updated. They will not survive a full cluster restart
*/ */
public ClusterUpdateSettingsRequest transientSettings(String source) { public ClusterUpdateSettingsRequest transientSettings(String source) {
this.transientSettings = Settings.settingsBuilder().loadFromSource(source).build(); this.transientSettings = Settings.builder().loadFromSource(source).build();
return this; return this;
} }
@ -124,7 +124,7 @@ public class ClusterUpdateSettingsRequest extends AcknowledgedRequest<ClusterUpd
* Sets the source containing the persistent settings to be updated. They will get applied cross restarts * Sets the source containing the persistent settings to be updated. They will get applied cross restarts
*/ */
public ClusterUpdateSettingsRequest persistentSettings(String source) { public ClusterUpdateSettingsRequest persistentSettings(String source) {
this.persistentSettings = Settings.settingsBuilder().loadFromSource(source).build(); this.persistentSettings = Settings.builder().loadFromSource(source).build();
return this; return this;
} }

View File

@ -32,8 +32,8 @@ import static org.elasticsearch.cluster.ClusterState.builder;
* due to the update. * due to the update.
*/ */
final class SettingsUpdater { final class SettingsUpdater {
final Settings.Builder transientUpdates = Settings.settingsBuilder(); final Settings.Builder transientUpdates = Settings.builder();
final Settings.Builder persistentUpdates = Settings.settingsBuilder(); final Settings.Builder persistentUpdates = Settings.builder();
private final ClusterSettings clusterSettings; private final ClusterSettings clusterSettings;
SettingsUpdater(ClusterSettings clusterSettings) { SettingsUpdater(ClusterSettings clusterSettings) {
@ -50,11 +50,11 @@ final class SettingsUpdater {
synchronized ClusterState updateSettings(final ClusterState currentState, Settings transientToApply, Settings persistentToApply) { synchronized ClusterState updateSettings(final ClusterState currentState, Settings transientToApply, Settings persistentToApply) {
boolean changed = false; boolean changed = false;
Settings.Builder transientSettings = Settings.settingsBuilder(); Settings.Builder transientSettings = Settings.builder();
transientSettings.put(currentState.metaData().transientSettings()); transientSettings.put(currentState.metaData().transientSettings());
changed |= clusterSettings.updateDynamicSettings(transientToApply, transientSettings, transientUpdates, "transient"); changed |= clusterSettings.updateDynamicSettings(transientToApply, transientSettings, transientUpdates, "transient");
Settings.Builder persistentSettings = Settings.settingsBuilder(); Settings.Builder persistentSettings = Settings.builder();
persistentSettings.put(currentState.metaData().persistentSettings()); persistentSettings.put(currentState.metaData().persistentSettings());
changed |= clusterSettings.updateDynamicSettings(persistentToApply, persistentSettings, persistentUpdates, "persistent"); changed |= clusterSettings.updateDynamicSettings(persistentToApply, persistentSettings, persistentUpdates, "persistent");

View File

@ -299,7 +299,7 @@ public class CreateSnapshotRequest extends MasterNodeRequest<CreateSnapshotReque
* @return this request * @return this request
*/ */
public CreateSnapshotRequest settings(String source) { public CreateSnapshotRequest settings(String source) {
this.settings = Settings.settingsBuilder().loadFromSource(source).build(); this.settings = Settings.builder().loadFromSource(source).build();
return this; return this;
} }

View File

@ -324,7 +324,7 @@ public class RestoreSnapshotRequest extends MasterNodeRequest<RestoreSnapshotReq
* @return this request * @return this request
*/ */
public RestoreSnapshotRequest settings(String source) { public RestoreSnapshotRequest settings(String source) {
this.settings = Settings.settingsBuilder().loadFromSource(source).build(); this.settings = Settings.builder().loadFromSource(source).build();
return this; return this;
} }
@ -441,7 +441,7 @@ public class RestoreSnapshotRequest extends MasterNodeRequest<RestoreSnapshotReq
* Sets settings that should be added/changed in all restored indices * Sets settings that should be added/changed in all restored indices
*/ */
public RestoreSnapshotRequest indexSettings(String source) { public RestoreSnapshotRequest indexSettings(String source) {
this.indexSettings = Settings.settingsBuilder().loadFromSource(source).build(); this.indexSettings = Settings.builder().loadFromSource(source).build();
return this; return this;
} }

View File

@ -169,7 +169,7 @@ public class CreateIndexRequest extends AcknowledgedRequest<CreateIndexRequest>
* The settings to create the index with (either json/yaml/properties format) * The settings to create the index with (either json/yaml/properties format)
*/ */
public CreateIndexRequest settings(String source) { public CreateIndexRequest settings(String source) {
this.settings = Settings.settingsBuilder().loadFromSource(source).build(); this.settings = Settings.builder().loadFromSource(source).build();
return this; return this;
} }

View File

@ -124,7 +124,7 @@ public class UpdateSettingsRequest extends AcknowledgedRequest<UpdateSettingsReq
* Sets the settings to be updated (either json/yaml/properties format) * Sets the settings to be updated (either json/yaml/properties format)
*/ */
public UpdateSettingsRequest settings(String source) { public UpdateSettingsRequest settings(String source) {
this.settings = Settings.settingsBuilder().loadFromSource(source).build(); this.settings = Settings.builder().loadFromSource(source).build();
return this; return this;
} }

View File

@ -162,7 +162,7 @@ public class PutIndexTemplateRequest extends MasterNodeRequest<PutIndexTemplateR
* The settings to create the index template with (either json/yaml/properties format). * The settings to create the index template with (either json/yaml/properties format).
*/ */
public PutIndexTemplateRequest settings(String source) { public PutIndexTemplateRequest settings(String source) {
this.settings = Settings.settingsBuilder().loadFromSource(source).build(); this.settings = Settings.builder().loadFromSource(source).build();
return this; return this;
} }

View File

@ -73,7 +73,7 @@ public class TransportPutIndexTemplateAction extends TransportMasterNodeAction<P
if (cause.length() == 0) { if (cause.length() == 0) {
cause = "api"; cause = "api";
} }
final Settings.Builder templateSettingsBuilder = Settings.settingsBuilder(); final Settings.Builder templateSettingsBuilder = Settings.builder();
templateSettingsBuilder.put(request.settings()).normalizePrefix(IndexMetaData.INDEX_SETTING_PREFIX); templateSettingsBuilder.put(request.settings()).normalizePrefix(IndexMetaData.INDEX_SETTING_PREFIX);
indexScopedSettings.validate(templateSettingsBuilder); indexScopedSettings.validate(templateSettingsBuilder);
indexTemplateService.putTemplate(new MetaDataIndexTemplateService.PutRequest(cause, request.name()) indexTemplateService.putTemplate(new MetaDataIndexTemplateService.PutRequest(cause, request.name())

View File

@ -179,7 +179,7 @@ final class Bootstrap {
// We do not need to reload system properties here as we have already applied them in building the settings and // We do not need to reload system properties here as we have already applied them in building the settings and
// reloading could cause multiple prompts to the user for values if a system property was specified with a prompt // reloading could cause multiple prompts to the user for values if a system property was specified with a prompt
// placeholder // placeholder
Settings nodeSettings = Settings.settingsBuilder() Settings nodeSettings = Settings.builder()
.put(settings) .put(settings)
.put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING.getKey(), true) .put(InternalSettingsPreparer.IGNORE_SYSTEM_PROPERTIES_SETTING.getKey(), true)
.build(); .build();

View File

@ -57,8 +57,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
/** /**
* The transport client allows to create a client that is not part of the cluster, but simply connects to one * The transport client allows to create a client that is not part of the cluster, but simply connects to one
* or more nodes directly by adding their respective addresses using {@link #addTransportAddress(org.elasticsearch.common.transport.TransportAddress)}. * or more nodes directly by adding their respective addresses using {@link #addTransportAddress(org.elasticsearch.common.transport.TransportAddress)}.
@ -107,7 +105,7 @@ public class TransportClient extends AbstractClient {
} }
private PluginsService newPluginService(final Settings settings) { private PluginsService newPluginService(final Settings settings) {
final Settings.Builder settingsBuilder = settingsBuilder() final Settings.Builder settingsBuilder = Settings.builder()
.put(NettyTransport.PING_SCHEDULE.getKey(), "5s") // enable by default the transport schedule ping interval .put(NettyTransport.PING_SCHEDULE.getKey(), "5s") // enable by default the transport schedule ping interval
.put(InternalSettingsPreparer.prepareSettings(settings)) .put(InternalSettingsPreparer.prepareSettings(settings))
.put(NetworkService.NETWORK_SERVER.getKey(), false) .put(NetworkService.NETWORK_SERVER.getKey(), false)

View File

@ -72,7 +72,6 @@ import java.util.function.Function;
import static org.elasticsearch.cluster.node.DiscoveryNodeFilters.OpType.AND; import static org.elasticsearch.cluster.node.DiscoveryNodeFilters.OpType.AND;
import static org.elasticsearch.cluster.node.DiscoveryNodeFilters.OpType.OR; import static org.elasticsearch.cluster.node.DiscoveryNodeFilters.OpType.OR;
import static org.elasticsearch.common.settings.Settings.readSettingsFromStream; import static org.elasticsearch.common.settings.Settings.readSettingsFromStream;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.common.settings.Settings.writeSettingsToStream; import static org.elasticsearch.common.settings.Settings.writeSettingsToStream;
/** /**
@ -694,7 +693,7 @@ public class IndexMetaData implements Diffable<IndexMetaData>, FromXContentBuild
} }
public Builder numberOfShards(int numberOfShards) { public Builder numberOfShards(int numberOfShards) {
settings = settingsBuilder().put(settings).put(SETTING_NUMBER_OF_SHARDS, numberOfShards).build(); settings = Settings.builder().put(settings).put(SETTING_NUMBER_OF_SHARDS, numberOfShards).build();
return this; return this;
} }
@ -703,7 +702,7 @@ public class IndexMetaData implements Diffable<IndexMetaData>, FromXContentBuild
} }
public Builder numberOfReplicas(int numberOfReplicas) { public Builder numberOfReplicas(int numberOfReplicas) {
settings = settingsBuilder().put(settings).put(SETTING_NUMBER_OF_REPLICAS, numberOfReplicas).build(); settings = Settings.builder().put(settings).put(SETTING_NUMBER_OF_REPLICAS, numberOfReplicas).build();
return this; return this;
} }
@ -712,7 +711,7 @@ public class IndexMetaData implements Diffable<IndexMetaData>, FromXContentBuild
} }
public Builder creationDate(long creationDate) { public Builder creationDate(long creationDate) {
settings = settingsBuilder().put(settings).put(SETTING_CREATION_DATE, creationDate).build(); settings = Settings.builder().put(settings).put(SETTING_CREATION_DATE, creationDate).build();
return this; return this;
} }
@ -989,7 +988,7 @@ public class IndexMetaData implements Diffable<IndexMetaData>, FromXContentBuild
currentFieldName = parser.currentName(); currentFieldName = parser.currentName();
} else if (token == XContentParser.Token.START_OBJECT) { } else if (token == XContentParser.Token.START_OBJECT) {
if (KEY_SETTINGS.equals(currentFieldName)) { if (KEY_SETTINGS.equals(currentFieldName)) {
builder.settings(Settings.settingsBuilder().put(SettingsLoader.Helper.loadNestedFromMap(parser.mapOrdered()))); builder.settings(Settings.builder().put(SettingsLoader.Helper.loadNestedFromMap(parser.mapOrdered())));
} else if (KEY_MAPPINGS.equals(currentFieldName)) { } else if (KEY_MAPPINGS.equals(currentFieldName)) {
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {

View File

@ -376,7 +376,7 @@ public class IndexTemplateMetaData extends AbstractDiffable<IndexTemplateMetaDat
currentFieldName = parser.currentName(); currentFieldName = parser.currentName();
} else if (token == XContentParser.Token.START_OBJECT) { } else if (token == XContentParser.Token.START_OBJECT) {
if ("settings".equals(currentFieldName)) { if ("settings".equals(currentFieldName)) {
Settings.Builder templateSettingsBuilder = Settings.settingsBuilder(); Settings.Builder templateSettingsBuilder = Settings.builder();
templateSettingsBuilder.put(SettingsLoader.Helper.loadNestedFromMap(parser.mapOrdered())).normalizePrefix(IndexMetaData.INDEX_SETTING_PREFIX); templateSettingsBuilder.put(SettingsLoader.Helper.loadNestedFromMap(parser.mapOrdered())).normalizePrefix(IndexMetaData.INDEX_SETTING_PREFIX);
builder.settings(templateSettingsBuilder.build()); builder.settings(templateSettingsBuilder.build());
} else if ("mappings".equals(currentFieldName)) { } else if ("mappings".equals(currentFieldName)) {

View File

@ -76,7 +76,6 @@ import java.util.TreeMap;
import static java.util.Collections.unmodifiableSet; import static java.util.Collections.unmodifiableSet;
import static org.elasticsearch.common.settings.Settings.readSettingsFromStream; import static org.elasticsearch.common.settings.Settings.readSettingsFromStream;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.common.settings.Settings.writeSettingsToStream; import static org.elasticsearch.common.settings.Settings.writeSettingsToStream;
import static org.elasticsearch.common.util.set.Sets.newHashSet; import static org.elasticsearch.common.util.set.Sets.newHashSet;
@ -181,7 +180,7 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, Fr
this.version = version; this.version = version;
this.transientSettings = transientSettings; this.transientSettings = transientSettings;
this.persistentSettings = persistentSettings; this.persistentSettings = persistentSettings;
this.settings = Settings.settingsBuilder().put(persistentSettings).put(transientSettings).build(); this.settings = Settings.builder().put(persistentSettings).put(transientSettings).build();
this.indices = indices; this.indices = indices;
this.customs = customs; this.customs = customs;
this.templates = templates; this.templates = templates;
@ -925,7 +924,7 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, Fr
throw new IndexNotFoundException(index); throw new IndexNotFoundException(index);
} }
put(IndexMetaData.builder(indexMetaData) put(IndexMetaData.builder(indexMetaData)
.settings(settingsBuilder().put(indexMetaData.getSettings()).put(settings))); .settings(Settings.builder().put(indexMetaData.getSettings()).put(settings)));
} }
return this; return this;
} }
@ -1124,7 +1123,7 @@ public class MetaData implements Iterable<IndexMetaData>, Diffable<MetaData>, Fr
currentFieldName = parser.currentName(); currentFieldName = parser.currentName();
} else if (token == XContentParser.Token.START_OBJECT) { } else if (token == XContentParser.Token.START_OBJECT) {
if ("settings".equals(currentFieldName)) { if ("settings".equals(currentFieldName)) {
builder.persistentSettings(Settings.settingsBuilder().put(SettingsLoader.Helper.loadNestedFromMap(parser.mapOrdered())).build()); builder.persistentSettings(Settings.builder().put(SettingsLoader.Helper.loadNestedFromMap(parser.mapOrdered())).build());
} else if ("indices".equals(currentFieldName)) { } else if ("indices".equals(currentFieldName)) {
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) { while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
builder.put(IndexMetaData.Builder.fromXContent(parser), false); builder.put(IndexMetaData.Builder.fromXContent(parser), false);

View File

@ -86,7 +86,6 @@ import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_INDEX_UUI
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_VERSION_CREATED; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_VERSION_CREATED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
/** /**
* Service responsible for submitting create index requests * Service responsible for submitting create index requests
@ -175,7 +174,7 @@ public class MetaDataCreateIndexService extends AbstractComponent {
} }
public void createIndex(final CreateIndexClusterStateUpdateRequest request, final ActionListener<ClusterStateUpdateResponse> listener) { public void createIndex(final CreateIndexClusterStateUpdateRequest request, final ActionListener<ClusterStateUpdateResponse> listener) {
Settings.Builder updatedSettingsBuilder = Settings.settingsBuilder(); Settings.Builder updatedSettingsBuilder = Settings.builder();
updatedSettingsBuilder.put(request.settings()).normalizePrefix(IndexMetaData.INDEX_SETTING_PREFIX); updatedSettingsBuilder.put(request.settings()).normalizePrefix(IndexMetaData.INDEX_SETTING_PREFIX);
indexScopedSettings.validate(updatedSettingsBuilder); indexScopedSettings.validate(updatedSettingsBuilder);
request.settings(updatedSettingsBuilder.build()); request.settings(updatedSettingsBuilder.build());
@ -265,7 +264,7 @@ public class MetaDataCreateIndexService extends AbstractComponent {
} }
} }
Settings.Builder indexSettingsBuilder = settingsBuilder(); Settings.Builder indexSettingsBuilder = Settings.builder();
// apply templates, here, in reverse order, since first ones are better matching // apply templates, here, in reverse order, since first ones are better matching
for (int i = templates.size() - 1; i >= 0; i--) { for (int i = templates.size() - 1; i >= 0; i--) {
indexSettingsBuilder.put(templates.get(i).settings()); indexSettingsBuilder.put(templates.get(i).settings());

View File

@ -106,7 +106,7 @@ public class MetaDataIndexTemplateService extends AbstractComponent {
} }
public void putTemplate(final PutRequest request, final PutListener listener) { public void putTemplate(final PutRequest request, final PutListener listener) {
Settings.Builder updatedSettingsBuilder = Settings.settingsBuilder(); Settings.Builder updatedSettingsBuilder = Settings.builder();
updatedSettingsBuilder.put(request.settings).normalizePrefix(IndexMetaData.INDEX_SETTING_PREFIX); updatedSettingsBuilder.put(request.settings).normalizePrefix(IndexMetaData.INDEX_SETTING_PREFIX);
request.settings(updatedSettingsBuilder.build()); request.settings(updatedSettingsBuilder.build());

View File

@ -52,8 +52,6 @@ import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
/** /**
* Service responsible for submitting update index settings requests * Service responsible for submitting update index settings requests
*/ */
@ -124,7 +122,7 @@ public class MetaDataUpdateSettingsService extends AbstractComponent implements
if (nrReplicasChanged.size() > 0) { if (nrReplicasChanged.size() > 0) {
// update settings and kick of a reroute (implicit) for them to take effect // update settings and kick of a reroute (implicit) for them to take effect
for (final Integer fNumberOfReplicas : nrReplicasChanged.keySet()) { for (final Integer fNumberOfReplicas : nrReplicasChanged.keySet()) {
Settings settings = Settings.settingsBuilder().put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, fNumberOfReplicas).build(); Settings settings = Settings.builder().put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, fNumberOfReplicas).build();
final List<Index> indices = nrReplicasChanged.get(fNumberOfReplicas); final List<Index> indices = nrReplicasChanged.get(fNumberOfReplicas);
UpdateSettingsClusterStateUpdateRequest updateRequest = new UpdateSettingsClusterStateUpdateRequest() UpdateSettingsClusterStateUpdateRequest updateRequest = new UpdateSettingsClusterStateUpdateRequest()
@ -152,7 +150,7 @@ public class MetaDataUpdateSettingsService extends AbstractComponent implements
} }
public void updateSettings(final UpdateSettingsClusterStateUpdateRequest request, final ActionListener<ClusterStateUpdateResponse> listener) { public void updateSettings(final UpdateSettingsClusterStateUpdateRequest request, final ActionListener<ClusterStateUpdateResponse> listener) {
final Settings normalizedSettings = Settings.settingsBuilder().put(request.settings()).normalizePrefix(IndexMetaData.INDEX_SETTING_PREFIX).build(); final Settings normalizedSettings = Settings.builder().put(request.settings()).normalizePrefix(IndexMetaData.INDEX_SETTING_PREFIX).build();
Settings.Builder settingsForClosedIndices = Settings.builder(); Settings.Builder settingsForClosedIndices = Settings.builder();
Settings.Builder settingsForOpenIndices = Settings.builder(); Settings.Builder settingsForOpenIndices = Settings.builder();
Settings.Builder skipppedSettings = Settings.builder(); Settings.Builder skipppedSettings = Settings.builder();
@ -316,7 +314,7 @@ public class MetaDataUpdateSettingsService extends AbstractComponent implements
if (Version.CURRENT.equals(indexMetaData.getCreationVersion()) == false) { if (Version.CURRENT.equals(indexMetaData.getCreationVersion()) == false) {
// No reason to pollute the settings, we didn't really upgrade anything // No reason to pollute the settings, we didn't really upgrade anything
metaDataBuilder.put(IndexMetaData.builder(indexMetaData) metaDataBuilder.put(IndexMetaData.builder(indexMetaData)
.settings(settingsBuilder().put(indexMetaData.getSettings()) .settings(Settings.builder().put(indexMetaData.getSettings())
.put(IndexMetaData.SETTING_VERSION_MINIMUM_COMPATIBLE, entry.getValue().v2()) .put(IndexMetaData.SETTING_VERSION_MINIMUM_COMPATIBLE, entry.getValue().v2())
.put(IndexMetaData.SETTING_VERSION_UPGRADED, entry.getValue().v1()) .put(IndexMetaData.SETTING_VERSION_UPGRADED, entry.getValue().v1())
) )

View File

@ -154,7 +154,7 @@ public class RepositoriesMetaData extends AbstractDiffable<Custom> implements Me
if (parser.nextToken() != XContentParser.Token.START_OBJECT) { if (parser.nextToken() != XContentParser.Token.START_OBJECT) {
throw new ElasticsearchParseException("failed to parse repository [{}], incompatible params", name); throw new ElasticsearchParseException("failed to parse repository [{}], incompatible params", name);
} }
settings = Settings.settingsBuilder().put(SettingsLoader.Helper.loadNestedFromMap(parser.mapOrdered())).build(); settings = Settings.builder().put(SettingsLoader.Helper.loadNestedFromMap(parser.mapOrdered())).build();
} else { } else {
throw new ElasticsearchParseException("failed to parse repository [{}], unknown field [{}]", name, currentFieldName); throw new ElasticsearchParseException("failed to parse repository [{}], unknown field [{}]", name, currentFieldName);
} }

View File

@ -43,7 +43,6 @@ import java.util.Set;
import static java.util.Collections.unmodifiableMap; import static java.util.Collections.unmodifiableMap;
import static org.elasticsearch.common.Strings.cleanPath; import static org.elasticsearch.common.Strings.cleanPath;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
/** /**
* Configures log4j with a special set of replacements. * Configures log4j with a special set of replacements.
@ -106,7 +105,7 @@ public class LogConfigurator {
// TODO: this is partly a copy of InternalSettingsPreparer...we should pass in Environment and not do all this... // TODO: this is partly a copy of InternalSettingsPreparer...we should pass in Environment and not do all this...
Environment environment = new Environment(settings); Environment environment = new Environment(settings);
Settings.Builder settingsBuilder = settingsBuilder(); Settings.Builder settingsBuilder = Settings.builder();
if (resolveConfig) { if (resolveConfig) {
resolveConfig(environment, settingsBuilder); resolveConfig(environment, settingsBuilder);
} }

View File

@ -427,7 +427,7 @@ public abstract class AbstractScopedSettings extends AbstractComponent {
private boolean updateSettings(Settings toApply, Settings.Builder target, Settings.Builder updates, String type, boolean onlyDynamic) { private boolean updateSettings(Settings toApply, Settings.Builder target, Settings.Builder updates, String type, boolean onlyDynamic) {
boolean changed = false; boolean changed = false;
final Set<String> toRemove = new HashSet<>(); final Set<String> toRemove = new HashSet<>();
Settings.Builder settingsBuilder = Settings.settingsBuilder(); Settings.Builder settingsBuilder = Settings.builder();
for (Map.Entry<String, String> entry : toApply.getAsMap().entrySet()) { for (Map.Entry<String, String> entry : toApply.getAsMap().entrySet()) {
if (entry.getValue() == null) { if (entry.getValue() == null) {
toRemove.add(entry.getKey()); toRemove.add(entry.getKey());

View File

@ -735,14 +735,10 @@ public final class Settings implements ToXContent {
} }
} }
public static Builder builder() {
return new Builder();
}
/** /**
* Returns a builder to be used in order to build settings. * Returns a builder to be used in order to build settings.
*/ */
public static Builder settingsBuilder() { public static Builder builder() {
return new Builder(); return new Builder();
} }
@ -771,7 +767,7 @@ public final class Settings implements ToXContent {
/** /**
* A builder allowing to put different settings and then {@link #build()} an immutable * A builder allowing to put different settings and then {@link #build()} an immutable
* settings implementation. Use {@link Settings#settingsBuilder()} in order to * settings implementation. Use {@link Settings#builder()} in order to
* construct it. * construct it.
*/ */
public static class Builder { public static class Builder {

View File

@ -97,7 +97,7 @@ public final class SettingsFilter extends AbstractComponent {
} }
private static Settings filterSettings(Iterable<String> patterns, Settings settings) { private static Settings filterSettings(Iterable<String> patterns, Settings settings) {
Settings.Builder builder = Settings.settingsBuilder().put(settings); Settings.Builder builder = Settings.builder().put(settings);
List<String> simpleMatchPatternList = new ArrayList<>(); List<String> simpleMatchPatternList = new ArrayList<>();
for (String pattern : patterns) { for (String pattern : patterns) {
if (Regex.isSimpleMatchPattern(pattern)) { if (Regex.isSimpleMatchPattern(pattern)) {

View File

@ -73,7 +73,7 @@ import java.util.Map;
public final class AnalysisModule extends AbstractModule { public final class AnalysisModule extends AbstractModule {
static { static {
Settings build = Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) Settings build = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1) .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1)
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
.build(); .build();

View File

@ -213,12 +213,12 @@ public class HunspellService extends AbstractComponent {
private static Settings loadDictionarySettings(Path dir, Settings defaults) { private static Settings loadDictionarySettings(Path dir, Settings defaults) {
Path file = dir.resolve("settings.yml"); Path file = dir.resolve("settings.yml");
if (Files.exists(file)) { if (Files.exists(file)) {
return Settings.settingsBuilder().loadFromPath(file).put(defaults).build(); return Settings.builder().loadFromPath(file).put(defaults).build();
} }
file = dir.resolve("settings.json"); file = dir.resolve("settings.json");
if (Files.exists(file)) { if (Files.exists(file)) {
return Settings.settingsBuilder().loadFromPath(file).put(defaults).build(); return Settings.builder().loadFromPath(file).put(defaults).build();
} }
return defaults; return defaults;

View File

@ -121,8 +121,6 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Function; import java.util.function.Function;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
/** /**
* A node represent a node within a cluster (<tt>cluster.name</tt>). The {@link #client()} can be used * A node represent a node within a cluster (<tt>cluster.name</tt>). The {@link #client()} can be used
* in order to use a {@link Client} to perform actions/operations against the cluster. * in order to use a {@link Client} to perform actions/operations against the cluster.
@ -162,7 +160,7 @@ public class Node implements Closeable {
} }
protected Node(Environment tmpEnv, Version version, Collection<Class<? extends Plugin>> classpathPlugins) { protected Node(Environment tmpEnv, Version version, Collection<Class<? extends Plugin>> classpathPlugins) {
Settings tmpSettings = settingsBuilder().put(tmpEnv.settings()) Settings tmpSettings = Settings.builder().put(tmpEnv.settings())
.put(Client.CLIENT_TYPE_SETTING_S.getKey(), CLIENT_TYPE).build(); .put(Client.CLIENT_TYPE_SETTING_S.getKey(), CLIENT_TYPE).build();
tmpSettings = TribeService.processSettings(tmpSettings); tmpSettings = TribeService.processSettings(tmpSettings);

View File

@ -45,7 +45,6 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import static org.elasticsearch.common.Strings.cleanPath; import static org.elasticsearch.common.Strings.cleanPath;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
/** /**
* *
@ -65,7 +64,7 @@ public class InternalSettingsPreparer {
* Prepares the settings by gathering all elasticsearch system properties and setting defaults. * Prepares the settings by gathering all elasticsearch system properties and setting defaults.
*/ */
public static Settings prepareSettings(Settings input) { public static Settings prepareSettings(Settings input) {
Settings.Builder output = settingsBuilder(); Settings.Builder output = Settings.builder();
initializeSettings(output, input, true); initializeSettings(output, input, true);
finalizeSettings(output, null, null); finalizeSettings(output, null, null);
return output.build(); return output.build();
@ -82,7 +81,7 @@ public class InternalSettingsPreparer {
*/ */
public static Environment prepareEnvironment(Settings input, Terminal terminal) { public static Environment prepareEnvironment(Settings input, Terminal terminal) {
// just create enough settings to build the environment, to get the config dir // just create enough settings to build the environment, to get the config dir
Settings.Builder output = settingsBuilder(); Settings.Builder output = Settings.builder();
initializeSettings(output, input, true); initializeSettings(output, input, true);
Environment environment = new Environment(output.build()); Environment environment = new Environment(output.build());

View File

@ -238,7 +238,7 @@ public class PluginsService extends AbstractComponent {
public Settings updatedSettings() { public Settings updatedSettings() {
Map<String, String> foundSettings = new HashMap<>(); Map<String, String> foundSettings = new HashMap<>();
final Settings.Builder builder = Settings.settingsBuilder(); final Settings.Builder builder = Settings.builder();
for (Tuple<PluginInfo, Plugin> plugin : plugins) { for (Tuple<PluginInfo, Plugin> plugin : plugins) {
Settings settings = plugin.v2().additionalSettings(); Settings settings = plugin.v2().additionalSettings();
for (String setting : settings.getAsMap().keySet()) { for (String setting : settings.getAsMap().keySet()) {

View File

@ -67,10 +67,10 @@ public class RestUpdateSettingsAction extends BaseRestHandler {
updateSettingsRequest.masterNodeTimeout(request.paramAsTime("master_timeout", updateSettingsRequest.masterNodeTimeout())); updateSettingsRequest.masterNodeTimeout(request.paramAsTime("master_timeout", updateSettingsRequest.masterNodeTimeout()));
updateSettingsRequest.indicesOptions(IndicesOptions.fromRequest(request, updateSettingsRequest.indicesOptions())); updateSettingsRequest.indicesOptions(IndicesOptions.fromRequest(request, updateSettingsRequest.indicesOptions()));
Settings.Builder updateSettings = Settings.settingsBuilder(); Settings.Builder updateSettings = Settings.builder();
String bodySettingsStr = request.content().toUtf8(); String bodySettingsStr = request.content().toUtf8();
if (Strings.hasText(bodySettingsStr)) { if (Strings.hasText(bodySettingsStr)) {
Settings buildSettings = Settings.settingsBuilder().loadFromSource(bodySettingsStr).build(); Settings buildSettings = Settings.builder().loadFromSource(bodySettingsStr).build();
for (Map.Entry<String, String> entry : buildSettings.getAsMap().entrySet()) { for (Map.Entry<String, String> entry : buildSettings.getAsMap().entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
String value = entry.getValue(); String value = entry.getValue();

View File

@ -255,7 +255,7 @@ public class RestoreService extends AbstractComponent implements ClusterStateLis
createIndexService.validateIndexName(renamedIndexName, currentState); createIndexService.validateIndexName(renamedIndexName, currentState);
createIndexService.validateIndexSettings(renamedIndexName, snapshotIndexMetaData.getSettings()); createIndexService.validateIndexSettings(renamedIndexName, snapshotIndexMetaData.getSettings());
IndexMetaData.Builder indexMdBuilder = IndexMetaData.builder(snapshotIndexMetaData).state(IndexMetaData.State.OPEN).index(renamedIndexName); IndexMetaData.Builder indexMdBuilder = IndexMetaData.builder(snapshotIndexMetaData).state(IndexMetaData.State.OPEN).index(renamedIndexName);
indexMdBuilder.settings(Settings.settingsBuilder().put(snapshotIndexMetaData.getSettings()).put(IndexMetaData.SETTING_INDEX_UUID, Strings.randomBase64UUID())); indexMdBuilder.settings(Settings.builder().put(snapshotIndexMetaData.getSettings()).put(IndexMetaData.SETTING_INDEX_UUID, Strings.randomBase64UUID()));
if (!request.includeAliases() && !snapshotIndexMetaData.getAliases().isEmpty()) { if (!request.includeAliases() && !snapshotIndexMetaData.getAliases().isEmpty()) {
// Remove all aliases - they shouldn't be restored // Remove all aliases - they shouldn't be restored
indexMdBuilder.removeAllAliases(); indexMdBuilder.removeAllAliases();
@ -291,7 +291,7 @@ public class RestoreService extends AbstractComponent implements ClusterStateLis
aliases.add(alias.value); aliases.add(alias.value);
} }
} }
indexMdBuilder.settings(Settings.settingsBuilder().put(snapshotIndexMetaData.getSettings()).put(IndexMetaData.SETTING_INDEX_UUID, currentIndexMetaData.getIndexUUID())); indexMdBuilder.settings(Settings.builder().put(snapshotIndexMetaData.getSettings()).put(IndexMetaData.SETTING_INDEX_UUID, currentIndexMetaData.getIndexUUID()));
IndexMetaData updatedIndexMetaData = indexMdBuilder.index(renamedIndexName).build(); IndexMetaData updatedIndexMetaData = indexMdBuilder.index(renamedIndexName).build();
rtBuilder.addAsRestore(updatedIndexMetaData, restoreSource); rtBuilder.addAsRestore(updatedIndexMetaData, restoreSource);
blocks.updateBlocks(updatedIndexMetaData); blocks.updateBlocks(updatedIndexMetaData);
@ -388,7 +388,7 @@ public class RestoreService extends AbstractComponent implements ClusterStateLis
if (changeSettings.names().isEmpty() && ignoreSettings.length == 0) { if (changeSettings.names().isEmpty() && ignoreSettings.length == 0) {
return indexMetaData; return indexMetaData;
} }
Settings normalizedChangeSettings = Settings.settingsBuilder().put(changeSettings).normalizePrefix(IndexMetaData.INDEX_SETTING_PREFIX).build(); Settings normalizedChangeSettings = Settings.builder().put(changeSettings).normalizePrefix(IndexMetaData.INDEX_SETTING_PREFIX).build();
IndexMetaData.Builder builder = IndexMetaData.builder(indexMetaData); IndexMetaData.Builder builder = IndexMetaData.builder(indexMetaData);
Map<String, String> settingsMap = new HashMap<>(indexMetaData.getSettings().getAsMap()); Map<String, String> settingsMap = new HashMap<>(indexMetaData.getSettings().getAsMap());
List<String> simpleMatchPatterns = new ArrayList<>(); List<String> simpleMatchPatterns = new ArrayList<>();

View File

@ -65,7 +65,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import static java.util.Collections.unmodifiableMap; import static java.util.Collections.unmodifiableMap;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.common.unit.SizeValue.parseSizeValue; import static org.elasticsearch.common.unit.SizeValue.parseSizeValue;
import static org.elasticsearch.common.unit.TimeValue.timeValueMinutes; import static org.elasticsearch.common.unit.TimeValue.timeValueMinutes;
@ -181,7 +180,7 @@ public class ThreadPool extends AbstractComponent implements Closeable {
} }
public Settings build() { public Settings build() {
return settingsBuilder().put(settings).build(); return Settings.builder().put(settings).build();
} }
} }

View File

@ -126,7 +126,6 @@ import static org.elasticsearch.common.settings.Setting.boolSetting;
import static org.elasticsearch.common.settings.Setting.byteSizeSetting; import static org.elasticsearch.common.settings.Setting.byteSizeSetting;
import static org.elasticsearch.common.settings.Setting.intSetting; import static org.elasticsearch.common.settings.Setting.intSetting;
import static org.elasticsearch.common.settings.Setting.timeSetting; import static org.elasticsearch.common.settings.Setting.timeSetting;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.common.transport.NetworkExceptionHelper.isCloseConnectionException; import static org.elasticsearch.common.transport.NetworkExceptionHelper.isCloseConnectionException;
import static org.elasticsearch.common.transport.NetworkExceptionHelper.isConnectException; import static org.elasticsearch.common.transport.NetworkExceptionHelper.isConnectException;
import static org.elasticsearch.common.util.concurrent.ConcurrentCollections.newConcurrentMap; import static org.elasticsearch.common.util.concurrent.ConcurrentCollections.newConcurrentMap;
@ -337,7 +336,7 @@ public class NettyTransport extends AbstractLifecycleComponent<Transport> implem
profileSettings.toDelimitedString(',')); profileSettings.toDelimitedString(','));
continue; continue;
} else if (TransportSettings.DEFAULT_PROFILE.equals(name)) { } else if (TransportSettings.DEFAULT_PROFILE.equals(name)) {
profileSettings = settingsBuilder() profileSettings = Settings.builder()
.put(profileSettings) .put(profileSettings)
.put("port", profileSettings.get("port", TransportSettings.PORT.get(this.settings))) .put("port", profileSettings.get("port", TransportSettings.PORT.get(this.settings)))
.build(); .build();
@ -348,7 +347,7 @@ public class NettyTransport extends AbstractLifecycleComponent<Transport> implem
} }
// merge fallback settings with default settings with profile settings so we have complete settings with default values // merge fallback settings with default settings with profile settings so we have complete settings with default values
Settings mergedSettings = settingsBuilder() Settings mergedSettings = Settings.builder()
.put(fallbackSettings) .put(fallbackSettings)
.put(defaultSettings) .put(defaultSettings)
.put(profileSettings) .put(profileSettings)
@ -414,7 +413,7 @@ public class NettyTransport extends AbstractLifecycleComponent<Transport> implem
} }
private Settings createFallbackSettings() { private Settings createFallbackSettings() {
Settings.Builder fallbackSettingsBuilder = settingsBuilder(); Settings.Builder fallbackSettingsBuilder = Settings.builder();
List<String> fallbackBindHost = TransportSettings.BIND_HOST.get(settings); List<String> fallbackBindHost = TransportSettings.BIND_HOST.get(settings);
if (fallbackBindHost.isEmpty() == false) { if (fallbackBindHost.isEmpty() == false) {

View File

@ -52,7 +52,7 @@ public final class ClusterAllocationExplainIT extends ESIntegTestCase {
}); });
logger.info("--> creating 'test' index"); logger.info("--> creating 'test' index");
prepareCreate("test").setSettings(Settings.settingsBuilder() prepareCreate("test").setSettings(Settings.builder()
.put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "1m") .put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.getKey(), "1m")
.put(IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 5) .put(IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 5)
.put(IndexMetaData.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 1)).get(); .put(IndexMetaData.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 1)).get();

View File

@ -45,7 +45,7 @@ public class RepositoryBlocksIT extends ESIntegTestCase {
assertBlocked(client().admin().cluster().preparePutRepository("test-repo-blocks") assertBlocked(client().admin().cluster().preparePutRepository("test-repo-blocks")
.setType("fs") .setType("fs")
.setVerify(false) .setVerify(false)
.setSettings(Settings.settingsBuilder().put("location", randomRepoPath())), MetaData.CLUSTER_READ_ONLY_BLOCK); .setSettings(Settings.builder().put("location", randomRepoPath())), MetaData.CLUSTER_READ_ONLY_BLOCK);
} finally { } finally {
setClusterReadOnly(false); setClusterReadOnly(false);
} }
@ -54,14 +54,14 @@ public class RepositoryBlocksIT extends ESIntegTestCase {
assertAcked(client().admin().cluster().preparePutRepository("test-repo-blocks") assertAcked(client().admin().cluster().preparePutRepository("test-repo-blocks")
.setType("fs") .setType("fs")
.setVerify(false) .setVerify(false)
.setSettings(Settings.settingsBuilder().put("location", randomRepoPath()))); .setSettings(Settings.builder().put("location", randomRepoPath())));
} }
public void testVerifyRepositoryWithBlocks() { public void testVerifyRepositoryWithBlocks() {
assertAcked(client().admin().cluster().preparePutRepository("test-repo-blocks") assertAcked(client().admin().cluster().preparePutRepository("test-repo-blocks")
.setType("fs") .setType("fs")
.setVerify(false) .setVerify(false)
.setSettings(Settings.settingsBuilder().put("location", randomRepoPath()))); .setSettings(Settings.builder().put("location", randomRepoPath())));
// This test checks that the Get Repository operation is never blocked, even if the cluster is read only. // This test checks that the Get Repository operation is never blocked, even if the cluster is read only.
try { try {
@ -77,7 +77,7 @@ public class RepositoryBlocksIT extends ESIntegTestCase {
assertAcked(client().admin().cluster().preparePutRepository("test-repo-blocks") assertAcked(client().admin().cluster().preparePutRepository("test-repo-blocks")
.setType("fs") .setType("fs")
.setVerify(false) .setVerify(false)
.setSettings(Settings.settingsBuilder().put("location", randomRepoPath()))); .setSettings(Settings.builder().put("location", randomRepoPath())));
logger.info("--> deleting a repository is blocked when the cluster is read only"); logger.info("--> deleting a repository is blocked when the cluster is read only");
try { try {
@ -95,7 +95,7 @@ public class RepositoryBlocksIT extends ESIntegTestCase {
assertAcked(client().admin().cluster().preparePutRepository("test-repo-blocks") assertAcked(client().admin().cluster().preparePutRepository("test-repo-blocks")
.setType("fs") .setType("fs")
.setVerify(false) .setVerify(false)
.setSettings(Settings.settingsBuilder().put("location", randomRepoPath()))); .setSettings(Settings.builder().put("location", randomRepoPath())));
// This test checks that the Get Repository operation is never blocked, even if the cluster is read only. // This test checks that the Get Repository operation is never blocked, even if the cluster is read only.
try { try {

View File

@ -69,7 +69,7 @@ public class SnapshotBlocksIT extends ESIntegTestCase {
logger.info("--> register a repository"); logger.info("--> register a repository");
assertAcked(client().admin().cluster().preparePutRepository(REPOSITORY_NAME) assertAcked(client().admin().cluster().preparePutRepository(REPOSITORY_NAME)
.setType("fs") .setType("fs")
.setSettings(Settings.settingsBuilder().put("location", randomRepoPath()))); .setSettings(Settings.builder().put("location", randomRepoPath())));
logger.info("--> verify the repository"); logger.info("--> verify the repository");
VerifyRepositoryResponse verifyResponse = client().admin().cluster().prepareVerifyRepository(REPOSITORY_NAME).get(); VerifyRepositoryResponse verifyResponse = client().admin().cluster().prepareVerifyRepository(REPOSITORY_NAME).get();

View File

@ -38,7 +38,6 @@ import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
@ -159,7 +158,7 @@ public class ClusterStatsIT extends ESIntegTestCase {
public void testValuesSmokeScreen() throws IOException { public void testValuesSmokeScreen() throws IOException {
internalCluster().ensureAtMostNumDataNodes(5); internalCluster().ensureAtMostNumDataNodes(5);
internalCluster().ensureAtLeastNumDataNodes(1); internalCluster().ensureAtLeastNumDataNodes(1);
assertAcked(prepareCreate("test1").setSettings(settingsBuilder().put(Store.INDEX_STORE_STATS_REFRESH_INTERVAL_SETTING.getKey(), 0).build())); assertAcked(prepareCreate("test1").setSettings(Settings.builder().put(Store.INDEX_STORE_STATS_REFRESH_INTERVAL_SETTING.getKey(), 0).build()));
index("test1", "type", "1", "f", "f"); index("test1", "type", "1", "f", "f");
/* /*
* Ensure at least one shard is allocated otherwise the FS stats might * Ensure at least one shard is allocated otherwise the FS stats might

View File

@ -25,7 +25,6 @@ import org.elasticsearch.action.admin.indices.analyze.TransportAnalyzeAction;
import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment; import org.elasticsearch.env.Environment;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.analysis.AnalysisRegistry; import org.elasticsearch.index.analysis.AnalysisRegistry;
import org.elasticsearch.index.analysis.AnalysisService; import org.elasticsearch.index.analysis.AnalysisService;
@ -36,8 +35,6 @@ import org.elasticsearch.test.IndexSettingsModule;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
public class TransportAnalyzeActionTests extends ESTestCase { public class TransportAnalyzeActionTests extends ESTestCase {
private AnalysisService analysisService; private AnalysisService analysisService;
@ -49,7 +46,7 @@ public class TransportAnalyzeActionTests extends ESTestCase {
super.setUp(); super.setUp();
Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build(); Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build();
Settings indexSettings = settingsBuilder() Settings indexSettings = Settings.builder()
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
.put("index.analysis.filter.wordDelimiter.type", "word_delimiter") .put("index.analysis.filter.wordDelimiter.type", "word_delimiter")
.put("index.analysis.filter.wordDelimiter.split_on_numerics", false) .put("index.analysis.filter.wordDelimiter.split_on_numerics", false)

View File

@ -48,7 +48,7 @@ public class MetaDataIndexTemplateServiceTests extends ESTestCase {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, "0"); map.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, "0");
request.settings(Settings.settingsBuilder().put(map).build()); request.settings(Settings.builder().put(map).build());
List<Throwable> throwables = putTemplate(request); List<Throwable> throwables = putTemplate(request);
assertEquals(throwables.size(), 1); assertEquals(throwables.size(), 1);
@ -62,7 +62,7 @@ public class MetaDataIndexTemplateServiceTests extends ESTestCase {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, "0"); map.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, "0");
request.settings(Settings.settingsBuilder().put(map).build()); request.settings(Settings.builder().put(map).build());
List<Throwable> throwables = putTemplate(request); List<Throwable> throwables = putTemplate(request);
assertEquals(throwables.size(), 1); assertEquals(throwables.size(), 1);

View File

@ -28,7 +28,7 @@ import org.elasticsearch.test.ESIntegTestCase.Scope;
public class BulkProcessorClusterSettingsIT extends ESIntegTestCase { public class BulkProcessorClusterSettingsIT extends ESIntegTestCase {
public void testBulkProcessorAutoCreateRestrictions() throws Exception { public void testBulkProcessorAutoCreateRestrictions() throws Exception {
// See issue #8125 // See issue #8125
Settings settings = Settings.settingsBuilder().put("action.auto_create_index", false).build(); Settings settings = Settings.builder().put("action.auto_create_index", false).build();
internalCluster().startNode(settings); internalCluster().startNode(settings);

View File

@ -208,7 +208,7 @@ public abstract class AbstractTermVectorsTestCase extends ESIntegTestCase {
field.addToMappings(mappingBuilder); field.addToMappings(mappingBuilder);
} }
mappingBuilder.endObject().endObject().endObject(); mappingBuilder.endObject().endObject().endObject();
Settings.Builder settings = Settings.settingsBuilder() Settings.Builder settings = Settings.builder()
.put(indexSettings()) .put(indexSettings())
.put("index.analysis.analyzer.tv_test.tokenizer", "standard") .put("index.analysis.analyzer.tv_test.tokenizer", "standard")
.putArray("index.analysis.analyzer.tv_test.filter", "type_as_payload", "lowercase"); .putArray("index.analysis.analyzer.tv_test.filter", "type_as_payload", "lowercase");

View File

@ -37,7 +37,6 @@ import org.elasticsearch.common.lucene.uid.Versions;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContent; import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.json.JsonXContent;
import org.elasticsearch.index.engine.VersionConflictEngineException; import org.elasticsearch.index.engine.VersionConflictEngineException;
import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.FieldMapper;
import org.hamcrest.Matcher; import org.hamcrest.Matcher;
@ -52,7 +51,6 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder; import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows;
@ -198,7 +196,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
.endObject().endObject(); .endObject().endObject();
assertAcked(prepareCreate("test").addMapping("type1", mapping) assertAcked(prepareCreate("test").addMapping("type1", mapping)
.addAlias(new Alias("alias")) .addAlias(new Alias("alias"))
.setSettings(settingsBuilder() .setSettings(Settings.builder()
.put(indexSettings()) .put(indexSettings())
.put("index.analysis.analyzer.tv_test.tokenizer", "whitespace") .put("index.analysis.analyzer.tv_test.tokenizer", "whitespace")
.putArray("index.analysis.analyzer.tv_test.filter", "type_as_payload", "lowercase"))); .putArray("index.analysis.analyzer.tv_test.filter", "type_as_payload", "lowercase")));
@ -285,7 +283,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
.endObject() .endObject()
.endObject().endObject(); .endObject().endObject();
assertAcked(prepareCreate("test").addMapping("type1", mapping) assertAcked(prepareCreate("test").addMapping("type1", mapping)
.setSettings(settingsBuilder() .setSettings(Settings.builder()
.put("index.analysis.analyzer.tv_test.tokenizer", "whitespace") .put("index.analysis.analyzer.tv_test.tokenizer", "whitespace")
.putArray("index.analysis.analyzer.tv_test.filter", "type_as_payload", "lowercase"))); .putArray("index.analysis.analyzer.tv_test.filter", "type_as_payload", "lowercase")));
ensureYellow(); ensureYellow();
@ -431,7 +429,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
.startObject("field").field("type", "text").field("term_vector", "with_positions_offsets_payloads") .startObject("field").field("type", "text").field("term_vector", "with_positions_offsets_payloads")
.field("analyzer", "payload_test").endObject().endObject().endObject().endObject(); .field("analyzer", "payload_test").endObject().endObject().endObject().endObject();
assertAcked(prepareCreate("test").addMapping("type1", mapping).setSettings( assertAcked(prepareCreate("test").addMapping("type1", mapping).setSettings(
settingsBuilder() Settings.builder()
.put(indexSettings()) .put(indexSettings())
.put("index.analysis.analyzer.payload_test.tokenizer", "whitespace") .put("index.analysis.analyzer.payload_test.tokenizer", "whitespace")
.putArray("index.analysis.analyzer.payload_test.filter", "my_delimited_payload_filter") .putArray("index.analysis.analyzer.payload_test.filter", "my_delimited_payload_filter")
@ -597,7 +595,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
assertAcked(prepareCreate("test") assertAcked(prepareCreate("test")
.addMapping("type1", mapping) .addMapping("type1", mapping)
.setSettings(settingsBuilder() .setSettings(Settings.builder()
.put(indexSettings()) .put(indexSettings())
.put("index.analysis.analyzer.tv_test.tokenizer", "whitespace") .put("index.analysis.analyzer.tv_test.tokenizer", "whitespace")
.putArray("index.analysis.analyzer.tv_test.filter", "type_as_payload", "lowercase"))); .putArray("index.analysis.analyzer.tv_test.filter", "type_as_payload", "lowercase")));
@ -785,7 +783,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
public void testArtificialVsExisting() throws ExecutionException, InterruptedException, IOException { public void testArtificialVsExisting() throws ExecutionException, InterruptedException, IOException {
// setup indices // setup indices
Settings.Builder settings = settingsBuilder() Settings.Builder settings = Settings.builder()
.put(indexSettings()) .put(indexSettings())
.put("index.analysis.analyzer", "standard"); .put("index.analysis.analyzer", "standard");
assertAcked(prepareCreate("test") assertAcked(prepareCreate("test")
@ -843,7 +841,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
public void testArtificialNoDoc() throws IOException { public void testArtificialNoDoc() throws IOException {
// setup indices // setup indices
Settings.Builder settings = settingsBuilder() Settings.Builder settings = Settings.builder()
.put(indexSettings()) .put(indexSettings())
.put("index.analysis.analyzer", "standard"); .put("index.analysis.analyzer", "standard");
assertAcked(prepareCreate("test") assertAcked(prepareCreate("test")
@ -891,7 +889,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
mapping.endObject().endObject().endObject(); mapping.endObject().endObject().endObject();
// setup indices with mapping // setup indices with mapping
Settings.Builder settings = settingsBuilder() Settings.Builder settings = Settings.builder()
.put(indexSettings()) .put(indexSettings())
.put("index.analysis.analyzer", "standard"); .put("index.analysis.analyzer", "standard");
assertAcked(prepareCreate("test") assertAcked(prepareCreate("test")
@ -982,7 +980,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
public void testTermVectorsWithVersion() { public void testTermVectorsWithVersion() {
assertAcked(prepareCreate("test").addAlias(new Alias("alias")) assertAcked(prepareCreate("test").addAlias(new Alias("alias"))
.setSettings(Settings.settingsBuilder().put("index.refresh_interval", -1))); .setSettings(Settings.builder().put("index.refresh_interval", -1)));
ensureGreen(); ensureGreen();
TermVectorsResponse response = client().prepareTermVectors("test", "type1", "1").get(); TermVectorsResponse response = client().prepareTermVectors("test", "type1", "1").get();
@ -1085,7 +1083,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
public void testFilterLength() throws ExecutionException, InterruptedException, IOException { public void testFilterLength() throws ExecutionException, InterruptedException, IOException {
logger.info("Setting up the index ..."); logger.info("Setting up the index ...");
Settings.Builder settings = settingsBuilder() Settings.Builder settings = Settings.builder()
.put(indexSettings()) .put(indexSettings())
.put("index.analysis.analyzer", "keyword"); .put("index.analysis.analyzer", "keyword");
assertAcked(prepareCreate("test") assertAcked(prepareCreate("test")
@ -1123,7 +1121,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
public void testFilterTermFreq() throws ExecutionException, InterruptedException, IOException { public void testFilterTermFreq() throws ExecutionException, InterruptedException, IOException {
logger.info("Setting up the index ..."); logger.info("Setting up the index ...");
Settings.Builder settings = settingsBuilder() Settings.Builder settings = Settings.builder()
.put(indexSettings()) .put(indexSettings())
.put("index.analysis.analyzer", "keyword"); .put("index.analysis.analyzer", "keyword");
assertAcked(prepareCreate("test") assertAcked(prepareCreate("test")
@ -1163,7 +1161,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase {
public void testFilterDocFreq() throws ExecutionException, InterruptedException, IOException { public void testFilterDocFreq() throws ExecutionException, InterruptedException, IOException {
logger.info("Setting up the index ..."); logger.info("Setting up the index ...");
Settings.Builder settings = settingsBuilder() Settings.Builder settings = Settings.builder()
.put(indexSettings()) .put(indexSettings())
.put("index.analysis.analyzer", "keyword") .put("index.analysis.analyzer", "keyword")
.put("index.number_of_shards", 1); // no dfs .put("index.number_of_shards", 1); // no dfs

View File

@ -85,7 +85,7 @@ public class MultiTermVectorsIT extends AbstractTermVectorsTestCase {
public void testMultiTermVectorsWithVersion() throws Exception { public void testMultiTermVectorsWithVersion() throws Exception {
assertAcked(prepareCreate("test").addAlias(new Alias("alias")) assertAcked(prepareCreate("test").addAlias(new Alias("alias"))
.setSettings(Settings.settingsBuilder().put("index.refresh_interval", -1))); .setSettings(Settings.builder().put("index.refresh_interval", -1)));
ensureGreen(); ensureGreen();
MultiTermVectorsResponse response = client().prepareMultiTermVectors().add(indexOrAlias(), "type1", "1").get(); MultiTermVectorsResponse response = client().prepareMultiTermVectors().add(indexOrAlias(), "type1", "1").get();

View File

@ -35,6 +35,7 @@ import org.elasticsearch.cluster.metadata.AliasMetaData;
import org.elasticsearch.cluster.metadata.AliasOrIndex; import org.elasticsearch.cluster.metadata.AliasOrIndex;
import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.StopWatch; import org.elasticsearch.common.StopWatch;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
@ -64,7 +65,6 @@ import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_ME
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_READ;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.index.query.QueryBuilders.hasChildQuery; import static org.elasticsearch.index.query.QueryBuilders.hasChildQuery;
import static org.elasticsearch.index.query.QueryBuilders.hasParentQuery; import static org.elasticsearch.index.query.QueryBuilders.hasParentQuery;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery; import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
@ -447,7 +447,7 @@ public class IndexAliasesIT extends ESIntegTestCase {
public void testWaitForAliasCreationSingleShard() throws Exception { public void testWaitForAliasCreationSingleShard() throws Exception {
logger.info("--> creating index [test]"); logger.info("--> creating index [test]");
assertAcked(admin().indices().create(createIndexRequest("test").settings(settingsBuilder().put("index.number_of_replicas", 0).put("index.number_of_shards", 1))).get()); assertAcked(admin().indices().create(createIndexRequest("test").settings(Settings.builder().put("index.number_of_replicas", 0).put("index.number_of_shards", 1))).get());
ensureGreen(); ensureGreen();

View File

@ -27,11 +27,11 @@ import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.cluster.block.ClusterBlockException; import org.elasticsearch.cluster.block.ClusterBlockException;
import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase;
import java.util.HashMap; import java.util.HashMap;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.notNullValue;
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST) @ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.TEST)
@ -83,11 +83,11 @@ public class SimpleBlocksIT extends ESIntegTestCase {
canCreateIndex("test1"); canCreateIndex("test1");
canIndexDocument("test1"); canIndexDocument("test1");
client().admin().indices().prepareUpdateSettings("test1") client().admin().indices().prepareUpdateSettings("test1")
.setSettings(settingsBuilder().put(IndexMetaData.SETTING_BLOCKS_WRITE, true)) .setSettings(Settings.builder().put(IndexMetaData.SETTING_BLOCKS_WRITE, true))
.execute().actionGet(); .execute().actionGet();
canNotIndexDocument("test1"); canNotIndexDocument("test1");
client().admin().indices().prepareUpdateSettings("test1") client().admin().indices().prepareUpdateSettings("test1")
.setSettings(settingsBuilder().put(IndexMetaData.SETTING_BLOCKS_WRITE, false)) .setSettings(Settings.builder().put(IndexMetaData.SETTING_BLOCKS_WRITE, false))
.execute().actionGet(); .execute().actionGet();
canIndexDocument("test1"); canIndexDocument("test1");
} }

View File

@ -99,7 +99,7 @@ public class ClusterStateBackwardsCompatIT extends ESBackcompatTestCase {
} }
private TransportClient newTransportClient() { private TransportClient newTransportClient() {
Settings settings = Settings.settingsBuilder().put("client.transport.ignore_cluster_name", true) Settings settings = Settings.builder().put("client.transport.ignore_cluster_name", true)
.put("node.name", "transport_client_" + getTestName()).build(); .put("node.name", "transport_client_" + getTestName()).build();
return TransportClient.builder().settings(settings).build(); return TransportClient.builder().settings(settings).build();
} }

View File

@ -38,7 +38,7 @@ public class NodesStatsBasicBackwardsCompatIT extends ESBackcompatTestCase {
NodesInfoResponse nodesInfo = client().admin().cluster().prepareNodesInfo().execute().actionGet(); NodesInfoResponse nodesInfo = client().admin().cluster().prepareNodesInfo().execute().actionGet();
Settings settings = Settings.settingsBuilder() Settings settings = Settings.builder()
.put("client.transport.ignore_cluster_name", true) .put("client.transport.ignore_cluster_name", true)
.put("node.name", "transport_client_" + getTestName()).build(); .put("node.name", "transport_client_" + getTestName()).build();
@ -56,7 +56,7 @@ public class NodesStatsBasicBackwardsCompatIT extends ESBackcompatTestCase {
NodesInfoResponse nodesInfo = client().admin().cluster().prepareNodesInfo().execute().actionGet(); NodesInfoResponse nodesInfo = client().admin().cluster().prepareNodesInfo().execute().actionGet();
Settings settings = Settings.settingsBuilder() Settings settings = Settings.builder()
.put("node.name", "transport_client_" + getTestName()) .put("node.name", "transport_client_" + getTestName())
.put("client.transport.ignore_cluster_name", true).build(); .put("client.transport.ignore_cluster_name", true).build();

View File

@ -52,7 +52,6 @@ import java.util.Locale;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.TreeSet; import java.util.TreeSet;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
@ -66,7 +65,7 @@ public class RestoreBackwardsCompatIT extends AbstractSnapshotIntegTestCase {
protected Settings nodeSettings(int nodeOrdinal) { protected Settings nodeSettings(int nodeOrdinal) {
if (randomBoolean()) { if (randomBoolean()) {
// Configure using path.repo // Configure using path.repo
return settingsBuilder() return Settings.builder()
.put(super.nodeSettings(nodeOrdinal)) .put(super.nodeSettings(nodeOrdinal))
.put(Environment.PATH_REPO_SETTING.getKey(), getBwcIndicesPath()) .put(Environment.PATH_REPO_SETTING.getKey(), getBwcIndicesPath())
.build(); .build();
@ -74,7 +73,7 @@ public class RestoreBackwardsCompatIT extends AbstractSnapshotIntegTestCase {
// Configure using url white list // Configure using url white list
try { try {
URI repoJarPatternUri = new URI("jar:" + getBwcIndicesPath().toUri().toString() + "*.zip!/repo/"); URI repoJarPatternUri = new URI("jar:" + getBwcIndicesPath().toUri().toString() + "*.zip!/repo/");
return settingsBuilder() return Settings.builder()
.put(super.nodeSettings(nodeOrdinal)) .put(super.nodeSettings(nodeOrdinal))
.putArray(URLRepository.ALLOWED_URLS_SETTING.getKey(), repoJarPatternUri.toString()) .putArray(URLRepository.ALLOWED_URLS_SETTING.getKey(), repoJarPatternUri.toString())
.build(); .build();
@ -159,7 +158,7 @@ public class RestoreBackwardsCompatIT extends AbstractSnapshotIntegTestCase {
URI repoJarUri = new URI("jar:" + repoFileUri.toString() + "!/repo/"); URI repoJarUri = new URI("jar:" + repoFileUri.toString() + "!/repo/");
logger.info("--> creating repository [{}] for version [{}]", repo, version); logger.info("--> creating repository [{}] for version [{}]", repo, version);
assertAcked(client().admin().cluster().preparePutRepository(repo) assertAcked(client().admin().cluster().preparePutRepository(repo)
.setType("url").setSettings(settingsBuilder() .setType("url").setSettings(Settings.builder()
.put("url", repoJarUri.toString()))); .put("url", repoJarUri.toString())));
} }

View File

@ -38,7 +38,7 @@ public class UnicastBackwardsCompatibilityIT extends ESBackcompatTestCase {
@Override @Override
protected Settings externalNodeSettings(int nodeOrdinal) { protected Settings externalNodeSettings(int nodeOrdinal) {
return Settings.settingsBuilder() return Settings.builder()
.put(super.externalNodeSettings(nodeOrdinal)) .put(super.externalNodeSettings(nodeOrdinal))
.put(TransportSettings.PORT.getKey(), 9390 + nodeOrdinal) .put(TransportSettings.PORT.getKey(), 9390 + nodeOrdinal)
.put("discovery.zen.ping.unicast.hosts", "localhost:9380,localhost:9381,localhost:9390,localhost:9391") .put("discovery.zen.ping.unicast.hosts", "localhost:9380,localhost:9381,localhost:9390,localhost:9391")

View File

@ -24,7 +24,6 @@ import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope; import org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
/** /**
@ -34,7 +33,7 @@ import static org.hamcrest.Matchers.is;
public class NodeClientIT extends ESIntegTestCase { public class NodeClientIT extends ESIntegTestCase {
@Override @Override
protected Settings nodeSettings(int nodeOrdinal) { protected Settings nodeSettings(int nodeOrdinal) {
return settingsBuilder().put(super.nodeSettings(nodeOrdinal)).put(Client.CLIENT_TYPE_SETTING_S.getKey(), "anything").build(); return Settings.builder().put(super.nodeSettings(nodeOrdinal)).put(Client.CLIENT_TYPE_SETTING_S.getKey(), "anything").build();
} }
public void testThatClientTypeSettingCannotBeChanged() { public void testThatClientTypeSettingCannotBeChanged() {

View File

@ -34,7 +34,6 @@ import org.elasticsearch.transport.TransportService;
import java.io.IOException; import java.io.IOException;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThanOrEqualTo; import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
@ -92,7 +91,7 @@ public class TransportClientIT extends ESIntegTestCase {
} }
public void testThatTransportClientSettingCannotBeChanged() { public void testThatTransportClientSettingCannotBeChanged() {
Settings baseSettings = settingsBuilder() Settings baseSettings = Settings.builder()
.put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()) .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
.build(); .build();
try (TransportClient client = TransportClient.builder().settings(baseSettings).build()) { try (TransportClient client = TransportClient.builder().settings(baseSettings).build()) {

View File

@ -38,7 +38,6 @@ import org.elasticsearch.transport.TransportService;
import java.io.IOException; import java.io.IOException;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.Matchers.greaterThanOrEqualTo; import static org.hamcrest.Matchers.greaterThanOrEqualTo;
@ -52,7 +51,7 @@ public class TransportClientRetryIT extends ESIntegTestCase {
addresses[i++] = instance.boundAddress().publishAddress(); addresses[i++] = instance.boundAddress().publishAddress();
} }
Settings.Builder builder = settingsBuilder().put("client.transport.nodes_sampler_interval", "1s") Settings.Builder builder = Settings.builder().put("client.transport.nodes_sampler_interval", "1s")
.put("node.name", "transport_client_retry_test") .put("node.name", "transport_client_retry_test")
.put(Node.NODE_MODE_SETTING.getKey(), internalCluster().getNodeMode()) .put(Node.NODE_MODE_SETTING.getKey(), internalCluster().getNodeMode())
.put(ClusterName.CLUSTER_NAME_SETTING.getKey(), internalCluster().getClusterName()) .put(ClusterName.CLUSTER_NAME_SETTING.getKey(), internalCluster().getClusterName())

View File

@ -62,7 +62,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
import static java.util.Collections.emptySet; import static java.util.Collections.emptySet;
import static java.util.Collections.unmodifiableSet; import static java.util.Collections.unmodifiableSet;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.common.util.set.Sets.newHashSet; import static org.elasticsearch.common.util.set.Sets.newHashSet;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.equalTo;
@ -139,7 +138,7 @@ public class ClusterInfoServiceIT extends ESIntegTestCase {
public void testClusterInfoServiceCollectsInformation() throws Exception { public void testClusterInfoServiceCollectsInformation() throws Exception {
internalCluster().startNodesAsync(2).get(); internalCluster().startNodesAsync(2).get();
assertAcked(prepareCreate("test").setSettings(settingsBuilder() assertAcked(prepareCreate("test").setSettings(Settings.builder()
.put(Store.INDEX_STORE_STATS_REFRESH_INTERVAL_SETTING.getKey(), 0) .put(Store.INDEX_STORE_STATS_REFRESH_INTERVAL_SETTING.getKey(), 0)
.put(EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), EnableAllocationDecider.Rebalance.NONE).build())); .put(EnableAllocationDecider.INDEX_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), EnableAllocationDecider.Rebalance.NONE).build()));
ensureGreen("test"); ensureGreen("test");

View File

@ -51,7 +51,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Predicate; import java.util.function.Predicate;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoTimeout; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoTimeout;
@ -75,7 +74,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
public void testSimpleMinimumMasterNodes() throws Exception { public void testSimpleMinimumMasterNodes() throws Exception {
Settings settings = settingsBuilder() Settings settings = Settings.builder()
.put("discovery.type", "zen") .put("discovery.type", "zen")
.put("discovery.zen.minimum_master_nodes", 2) .put("discovery.zen.minimum_master_nodes", 2)
.put(ZenDiscovery.PING_TIMEOUT_SETTING.getKey(), "200ms") .put(ZenDiscovery.PING_TIMEOUT_SETTING.getKey(), "200ms")
@ -187,7 +186,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
} }
public void testMultipleNodesShutdownNonMasterNodes() throws Exception { public void testMultipleNodesShutdownNonMasterNodes() throws Exception {
Settings settings = settingsBuilder() Settings settings = Settings.builder()
.put("discovery.type", "zen") .put("discovery.type", "zen")
.put("discovery.zen.minimum_master_nodes", 3) .put("discovery.zen.minimum_master_nodes", 3)
.put(ZenDiscovery.PING_TIMEOUT_SETTING.getKey(), "1s") .put(ZenDiscovery.PING_TIMEOUT_SETTING.getKey(), "1s")
@ -263,7 +262,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
} }
public void testDynamicUpdateMinimumMasterNodes() throws Exception { public void testDynamicUpdateMinimumMasterNodes() throws Exception {
Settings settings = settingsBuilder() Settings settings = Settings.builder()
.put("discovery.type", "zen") .put("discovery.type", "zen")
.put(ZenDiscovery.PING_TIMEOUT_SETTING.getKey(), "400ms") .put(ZenDiscovery.PING_TIMEOUT_SETTING.getKey(), "400ms")
.put("discovery.initial_state_timeout", "500ms") .put("discovery.initial_state_timeout", "500ms")
@ -291,7 +290,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
assertNoMasterBlockOnAllNodes(); assertNoMasterBlockOnAllNodes();
logger.info("--> bringing another node up"); logger.info("--> bringing another node up");
internalCluster().startNode(settingsBuilder().put(settings).put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), 2).build()); internalCluster().startNode(Settings.builder().put(settings).put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), 2).build());
clusterHealthResponse = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForNodes("2").get(); clusterHealthResponse = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForNodes("2").get();
assertThat(clusterHealthResponse.isTimedOut(), equalTo(false)); assertThat(clusterHealthResponse.isTimedOut(), equalTo(false));
} }
@ -321,7 +320,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
public void testCanNotBringClusterDown() throws ExecutionException, InterruptedException { public void testCanNotBringClusterDown() throws ExecutionException, InterruptedException {
int nodeCount = scaledRandomIntBetween(1, 5); int nodeCount = scaledRandomIntBetween(1, 5);
Settings.Builder settings = settingsBuilder() Settings.Builder settings = Settings.builder()
.put("discovery.type", "zen") .put("discovery.type", "zen")
.put(ZenDiscovery.PING_TIMEOUT_SETTING.getKey(), "200ms") .put(ZenDiscovery.PING_TIMEOUT_SETTING.getKey(), "200ms")
.put("discovery.initial_state_timeout", "500ms"); .put("discovery.initial_state_timeout", "500ms");
@ -341,7 +340,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
logger.info("--> updating [{}] to [{}]", ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), updateCount); logger.info("--> updating [{}] to [{}]", ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), updateCount);
assertAcked(client().admin().cluster().prepareUpdateSettings() assertAcked(client().admin().cluster().prepareUpdateSettings()
.setPersistentSettings(settingsBuilder().put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), updateCount))); .setPersistentSettings(Settings.builder().put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), updateCount)));
logger.info("--> verifying no node left and master is up"); logger.info("--> verifying no node left and master is up");
assertFalse(client().admin().cluster().prepareHealth().setWaitForNodes(Integer.toString(nodeCount)).get().isTimedOut()); assertFalse(client().admin().cluster().prepareHealth().setWaitForNodes(Integer.toString(nodeCount)).get().isTimedOut());
@ -350,7 +349,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
logger.info("--> trying to updating [{}] to [{}]", ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), updateCount); logger.info("--> trying to updating [{}] to [{}]", ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), updateCount);
try { try {
client().admin().cluster().prepareUpdateSettings() client().admin().cluster().prepareUpdateSettings()
.setPersistentSettings(settingsBuilder().put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), updateCount)); .setPersistentSettings(Settings.builder().put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), updateCount));
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
assertEquals(ex.getMessage(), "cannot set discovery.zen.minimum_master_nodes to more than the current master nodes count [" +updateCount+ "]"); assertEquals(ex.getMessage(), "cannot set discovery.zen.minimum_master_nodes to more than the current master nodes count [" +updateCount+ "]");
} }
@ -360,7 +359,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
} }
public void testCanNotPublishWithoutMinMastNodes() throws Exception { public void testCanNotPublishWithoutMinMastNodes() throws Exception {
Settings settings = settingsBuilder() Settings settings = Settings.builder()
.put("discovery.type", "zen") .put("discovery.type", "zen")
.put(FaultDetection.PING_TIMEOUT_SETTING.getKey(), "1h") // disable it .put(FaultDetection.PING_TIMEOUT_SETTING.getKey(), "1h") // disable it
.put(ZenDiscovery.PING_TIMEOUT_SETTING.getKey(), "200ms") .put(ZenDiscovery.PING_TIMEOUT_SETTING.getKey(), "200ms")

View File

@ -43,7 +43,6 @@ import org.elasticsearch.test.ESIntegTestCase.Scope;
import java.util.HashMap; import java.util.HashMap;
import static org.elasticsearch.action.percolate.PercolateSourceBuilder.docBuilder; import static org.elasticsearch.action.percolate.PercolateSourceBuilder.docBuilder;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertExists; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertExists;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows;
@ -61,7 +60,7 @@ public class NoMasterNodeIT extends ESIntegTestCase {
boolean autoCreateIndex = randomBoolean(); boolean autoCreateIndex = randomBoolean();
logger.info("auto_create_index set to {}", autoCreateIndex); logger.info("auto_create_index set to {}", autoCreateIndex);
Settings settings = settingsBuilder() Settings settings = Settings.builder()
.put("discovery.type", "zen") .put("discovery.type", "zen")
.put("action.auto_create_index", autoCreateIndex) .put("action.auto_create_index", autoCreateIndex)
.put("discovery.zen.minimum_master_nodes", 2) .put("discovery.zen.minimum_master_nodes", 2)
@ -213,7 +212,7 @@ public class NoMasterNodeIT extends ESIntegTestCase {
} }
public void testNoMasterActionsWriteMasterBlock() throws Exception { public void testNoMasterActionsWriteMasterBlock() throws Exception {
Settings settings = settingsBuilder() Settings settings = Settings.builder()
.put("discovery.type", "zen") .put("discovery.type", "zen")
.put("action.auto_create_index", false) .put("action.auto_create_index", false)
.put("discovery.zen.minimum_master_nodes", 2) .put("discovery.zen.minimum_master_nodes", 2)

View File

@ -23,13 +23,13 @@ import org.elasticsearch.action.UnavailableShardsException;
import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.client.Requests; import org.elasticsearch.client.Requests;
import org.elasticsearch.common.Priority; import org.elasticsearch.common.Priority;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.Node; import org.elasticsearch.node.Node;
import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope; import org.elasticsearch.test.ESIntegTestCase.Scope;
import static org.elasticsearch.client.Requests.createIndexRequest; import static org.elasticsearch.client.Requests.createIndexRequest;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds; import static org.elasticsearch.common.unit.TimeValue.timeValueSeconds;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
@ -39,7 +39,7 @@ import static org.hamcrest.Matchers.equalTo;
@ClusterScope(scope= Scope.TEST, numDataNodes =0) @ClusterScope(scope= Scope.TEST, numDataNodes =0)
public class SimpleDataNodesIT extends ESIntegTestCase { public class SimpleDataNodesIT extends ESIntegTestCase {
public void testDataNodes() throws Exception { public void testDataNodes() throws Exception {
internalCluster().startNode(settingsBuilder().put(Node.NODE_DATA_SETTING.getKey(), false).build()); internalCluster().startNode(Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), false).build());
client().admin().indices().create(createIndexRequest("test")).actionGet(); client().admin().indices().create(createIndexRequest("test")).actionGet();
try { try {
client().index(Requests.indexRequest("test").type("type1").id("1").source(source("1", "test")).timeout(timeValueSeconds(1))).actionGet(); client().index(Requests.indexRequest("test").type("type1").id("1").source(source("1", "test")).timeout(timeValueSeconds(1))).actionGet();
@ -48,7 +48,7 @@ public class SimpleDataNodesIT extends ESIntegTestCase {
// all is well // all is well
} }
internalCluster().startNode(settingsBuilder().put(Node.NODE_DATA_SETTING.getKey(), false).build()); internalCluster().startNode(Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), false).build());
assertThat(client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForNodes("2").setLocal(true).execute().actionGet().isTimedOut(), equalTo(false)); assertThat(client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForNodes("2").setLocal(true).execute().actionGet().isTimedOut(), equalTo(false));
// still no shard should be allocated // still no shard should be allocated
@ -60,7 +60,7 @@ public class SimpleDataNodesIT extends ESIntegTestCase {
} }
// now, start a node data, and see that it gets with shards // now, start a node data, and see that it gets with shards
internalCluster().startNode(settingsBuilder().put(Node.NODE_DATA_SETTING.getKey(), true).build()); internalCluster().startNode(Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), true).build());
assertThat(client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForNodes("3").setLocal(true).execute().actionGet().isTimedOut(), equalTo(false)); assertThat(client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForNodes("3").setLocal(true).execute().actionGet().isTimedOut(), equalTo(false));
IndexResponse indexResponse = client().index(Requests.indexRequest("test").type("type1").id("1").source(source("1", "test"))).actionGet(); IndexResponse indexResponse = client().index(Requests.indexRequest("test").type("type1").id("1").source(source("1", "test"))).actionGet();

View File

@ -21,14 +21,13 @@ package org.elasticsearch.cluster;
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.common.Priority; import org.elasticsearch.common.Priority;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.Node; import org.elasticsearch.node.Node;
import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope; import org.elasticsearch.test.ESIntegTestCase.Scope;
import java.util.List;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
/** /**
@ -36,14 +35,11 @@ import static org.hamcrest.Matchers.equalTo;
@ClusterScope(scope= Scope.TEST, numDataNodes =0) @ClusterScope(scope= Scope.TEST, numDataNodes =0)
public class UpdateSettingsValidationIT extends ESIntegTestCase { public class UpdateSettingsValidationIT extends ESIntegTestCase {
public void testUpdateSettingsValidation() throws Exception { public void testUpdateSettingsValidation() throws Exception {
List<String> nodes = internalCluster().startNodesAsync( internalCluster().startNodesAsync(
settingsBuilder().put(Node.NODE_DATA_SETTING.getKey(), false).build(), Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), false).build(),
settingsBuilder().put(Node.NODE_MASTER_SETTING.getKey(), false).build(), Settings.builder().put(Node.NODE_MASTER_SETTING.getKey(), false).build(),
settingsBuilder().put(Node.NODE_MASTER_SETTING.getKey(), false).build() Settings.builder().put(Node.NODE_MASTER_SETTING.getKey(), false).build()
).get(); ).get();
String master = nodes.get(0);
String node_1 = nodes.get(1);
String node_2 = nodes.get(2);
createIndex("test"); createIndex("test");
NumShards test = getNumShards("test"); NumShards test = getNumShards("test");
@ -52,13 +48,13 @@ public class UpdateSettingsValidationIT extends ESIntegTestCase {
assertThat(healthResponse.isTimedOut(), equalTo(false)); assertThat(healthResponse.isTimedOut(), equalTo(false));
assertThat(healthResponse.getIndices().get("test").getActiveShards(), equalTo(test.totalNumShards)); assertThat(healthResponse.getIndices().get("test").getActiveShards(), equalTo(test.totalNumShards));
client().admin().indices().prepareUpdateSettings("test").setSettings(settingsBuilder().put("index.number_of_replicas", 0)).execute().actionGet(); client().admin().indices().prepareUpdateSettings("test").setSettings(Settings.builder().put("index.number_of_replicas", 0)).execute().actionGet();
healthResponse = client().admin().cluster().prepareHealth("test").setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet(); healthResponse = client().admin().cluster().prepareHealth("test").setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().execute().actionGet();
assertThat(healthResponse.isTimedOut(), equalTo(false)); assertThat(healthResponse.isTimedOut(), equalTo(false));
assertThat(healthResponse.getIndices().get("test").getActiveShards(), equalTo(test.numPrimaries)); assertThat(healthResponse.getIndices().get("test").getActiveShards(), equalTo(test.numPrimaries));
try { try {
client().admin().indices().prepareUpdateSettings("test").setSettings(settingsBuilder().put("index.refresh_interval", "")).execute().actionGet(); client().admin().indices().prepareUpdateSettings("test").setSettings(Settings.builder().put("index.refresh_interval", "")).execute().actionGet();
fail(); fail();
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
logger.info("Error message: [{}]", ex.getMessage()); logger.info("Error message: [{}]", ex.getMessage());

View File

@ -36,7 +36,6 @@ import org.elasticsearch.discovery.DiscoverySettings;
import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.ESIntegTestCase.Scope.TEST; import static org.elasticsearch.test.ESIntegTestCase.Scope.TEST;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
@ -91,7 +90,7 @@ public class AckClusterUpdateSettingsIT extends ESIntegTestCase {
assertNotNull(excludedNodeId); assertNotNull(excludedNodeId);
ClusterUpdateSettingsResponse clusterUpdateSettingsResponse = client().admin().cluster().prepareUpdateSettings() ClusterUpdateSettingsResponse clusterUpdateSettingsResponse = client().admin().cluster().prepareUpdateSettings()
.setTransientSettings(settingsBuilder().put("cluster.routing.allocation.exclude._id", excludedNodeId)).get(); .setTransientSettings(Settings.builder().put("cluster.routing.allocation.exclude._id", excludedNodeId)).get();
assertAcked(clusterUpdateSettingsResponse); assertAcked(clusterUpdateSettingsResponse);
assertThat(clusterUpdateSettingsResponse.getTransientSettings().get("cluster.routing.allocation.exclude._id"), equalTo(excludedNodeId)); assertThat(clusterUpdateSettingsResponse.getTransientSettings().get("cluster.routing.allocation.exclude._id"), equalTo(excludedNodeId));
@ -115,7 +114,7 @@ public class AckClusterUpdateSettingsIT extends ESIntegTestCase {
public void testClusterUpdateSettingsNoAcknowledgement() { public void testClusterUpdateSettingsNoAcknowledgement() {
client().admin().indices().prepareCreate("test") client().admin().indices().prepareCreate("test")
.setSettings(settingsBuilder() .setSettings(Settings.builder()
.put("number_of_shards", between(cluster().numDataNodes(), DEFAULT_MAX_NUM_SHARDS)) .put("number_of_shards", between(cluster().numDataNodes(), DEFAULT_MAX_NUM_SHARDS))
.put("number_of_replicas", 0)).get(); .put("number_of_replicas", 0)).get();
ensureGreen(); ensureGreen();
@ -134,7 +133,7 @@ public class AckClusterUpdateSettingsIT extends ESIntegTestCase {
assertNotNull(excludedNodeId); assertNotNull(excludedNodeId);
ClusterUpdateSettingsResponse clusterUpdateSettingsResponse = client().admin().cluster().prepareUpdateSettings().setTimeout("0s") ClusterUpdateSettingsResponse clusterUpdateSettingsResponse = client().admin().cluster().prepareUpdateSettings().setTimeout("0s")
.setTransientSettings(settingsBuilder().put("cluster.routing.allocation.exclude._id", excludedNodeId)).get(); .setTransientSettings(Settings.builder().put("cluster.routing.allocation.exclude._id", excludedNodeId)).get();
assertThat(clusterUpdateSettingsResponse.isAcknowledged(), equalTo(false)); assertThat(clusterUpdateSettingsResponse.isAcknowledged(), equalTo(false));
assertThat(clusterUpdateSettingsResponse.getTransientSettings().get("cluster.routing.allocation.exclude._id"), equalTo(excludedNodeId)); assertThat(clusterUpdateSettingsResponse.getTransientSettings().get("cluster.routing.allocation.exclude._id"), equalTo(excludedNodeId));
} }

View File

@ -47,7 +47,6 @@ import java.util.concurrent.TimeUnit;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
@ -121,7 +120,7 @@ public class AckIT extends ESIntegTestCase {
public void testClusterRerouteNoAcknowledgement() throws InterruptedException { public void testClusterRerouteNoAcknowledgement() throws InterruptedException {
client().admin().indices().prepareCreate("test") client().admin().indices().prepareCreate("test")
.setSettings(settingsBuilder() .setSettings(Settings.builder()
.put(SETTING_NUMBER_OF_SHARDS, between(cluster().numDataNodes(), DEFAULT_MAX_NUM_SHARDS)) .put(SETTING_NUMBER_OF_SHARDS, between(cluster().numDataNodes(), DEFAULT_MAX_NUM_SHARDS))
.put(SETTING_NUMBER_OF_REPLICAS, 0)).get(); .put(SETTING_NUMBER_OF_REPLICAS, 0)).get();
ensureGreen(); ensureGreen();
@ -134,7 +133,7 @@ public class AckIT extends ESIntegTestCase {
public void testClusterRerouteAcknowledgementDryRun() throws InterruptedException { public void testClusterRerouteAcknowledgementDryRun() throws InterruptedException {
client().admin().indices().prepareCreate("test") client().admin().indices().prepareCreate("test")
.setSettings(settingsBuilder() .setSettings(Settings.builder()
.put(SETTING_NUMBER_OF_SHARDS, between(cluster().numDataNodes(), DEFAULT_MAX_NUM_SHARDS)) .put(SETTING_NUMBER_OF_SHARDS, between(cluster().numDataNodes(), DEFAULT_MAX_NUM_SHARDS))
.put(SETTING_NUMBER_OF_REPLICAS, 0)).get(); .put(SETTING_NUMBER_OF_REPLICAS, 0)).get();
ensureGreen(); ensureGreen();
@ -169,7 +168,7 @@ public class AckIT extends ESIntegTestCase {
public void testClusterRerouteNoAcknowledgementDryRun() throws InterruptedException { public void testClusterRerouteNoAcknowledgementDryRun() throws InterruptedException {
client().admin().indices().prepareCreate("test") client().admin().indices().prepareCreate("test")
.setSettings(settingsBuilder() .setSettings(Settings.builder()
.put(SETTING_NUMBER_OF_SHARDS, between(cluster().numDataNodes(), DEFAULT_MAX_NUM_SHARDS)) .put(SETTING_NUMBER_OF_SHARDS, between(cluster().numDataNodes(), DEFAULT_MAX_NUM_SHARDS))
.put(SETTING_NUMBER_OF_REPLICAS, 0)).get(); .put(SETTING_NUMBER_OF_REPLICAS, 0)).get();
ensureGreen(); ensureGreen();

View File

@ -55,7 +55,6 @@ import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.CoreMatchers.not;
@ -73,7 +72,7 @@ public class ShardFailedClusterStateTaskExecutorTests extends ESAllocationTestCa
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp(); super.setUp();
allocationService = createAllocationService(settingsBuilder() allocationService = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 8) .put("cluster.routing.allocation.node_concurrent_recoveries", 8)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.build()); .build());

View File

@ -38,7 +38,6 @@ import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
@ -55,13 +54,13 @@ public class AwarenessAllocationIT extends ESIntegTestCase {
} }
public void testSimpleAwareness() throws Exception { public void testSimpleAwareness() throws Exception {
Settings commonSettings = Settings.settingsBuilder() Settings commonSettings = Settings.builder()
.put("cluster.routing.allocation.awareness.attributes", "rack_id") .put("cluster.routing.allocation.awareness.attributes", "rack_id")
.build(); .build();
logger.info("--> starting 2 nodes on the same rack"); logger.info("--> starting 2 nodes on the same rack");
internalCluster().startNodesAsync(2, Settings.settingsBuilder().put(commonSettings).put("node.attr.rack_id", "rack_1").build()).get(); internalCluster().startNodesAsync(2, Settings.builder().put(commonSettings).put("node.attr.rack_id", "rack_1").build()).get();
createIndex("test1"); createIndex("test1");
createIndex("test2"); createIndex("test2");
@ -74,7 +73,7 @@ public class AwarenessAllocationIT extends ESIntegTestCase {
ensureGreen(); ensureGreen();
logger.info("--> starting 1 node on a different rack"); logger.info("--> starting 1 node on a different rack");
final String node3 = internalCluster().startNode(Settings.settingsBuilder().put(commonSettings).put("node.attr.rack_id", "rack_2").build()); final String node3 = internalCluster().startNode(Settings.builder().put(commonSettings).put("node.attr.rack_id", "rack_2").build());
// On slow machines the initial relocation might be delayed // On slow machines the initial relocation might be delayed
assertThat(awaitBusy( assertThat(awaitBusy(
@ -104,7 +103,7 @@ public class AwarenessAllocationIT extends ESIntegTestCase {
} }
public void testAwarenessZones() throws Exception { public void testAwarenessZones() throws Exception {
Settings commonSettings = Settings.settingsBuilder() Settings commonSettings = Settings.builder()
.put(AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_FORCE_GROUP_SETTING.getKey() + "zone.values", "a,b") .put(AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_FORCE_GROUP_SETTING.getKey() + "zone.values", "a,b")
.put(AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTE_SETTING.getKey(), "zone") .put(AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTE_SETTING.getKey(), "zone")
.put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), 3) .put(ElectMasterService.DISCOVERY_ZEN_MINIMUM_MASTER_NODES_SETTING.getKey(), 3)
@ -113,10 +112,10 @@ public class AwarenessAllocationIT extends ESIntegTestCase {
logger.info("--> starting 4 nodes on different zones"); logger.info("--> starting 4 nodes on different zones");
List<String> nodes = internalCluster().startNodesAsync( List<String> nodes = internalCluster().startNodesAsync(
Settings.settingsBuilder().put(commonSettings).put("node.attr.zone", "a").build(), Settings.builder().put(commonSettings).put("node.attr.zone", "a").build(),
Settings.settingsBuilder().put(commonSettings).put("node.attr.zone", "b").build(), Settings.builder().put(commonSettings).put("node.attr.zone", "b").build(),
Settings.settingsBuilder().put(commonSettings).put("node.attr.zone", "b").build(), Settings.builder().put(commonSettings).put("node.attr.zone", "b").build(),
Settings.settingsBuilder().put(commonSettings).put("node.attr.zone", "a").build() Settings.builder().put(commonSettings).put("node.attr.zone", "a").build()
).get(); ).get();
String A_0 = nodes.get(0); String A_0 = nodes.get(0);
String B_0 = nodes.get(1); String B_0 = nodes.get(1);
@ -128,7 +127,7 @@ public class AwarenessAllocationIT extends ESIntegTestCase {
assertThat(health.isTimedOut(), equalTo(false)); assertThat(health.isTimedOut(), equalTo(false));
client().admin().indices().prepareCreate("test") client().admin().indices().prepareCreate("test")
.setSettings(settingsBuilder().put("index.number_of_shards", 5) .setSettings(Settings.builder().put("index.number_of_shards", 5)
.put("index.number_of_replicas", 1)).execute().actionGet(); .put("index.number_of_replicas", 1)).execute().actionGet();
logger.info("--> waiting for shards to be allocated"); logger.info("--> waiting for shards to be allocated");
@ -152,20 +151,20 @@ public class AwarenessAllocationIT extends ESIntegTestCase {
} }
public void testAwarenessZonesIncrementalNodes() throws Exception { public void testAwarenessZonesIncrementalNodes() throws Exception {
Settings commonSettings = Settings.settingsBuilder() Settings commonSettings = Settings.builder()
.put("cluster.routing.allocation.awareness.force.zone.values", "a,b") .put("cluster.routing.allocation.awareness.force.zone.values", "a,b")
.put("cluster.routing.allocation.awareness.attributes", "zone") .put("cluster.routing.allocation.awareness.attributes", "zone")
.build(); .build();
logger.info("--> starting 2 nodes on zones 'a' & 'b'"); logger.info("--> starting 2 nodes on zones 'a' & 'b'");
List<String> nodes = internalCluster().startNodesAsync( List<String> nodes = internalCluster().startNodesAsync(
Settings.settingsBuilder().put(commonSettings).put("node.attr.zone", "a").build(), Settings.builder().put(commonSettings).put("node.attr.zone", "a").build(),
Settings.settingsBuilder().put(commonSettings).put("node.attr.zone", "b").build() Settings.builder().put(commonSettings).put("node.attr.zone", "b").build()
).get(); ).get();
String A_0 = nodes.get(0); String A_0 = nodes.get(0);
String B_0 = nodes.get(1); String B_0 = nodes.get(1);
client().admin().indices().prepareCreate("test") client().admin().indices().prepareCreate("test")
.setSettings(settingsBuilder().put("index.number_of_shards", 5) .setSettings(Settings.builder().put("index.number_of_shards", 5)
.put("index.number_of_replicas", 1)).execute().actionGet(); .put("index.number_of_replicas", 1)).execute().actionGet();
ClusterHealthResponse health = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().setWaitForNodes("2").setWaitForRelocatingShards(0).execute().actionGet(); ClusterHealthResponse health = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().setWaitForNodes("2").setWaitForRelocatingShards(0).execute().actionGet();
assertThat(health.isTimedOut(), equalTo(false)); assertThat(health.isTimedOut(), equalTo(false));
@ -183,7 +182,7 @@ public class AwarenessAllocationIT extends ESIntegTestCase {
assertThat(counts.get(B_0), equalTo(5)); assertThat(counts.get(B_0), equalTo(5));
logger.info("--> starting another node in zone 'b'"); logger.info("--> starting another node in zone 'b'");
String B_1 = internalCluster().startNode(Settings.settingsBuilder().put(commonSettings).put("node.attr.zone", "b").build()); String B_1 = internalCluster().startNode(Settings.builder().put(commonSettings).put("node.attr.zone", "b").build());
health = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().setWaitForNodes("3").execute().actionGet(); health = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().setWaitForNodes("3").execute().actionGet();
assertThat(health.isTimedOut(), equalTo(false)); assertThat(health.isTimedOut(), equalTo(false));
client().admin().cluster().prepareReroute().get(); client().admin().cluster().prepareReroute().get();
@ -228,7 +227,7 @@ public class AwarenessAllocationIT extends ESIntegTestCase {
assertThat(counts.get(B_0), equalTo(3)); assertThat(counts.get(B_0), equalTo(3));
assertThat(counts.get(B_1), equalTo(2)); assertThat(counts.get(B_1), equalTo(2));
assertThat(counts.containsKey(noZoneNode), equalTo(false)); assertThat(counts.containsKey(noZoneNode), equalTo(false));
client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.settingsBuilder().put("cluster.routing.allocation.awareness.attributes", "").build()).get(); client().admin().cluster().prepareUpdateSettings().setTransientSettings(Settings.builder().put("cluster.routing.allocation.awareness.attributes", "").build()).get();
health = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().setWaitForNodes("4").setWaitForActiveShards(10).setWaitForRelocatingShards(0).execute().actionGet(); health = client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForGreenStatus().setWaitForNodes("4").setWaitForActiveShards(10).setWaitForRelocatingShards(0).execute().actionGet();

View File

@ -58,7 +58,6 @@ import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_RE
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_BLOCKS_WRITE;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_READ_ONLY;
import static org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING; import static org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertBlocked;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
@ -71,7 +70,7 @@ public class ClusterRerouteIT extends ESIntegTestCase {
private final ESLogger logger = Loggers.getLogger(ClusterRerouteIT.class); private final ESLogger logger = Loggers.getLogger(ClusterRerouteIT.class);
public void testRerouteWithCommands_disableAllocationSettings() throws Exception { public void testRerouteWithCommands_disableAllocationSettings() throws Exception {
Settings commonSettings = settingsBuilder() Settings commonSettings = Settings.builder()
.put(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey(), "none") .put(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey(), "none")
.put(EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), "none") .put(EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), "none")
.build(); .build();
@ -79,7 +78,7 @@ public class ClusterRerouteIT extends ESIntegTestCase {
} }
public void testRerouteWithCommands_enableAllocationSettings() throws Exception { public void testRerouteWithCommands_enableAllocationSettings() throws Exception {
Settings commonSettings = settingsBuilder() Settings commonSettings = Settings.builder()
.put(CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey(), Allocation.NONE.name()) .put(CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey(), Allocation.NONE.name())
.build(); .build();
rerouteWithCommands(commonSettings); rerouteWithCommands(commonSettings);
@ -92,7 +91,7 @@ public class ClusterRerouteIT extends ESIntegTestCase {
logger.info("--> create an index with 1 shard, 1 replica, nothing should allocate"); logger.info("--> create an index with 1 shard, 1 replica, nothing should allocate");
client().admin().indices().prepareCreate("test") client().admin().indices().prepareCreate("test")
.setSettings(settingsBuilder().put("index.number_of_shards", 1)) .setSettings(Settings.builder().put("index.number_of_shards", 1))
.execute().actionGet(); .execute().actionGet();
ClusterState state = client().admin().cluster().prepareState().execute().actionGet().getState(); ClusterState state = client().admin().cluster().prepareState().execute().actionGet().getState();
@ -147,7 +146,7 @@ public class ClusterRerouteIT extends ESIntegTestCase {
} }
public void testRerouteWithAllocateLocalGateway_disableAllocationSettings() throws Exception { public void testRerouteWithAllocateLocalGateway_disableAllocationSettings() throws Exception {
Settings commonSettings = settingsBuilder() Settings commonSettings = Settings.builder()
.put(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey(), "none") .put(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey(), "none")
.put(EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), "none") .put(EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), "none")
.build(); .build();
@ -155,14 +154,14 @@ public class ClusterRerouteIT extends ESIntegTestCase {
} }
public void testRerouteWithAllocateLocalGateway_enableAllocationSettings() throws Exception { public void testRerouteWithAllocateLocalGateway_enableAllocationSettings() throws Exception {
Settings commonSettings = settingsBuilder() Settings commonSettings = Settings.builder()
.put(CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey(), Allocation.NONE.name()) .put(CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey(), Allocation.NONE.name())
.build(); .build();
rerouteWithAllocateLocalGateway(commonSettings); rerouteWithAllocateLocalGateway(commonSettings);
} }
public void testDelayWithALargeAmountOfShards() throws Exception { public void testDelayWithALargeAmountOfShards() throws Exception {
Settings commonSettings = settingsBuilder() Settings commonSettings = Settings.builder()
.put(ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_INCOMING_RECOVERIES_SETTING.getKey(), 1) .put(ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_INCOMING_RECOVERIES_SETTING.getKey(), 1)
.put(ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_OUTGOING_RECOVERIES_SETTING.getKey(), 1) .put(ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_OUTGOING_RECOVERIES_SETTING.getKey(), 1)
.build(); .build();
@ -179,7 +178,7 @@ public class ClusterRerouteIT extends ESIntegTestCase {
logger.info("--> create indices"); logger.info("--> create indices");
for (int i = 0; i < 25; i++) { for (int i = 0; i < 25; i++) {
client().admin().indices().prepareCreate("test" + i) client().admin().indices().prepareCreate("test" + i)
.setSettings(settingsBuilder() .setSettings(Settings.builder()
.put("index.number_of_shards", 5).put("index.number_of_replicas", 1) .put("index.number_of_shards", 5).put("index.number_of_replicas", 1)
.put("index.unassigned.node_left.delayed_timeout", randomIntBetween(250, 1000) + "ms")) .put("index.unassigned.node_left.delayed_timeout", randomIntBetween(250, 1000) + "ms"))
.execute().actionGet(); .execute().actionGet();
@ -204,7 +203,7 @@ public class ClusterRerouteIT extends ESIntegTestCase {
logger.info("--> create an index with 1 shard, 1 replica, nothing should allocate"); logger.info("--> create an index with 1 shard, 1 replica, nothing should allocate");
client().admin().indices().prepareCreate("test") client().admin().indices().prepareCreate("test")
.setSettings(settingsBuilder().put("index.number_of_shards", 1)) .setSettings(Settings.builder().put("index.number_of_shards", 1))
.execute().actionGet(); .execute().actionGet();
ClusterState state = client().admin().cluster().prepareState().execute().actionGet().getState(); ClusterState state = client().admin().cluster().prepareState().execute().actionGet().getState();
@ -264,7 +263,7 @@ public class ClusterRerouteIT extends ESIntegTestCase {
} }
public void testRerouteExplain() { public void testRerouteExplain() {
Settings commonSettings = settingsBuilder().build(); Settings commonSettings = Settings.builder().build();
logger.info("--> starting a node"); logger.info("--> starting a node");
String node_1 = internalCluster().startNode(commonSettings); String node_1 = internalCluster().startNode(commonSettings);
@ -275,13 +274,13 @@ public class ClusterRerouteIT extends ESIntegTestCase {
logger.info("--> create an index with 1 shard"); logger.info("--> create an index with 1 shard");
client().admin().indices().prepareCreate("test") client().admin().indices().prepareCreate("test")
.setSettings(settingsBuilder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0)) .setSettings(Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0))
.execute().actionGet(); .execute().actionGet();
ensureGreen("test"); ensureGreen("test");
logger.info("--> disable allocation"); logger.info("--> disable allocation");
Settings newSettings = settingsBuilder() Settings newSettings = Settings.builder()
.put(CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey(), Allocation.NONE.name()) .put(CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey(), Allocation.NONE.name())
.build(); .build();
client().admin().cluster().prepareUpdateSettings().setTransientSettings(newSettings).execute().actionGet(); client().admin().cluster().prepareUpdateSettings().setTransientSettings(newSettings).execute().actionGet();
@ -309,7 +308,7 @@ public class ClusterRerouteIT extends ESIntegTestCase {
List<String> nodesIds = internalCluster().startNodesAsync(2).get(); List<String> nodesIds = internalCluster().startNodesAsync(2).get();
logger.info("--> create an index with 1 shard and 0 replicas"); logger.info("--> create an index with 1 shard and 0 replicas");
assertAcked(prepareCreate("test-blocks").setSettings(settingsBuilder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0))); assertAcked(prepareCreate("test-blocks").setSettings(Settings.builder().put("index.number_of_shards", 1).put("index.number_of_replicas", 0)));
ensureGreen("test-blocks"); ensureGreen("test-blocks");
logger.info("--> check that the index has 1 shard"); logger.info("--> check that the index has 1 shard");

View File

@ -26,6 +26,7 @@ import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.allocation.decider.ThrottlingAllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.ThrottlingAllocationDecider;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope; import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
@ -33,7 +34,6 @@ import org.elasticsearch.test.ESIntegTestCase.Scope;
import java.util.List; import java.util.List;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
@ClusterScope(scope= Scope.TEST, numDataNodes =0) @ClusterScope(scope= Scope.TEST, numDataNodes =0)
@ -50,7 +50,7 @@ public class FilteringAllocationIT extends ESIntegTestCase {
logger.info("--> creating an index with no replicas"); logger.info("--> creating an index with no replicas");
client().admin().indices().prepareCreate("test") client().admin().indices().prepareCreate("test")
.setSettings(settingsBuilder().put("index.number_of_replicas", 0)) .setSettings(Settings.builder().put("index.number_of_replicas", 0))
.execute().actionGet(); .execute().actionGet();
ensureGreen(); ensureGreen();
logger.info("--> index some data"); logger.info("--> index some data");
@ -62,7 +62,7 @@ public class FilteringAllocationIT extends ESIntegTestCase {
logger.info("--> decommission the second node"); logger.info("--> decommission the second node");
client().admin().cluster().prepareUpdateSettings() client().admin().cluster().prepareUpdateSettings()
.setTransientSettings(settingsBuilder().put("cluster.routing.allocation.exclude._name", node_1)) .setTransientSettings(Settings.builder().put("cluster.routing.allocation.exclude._name", node_1))
.execute().actionGet(); .execute().actionGet();
waitForRelocation(); waitForRelocation();
@ -89,7 +89,7 @@ public class FilteringAllocationIT extends ESIntegTestCase {
logger.info("--> creating an index with no replicas"); logger.info("--> creating an index with no replicas");
client().admin().indices().prepareCreate("test") client().admin().indices().prepareCreate("test")
.setSettings(settingsBuilder().put("index.number_of_replicas", 0)) .setSettings(Settings.builder().put("index.number_of_replicas", 0))
.execute().actionGet(); .execute().actionGet();
ensureGreen(); ensureGreen();
@ -113,13 +113,13 @@ public class FilteringAllocationIT extends ESIntegTestCase {
if (numShardsOnNode1 > ThrottlingAllocationDecider.DEFAULT_CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_RECOVERIES) { if (numShardsOnNode1 > ThrottlingAllocationDecider.DEFAULT_CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_RECOVERIES) {
client().admin().cluster().prepareUpdateSettings() client().admin().cluster().prepareUpdateSettings()
.setTransientSettings(settingsBuilder().put("cluster.routing.allocation.node_concurrent_recoveries", numShardsOnNode1)).execute().actionGet(); .setTransientSettings(Settings.builder().put("cluster.routing.allocation.node_concurrent_recoveries", numShardsOnNode1)).execute().actionGet();
// make sure we can recover all the nodes at once otherwise we might run into a state where one of the shards has not yet started relocating // make sure we can recover all the nodes at once otherwise we might run into a state where one of the shards has not yet started relocating
// but we already fired up the request to wait for 0 relocating shards. // but we already fired up the request to wait for 0 relocating shards.
} }
logger.info("--> remove index from the first node"); logger.info("--> remove index from the first node");
client().admin().indices().prepareUpdateSettings("test") client().admin().indices().prepareUpdateSettings("test")
.setSettings(settingsBuilder().put("index.routing.allocation.exclude._name", node_0)) .setSettings(Settings.builder().put("index.routing.allocation.exclude._name", node_0))
.execute().actionGet(); .execute().actionGet();
client().admin().cluster().prepareReroute().get(); client().admin().cluster().prepareReroute().get();
ensureGreen(); ensureGreen();
@ -135,7 +135,7 @@ public class FilteringAllocationIT extends ESIntegTestCase {
logger.info("--> disable allocation filtering "); logger.info("--> disable allocation filtering ");
client().admin().indices().prepareUpdateSettings("test") client().admin().indices().prepareUpdateSettings("test")
.setSettings(settingsBuilder().put("index.routing.allocation.exclude._name", "")) .setSettings(Settings.builder().put("index.routing.allocation.exclude._name", ""))
.execute().actionGet(); .execute().actionGet();
client().admin().cluster().prepareReroute().get(); client().admin().cluster().prepareReroute().get();
ensureGreen(); ensureGreen();

View File

@ -20,10 +20,10 @@ package org.elasticsearch.cluster.allocation;
import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.routing.RoutingNode; import org.elasticsearch.cluster.routing.RoutingNode;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.ESIntegTestCase;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS; import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
@ -54,7 +54,7 @@ public class SimpleAllocationIT extends ESIntegTestCase {
assertThat(node.size(), equalTo(2)); assertThat(node.size(), equalTo(2));
} }
} }
client().admin().indices().prepareUpdateSettings("test").setSettings(settingsBuilder().put(SETTING_NUMBER_OF_REPLICAS, 0)).execute().actionGet(); client().admin().indices().prepareUpdateSettings("test").setSettings(Settings.builder().put(SETTING_NUMBER_OF_REPLICAS, 0)).execute().actionGet();
ensureGreen(); ensureGreen();
state = client().admin().cluster().prepareState().execute().actionGet().getState(); state = client().admin().cluster().prepareState().execute().actionGet().getState();
@ -69,7 +69,7 @@ public class SimpleAllocationIT extends ESIntegTestCase {
assertAcked(prepareCreate("test2", 3)); assertAcked(prepareCreate("test2", 3));
ensureGreen(); ensureGreen();
client().admin().indices().prepareUpdateSettings("test").setSettings(settingsBuilder().put(SETTING_NUMBER_OF_REPLICAS, 1)).execute().actionGet(); client().admin().indices().prepareUpdateSettings("test").setSettings(Settings.builder().put(SETTING_NUMBER_OF_REPLICAS, 1)).execute().actionGet();
ensureGreen(); ensureGreen();
state = client().admin().cluster().prepareState().execute().actionGet().getState(); state = client().admin().cluster().prepareState().execute().actionGet().getState();

View File

@ -78,7 +78,7 @@ public class MetaDataIndexUpgradeServiceTests extends ESTestCase {
} }
public static IndexMetaData newIndexMeta(String name, Settings indexSettings) { public static IndexMetaData newIndexMeta(String name, Settings indexSettings) {
Settings build = Settings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT) Settings build = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1) .put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1)
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1) .put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
.put(IndexMetaData.SETTING_CREATION_DATE, 1) .put(IndexMetaData.SETTING_CREATION_DATE, 1)

View File

@ -20,6 +20,7 @@
package org.elasticsearch.cluster.metadata; package org.elasticsearch.cluster.metadata;
import org.elasticsearch.Version; import org.elasticsearch.Version;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.test.ESTestCase; import org.elasticsearch.test.ESTestCase;
@ -27,7 +28,6 @@ import org.elasticsearch.test.ESTestCase;
import java.io.IOException; import java.io.IOException;
import static org.elasticsearch.cluster.metadata.AliasMetaData.newAliasMetaDataBuilder; import static org.elasticsearch.cluster.metadata.AliasMetaData.newAliasMetaDataBuilder;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.nullValue;
@ -118,7 +118,7 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase {
.put(IndexTemplateMetaData.builder("foo") .put(IndexTemplateMetaData.builder("foo")
.template("bar") .template("bar")
.order(1) .order(1)
.settings(settingsBuilder() .settings(Settings.builder()
.put("setting1", "value1") .put("setting1", "value1")
.put("setting2", "value2")) .put("setting2", "value2"))
.putAlias(newAliasMetaDataBuilder("alias-bar1")) .putAlias(newAliasMetaDataBuilder("alias-bar1"))
@ -139,7 +139,7 @@ public class ToAndFromJsonMetaDataTests extends ESTestCase {
.put(IndexTemplateMetaData.builder("foo") .put(IndexTemplateMetaData.builder("foo")
.template("bar") .template("bar")
.order(1) .order(1)
.settings(settingsBuilder() .settings(Settings.builder()
.put("setting1", "value1") .put("setting1", "value1")
.put("setting2", "value2")) .put("setting2", "value2"))
.putAlias(newAliasMetaDataBuilder("alias-bar1")) .putAlias(newAliasMetaDataBuilder("alias-bar1"))

View File

@ -59,7 +59,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
} }
public void testNameMatch() { public void testNameMatch() {
Settings settings = Settings.settingsBuilder() Settings settings = Settings.builder()
.put("xxx.name", "name1") .put("xxx.name", "name1")
.build(); .build();
DiscoveryNodeFilters filters = DiscoveryNodeFilters.buildFromSettings(OR, "xxx.", settings); DiscoveryNodeFilters filters = DiscoveryNodeFilters.buildFromSettings(OR, "xxx.", settings);
@ -72,7 +72,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
} }
public void testIdMatch() { public void testIdMatch() {
Settings settings = Settings.settingsBuilder() Settings settings = Settings.builder()
.put("xxx._id", "id1") .put("xxx._id", "id1")
.build(); .build();
DiscoveryNodeFilters filters = DiscoveryNodeFilters.buildFromSettings(OR, "xxx.", settings); DiscoveryNodeFilters filters = DiscoveryNodeFilters.buildFromSettings(OR, "xxx.", settings);
@ -85,7 +85,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
} }
public void testIdOrNameMatch() { public void testIdOrNameMatch() {
Settings settings = shuffleSettings(Settings.settingsBuilder() Settings settings = shuffleSettings(Settings.builder()
.put("xxx._id", "id1,blah") .put("xxx._id", "id1,blah")
.put("xxx.name", "blah,name2") .put("xxx.name", "blah,name2")
.build()); .build());
@ -102,7 +102,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
} }
public void testTagAndGroupMatch() { public void testTagAndGroupMatch() {
Settings settings = shuffleSettings(Settings.settingsBuilder() Settings settings = shuffleSettings(Settings.builder()
.put("xxx.tag", "A") .put("xxx.tag", "A")
.put("xxx.group", "B") .put("xxx.group", "B")
.build()); .build());
@ -136,7 +136,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
} }
public void testStarMatch() { public void testStarMatch() {
Settings settings = Settings.settingsBuilder() Settings settings = Settings.builder()
.put("xxx.name", "*") .put("xxx.name", "*")
.build(); .build();
DiscoveryNodeFilters filters = DiscoveryNodeFilters.buildFromSettings(OR, "xxx.", settings); DiscoveryNodeFilters filters = DiscoveryNodeFilters.buildFromSettings(OR, "xxx.", settings);
@ -146,7 +146,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
} }
public void testIpBindFilteringMatchingAnd() { public void testIpBindFilteringMatchingAnd() {
Settings settings = shuffleSettings(Settings.settingsBuilder() Settings settings = shuffleSettings(Settings.builder()
.put("xxx.tag", "A") .put("xxx.tag", "A")
.put("xxx." + randomFrom("_ip", "_host_ip", "_publish_ip"), "192.1.1.54") .put("xxx." + randomFrom("_ip", "_host_ip", "_publish_ip"), "192.1.1.54")
.build()); .build());
@ -157,7 +157,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
} }
public void testIpBindFilteringNotMatching() { public void testIpBindFilteringNotMatching() {
Settings settings = shuffleSettings(Settings.settingsBuilder() Settings settings = shuffleSettings(Settings.builder()
.put("xxx.tag", "B") .put("xxx.tag", "B")
.put("xxx." + randomFrom("_ip", "_host_ip", "_publish_ip"), "192.1.1.54") .put("xxx." + randomFrom("_ip", "_host_ip", "_publish_ip"), "192.1.1.54")
.build()); .build());
@ -168,7 +168,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
} }
public void testIpBindFilteringNotMatchingAnd() { public void testIpBindFilteringNotMatchingAnd() {
Settings settings = shuffleSettings(Settings.settingsBuilder() Settings settings = shuffleSettings(Settings.builder()
.put("xxx.tag", "A") .put("xxx.tag", "A")
.put("xxx." + randomFrom("_ip", "_host_ip", "_publish_ip"), "8.8.8.8") .put("xxx." + randomFrom("_ip", "_host_ip", "_publish_ip"), "8.8.8.8")
.build()); .build());
@ -179,7 +179,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
} }
public void testIpBindFilteringMatchingOr() { public void testIpBindFilteringMatchingOr() {
Settings settings = shuffleSettings(Settings.settingsBuilder() Settings settings = shuffleSettings(Settings.builder()
.put("xxx." + randomFrom("_ip", "_host_ip", "_publish_ip"), "192.1.1.54") .put("xxx." + randomFrom("_ip", "_host_ip", "_publish_ip"), "192.1.1.54")
.put("xxx.tag", "A") .put("xxx.tag", "A")
.build()); .build());
@ -190,7 +190,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
} }
public void testIpBindFilteringNotMatchingOr() { public void testIpBindFilteringNotMatchingOr() {
Settings settings = shuffleSettings(Settings.settingsBuilder() Settings settings = shuffleSettings(Settings.builder()
.put("xxx.tag", "A") .put("xxx.tag", "A")
.put("xxx." + randomFrom("_ip", "_host_ip", "_publish_ip"), "8.8.8.8") .put("xxx." + randomFrom("_ip", "_host_ip", "_publish_ip"), "8.8.8.8")
.build()); .build());
@ -201,7 +201,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
} }
public void testIpPublishFilteringMatchingAnd() { public void testIpPublishFilteringMatchingAnd() {
Settings settings = shuffleSettings(Settings.settingsBuilder() Settings settings = shuffleSettings(Settings.builder()
.put("xxx.tag", "A") .put("xxx.tag", "A")
.put("xxx._publish_ip", "192.1.1.54") .put("xxx._publish_ip", "192.1.1.54")
.build()); .build());
@ -212,7 +212,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
} }
public void testIpPublishFilteringNotMatchingAnd() { public void testIpPublishFilteringNotMatchingAnd() {
Settings settings = shuffleSettings(Settings.settingsBuilder() Settings settings = shuffleSettings(Settings.builder()
.put("xxx.tag", "A") .put("xxx.tag", "A")
.put("xxx._publish_ip", "8.8.8.8") .put("xxx._publish_ip", "8.8.8.8")
.build()); .build());
@ -223,7 +223,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
} }
public void testIpPublishFilteringMatchingOr() { public void testIpPublishFilteringMatchingOr() {
Settings settings = shuffleSettings(Settings.settingsBuilder() Settings settings = shuffleSettings(Settings.builder()
.put("xxx._publish_ip", "192.1.1.54") .put("xxx._publish_ip", "192.1.1.54")
.put("xxx.tag", "A") .put("xxx.tag", "A")
.build()); .build());
@ -234,7 +234,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
} }
public void testIpPublishFilteringNotMatchingOr() { public void testIpPublishFilteringNotMatchingOr() {
Settings settings = shuffleSettings(Settings.settingsBuilder() Settings settings = shuffleSettings(Settings.builder()
.put("xxx.tag", "A") .put("xxx.tag", "A")
.put("xxx._publish_ip", "8.8.8.8") .put("xxx._publish_ip", "8.8.8.8")
.build()); .build());
@ -245,7 +245,7 @@ public class DiscoveryNodeFiltersTests extends ESTestCase {
} }
private Settings shuffleSettings(Settings source) { private Settings shuffleSettings(Settings source) {
Settings.Builder settings = Settings.settingsBuilder(); Settings.Builder settings = Settings.builder();
List<String> keys = new ArrayList<>(source.getAsMap().keySet()); List<String> keys = new ArrayList<>(source.getAsMap().keySet());
Collections.shuffle(keys, random()); Collections.shuffle(keys, random());
for (String o : keys) { for (String o : keys) {

View File

@ -40,7 +40,6 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
@ -60,7 +59,7 @@ public class PrimaryTermsTests extends ESAllocationTestCase {
@Override @Override
public void setUp() throws Exception { public void setUp() throws Exception {
super.setUp(); super.setUp();
this.allocationService = createAllocationService(settingsBuilder() this.allocationService = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", Integer.MAX_VALUE) // don't limit recoveries .put("cluster.routing.allocation.node_concurrent_recoveries", Integer.MAX_VALUE) // don't limit recoveries
.put("cluster.routing.allocation.node_initial_primaries_recoveries", Integer.MAX_VALUE) .put("cluster.routing.allocation.node_initial_primaries_recoveries", Integer.MAX_VALUE)
.build()); .build());

View File

@ -33,7 +33,6 @@ import org.elasticsearch.test.ESAllocationTestCase;
import org.junit.Before; import org.junit.Before;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.nullValue;
@ -49,7 +48,7 @@ public class RoutingTableTests extends ESAllocationTestCase {
private int shardsPerIndex; private int shardsPerIndex;
private int totalNumberOfShards; private int totalNumberOfShards;
private final static Settings DEFAULT_SETTINGS = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build(); private final static Settings DEFAULT_SETTINGS = Settings.builder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build();
private final AllocationService ALLOCATION_SERVICE = createAllocationService(settingsBuilder() private final AllocationService ALLOCATION_SERVICE = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", Integer.MAX_VALUE) // don't limit recoveries .put("cluster.routing.allocation.node_concurrent_recoveries", Integer.MAX_VALUE) // don't limit recoveries
.put("cluster.routing.allocation.node_initial_primaries_recoveries", Integer.MAX_VALUE) .put("cluster.routing.allocation.node_initial_primaries_recoveries", Integer.MAX_VALUE)
.build()); .build());

View File

@ -43,13 +43,12 @@ import java.util.Collections;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
public class AddIncrementallyTests extends ESAllocationTestCase { public class AddIncrementallyTests extends ESAllocationTestCase {
private final ESLogger logger = Loggers.getLogger(AddIncrementallyTests.class); private final ESLogger logger = Loggers.getLogger(AddIncrementallyTests.class);
public void testAddNodesAndIndices() { public void testAddNodesAndIndices() {
Settings.Builder settings = settingsBuilder(); Settings.Builder settings = Settings.builder();
settings.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()); settings.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString());
AllocationService service = createAllocationService(settings.build()); AllocationService service = createAllocationService(settings.build());
@ -92,7 +91,7 @@ public class AddIncrementallyTests extends ESAllocationTestCase {
} }
public void testMinimalRelocations() { public void testMinimalRelocations() {
Settings.Builder settings = settingsBuilder(); Settings.Builder settings = Settings.builder();
settings.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()) settings.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString())
.put("cluster.routing.allocation.node_concurrent_recoveries", 2); .put("cluster.routing.allocation.node_concurrent_recoveries", 2);
AllocationService service = createAllocationService(settings.build()); AllocationService service = createAllocationService(settings.build());
@ -160,7 +159,7 @@ public class AddIncrementallyTests extends ESAllocationTestCase {
} }
public void testMinimalRelocationsNoLimit() { public void testMinimalRelocationsNoLimit() {
Settings.Builder settings = settingsBuilder(); Settings.Builder settings = Settings.builder();
settings.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()) settings.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString())
.put("cluster.routing.allocation.node_concurrent_recoveries", 100) .put("cluster.routing.allocation.node_concurrent_recoveries", 100)
.put("cluster.routing.allocation.node_initial_primaries_recoveries", 100); .put("cluster.routing.allocation.node_initial_primaries_recoveries", 100);

View File

@ -39,6 +39,7 @@ import org.elasticsearch.common.io.stream.BytesStreamOutput;
import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentFactory; import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType; import org.elasticsearch.common.xcontent.XContentType;
@ -51,7 +52,6 @@ import static java.util.Collections.singleton;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING; import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
@ -61,7 +61,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
private final ESLogger logger = Loggers.getLogger(AllocationCommandsTests.class); private final ESLogger logger = Loggers.getLogger(AllocationCommandsTests.class);
public void testMoveShardCommand() { public void testMoveShardCommand() {
AllocationService allocation = createAllocationService(settingsBuilder().put("cluster.routing.allocation.node_concurrent_recoveries", 10).build()); AllocationService allocation = createAllocationService(Settings.builder().put("cluster.routing.allocation.node_concurrent_recoveries", 10).build());
logger.info("creating an index with 1 shard, no replica"); logger.info("creating an index with 1 shard, no replica");
MetaData metaData = MetaData.builder() MetaData metaData = MetaData.builder()
@ -112,7 +112,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
} }
public void testAllocateCommand() { public void testAllocateCommand() {
AllocationService allocation = createAllocationService(settingsBuilder() AllocationService allocation = createAllocationService(Settings.builder()
.put(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey(), "none") .put(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey(), "none")
.put(EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), "none") .put(EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), "none")
.build()); .build());
@ -238,7 +238,7 @@ public class AllocationCommandsTests extends ESAllocationTestCase {
} }
public void testCancelCommand() { public void testCancelCommand() {
AllocationService allocation = createAllocationService(settingsBuilder() AllocationService allocation = createAllocationService(Settings.builder()
.put(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey(), "none") .put(EnableAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ENABLE_SETTING.getKey(), "none")
.put(EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), "none") .put(EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), "none")
.build()); .build());

View File

@ -25,10 +25,10 @@ import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.cluster.routing.allocation.decider.ThrottlingAllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.ThrottlingAllocationDecider;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESAllocationTestCase; import org.elasticsearch.test.ESAllocationTestCase;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
public class AllocationPriorityTests extends ESAllocationTestCase { public class AllocationPriorityTests extends ESAllocationTestCase {
@ -37,7 +37,7 @@ public class AllocationPriorityTests extends ESAllocationTestCase {
* See https://github.com/elastic/elasticsearch/issues/13249 for details * See https://github.com/elastic/elasticsearch/issues/13249 for details
*/ */
public void testPrioritizedIndicesAllocatedFirst() { public void testPrioritizedIndicesAllocatedFirst() {
AllocationService allocation = createAllocationService(settingsBuilder(). AllocationService allocation = createAllocationService(Settings.builder().
put(ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_RECOVERIES_SETTING.getKey(), 1) put(ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_RECOVERIES_SETTING.getKey(), 1)
.put(ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_OUTGOING_RECOVERIES_SETTING.getKey(), 10) .put(ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_OUTGOING_RECOVERIES_SETTING.getKey(), 10)
.put(ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_NODE_INITIAL_PRIMARIES_RECOVERIES_SETTING.getKey(), 1) .put(ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_NODE_INITIAL_PRIMARIES_RECOVERIES_SETTING.getKey(), 1)

View File

@ -33,7 +33,7 @@ import org.elasticsearch.cluster.routing.allocation.command.MoveAllocationComman
import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESAllocationTestCase; import org.elasticsearch.test.ESAllocationTestCase;
import static java.util.Collections.singletonMap; import static java.util.Collections.singletonMap;
@ -41,7 +41,6 @@ import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING; import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED; import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.sameInstance; import static org.hamcrest.Matchers.sameInstance;
@ -53,7 +52,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
private final ESLogger logger = Loggers.getLogger(AwarenessAllocationTests.class); private final ESLogger logger = Loggers.getLogger(AwarenessAllocationTests.class);
public void testMoveShardOnceNewNodeWithAttributeAdded1() { public void testMoveShardOnceNewNodeWithAttributeAdded1() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.put("cluster.routing.allocation.awareness.attributes", "rack_id") .put("cluster.routing.allocation.awareness.attributes", "rack_id")
@ -121,7 +120,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
} }
public void testMoveShardOnceNewNodeWithAttributeAdded2() { public void testMoveShardOnceNewNodeWithAttributeAdded2() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.concurrent_recoveries", 10) .put("cluster.routing.allocation.concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.put("cluster.routing.allocation.awareness.attributes", "rack_id") .put("cluster.routing.allocation.awareness.attributes", "rack_id")
@ -190,7 +189,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
} }
public void testMoveShardOnceNewNodeWithAttributeAdded3() { public void testMoveShardOnceNewNodeWithAttributeAdded3() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put("cluster.routing.allocation.node_initial_primaries_recoveries", 10) .put("cluster.routing.allocation.node_initial_primaries_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
@ -282,7 +281,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
} }
public void testMoveShardOnceNewNodeWithAttributeAdded4() { public void testMoveShardOnceNewNodeWithAttributeAdded4() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put("cluster.routing.allocation.node_initial_primaries_recoveries", 10) .put("cluster.routing.allocation.node_initial_primaries_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
@ -377,7 +376,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
} }
public void testMoveShardOnceNewNodeWithAttributeAdded5() { public void testMoveShardOnceNewNodeWithAttributeAdded5() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.put("cluster.routing.allocation.awareness.attributes", "rack_id") .put("cluster.routing.allocation.awareness.attributes", "rack_id")
@ -455,7 +454,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
} }
public void testMoveShardOnceNewNodeWithAttributeAdded6() { public void testMoveShardOnceNewNodeWithAttributeAdded6() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.put("cluster.routing.allocation.awareness.attributes", "rack_id") .put("cluster.routing.allocation.awareness.attributes", "rack_id")
@ -535,7 +534,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
} }
public void testFullAwareness1() { public void testFullAwareness1() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.put("cluster.routing.allocation.awareness.force.rack_id.values", "1,2") .put("cluster.routing.allocation.awareness.force.rack_id.values", "1,2")
@ -602,7 +601,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
} }
public void testFullAwareness2() { public void testFullAwareness2() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.put("cluster.routing.allocation.awareness.force.rack_id.values", "1,2") .put("cluster.routing.allocation.awareness.force.rack_id.values", "1,2")
@ -670,7 +669,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
} }
public void testFullAwareness3() { public void testFullAwareness3() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put("cluster.routing.allocation.node_initial_primaries_recoveries", 10) .put("cluster.routing.allocation.node_initial_primaries_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
@ -754,7 +753,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
} }
public void testUnbalancedZones() { public void testUnbalancedZones() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.awareness.force.zone.values", "a,b") .put("cluster.routing.allocation.awareness.force.zone.values", "a,b")
.put("cluster.routing.allocation.awareness.attributes", "zone") .put("cluster.routing.allocation.awareness.attributes", "zone")
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
@ -818,7 +817,7 @@ public class AwarenessAllocationTests extends ESAllocationTestCase {
} }
public void testUnassignedShardsWithUnbalancedZones() { public void testUnassignedShardsWithUnbalancedZones() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.put("cluster.routing.allocation.awareness.attributes", "zone") .put("cluster.routing.allocation.awareness.attributes", "zone")

View File

@ -49,7 +49,6 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
public class BalanceConfigurationTests extends ESAllocationTestCase { public class BalanceConfigurationTests extends ESAllocationTestCase {
@ -66,7 +65,7 @@ public class BalanceConfigurationTests extends ESAllocationTestCase {
final float replicaBalance = 0.0f; final float replicaBalance = 0.0f;
final float balanceTreshold = 1.0f; final float balanceTreshold = 1.0f;
Settings.Builder settings = settingsBuilder(); Settings.Builder settings = Settings.builder();
settings.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()); settings.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString());
settings.put(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING.getKey(), indexBalance); settings.put(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING.getKey(), indexBalance);
settings.put(BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING.getKey(), replicaBalance); settings.put(BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING.getKey(), replicaBalance);
@ -91,7 +90,7 @@ public class BalanceConfigurationTests extends ESAllocationTestCase {
final float replicaBalance = 1.0f; final float replicaBalance = 1.0f;
final float balanceTreshold = 1.0f; final float balanceTreshold = 1.0f;
Settings.Builder settings = settingsBuilder(); Settings.Builder settings = Settings.builder();
settings.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()); settings.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString());
settings.put(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING.getKey(), indexBalance); settings.put(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING.getKey(), indexBalance);
settings.put(BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING.getKey(), replicaBalance); settings.put(BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING.getKey(), replicaBalance);
@ -280,17 +279,17 @@ public class BalanceConfigurationTests extends ESAllocationTestCase {
} }
public void testPersistedSettings() { public void testPersistedSettings() {
Settings.Builder settings = settingsBuilder(); Settings.Builder settings = Settings.builder();
settings.put(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING.getKey(), 0.2); settings.put(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING.getKey(), 0.2);
settings.put(BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING.getKey(), 0.3); settings.put(BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING.getKey(), 0.3);
settings.put(BalancedShardsAllocator.THRESHOLD_SETTING.getKey(), 2.0); settings.put(BalancedShardsAllocator.THRESHOLD_SETTING.getKey(), 2.0);
ClusterSettings service = new ClusterSettings(settingsBuilder().build(), ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); ClusterSettings service = new ClusterSettings(Settings.builder().build(), ClusterSettings.BUILT_IN_CLUSTER_SETTINGS);
BalancedShardsAllocator allocator = new BalancedShardsAllocator(settings.build(), service); BalancedShardsAllocator allocator = new BalancedShardsAllocator(settings.build(), service);
assertThat(allocator.getIndexBalance(), Matchers.equalTo(0.2f)); assertThat(allocator.getIndexBalance(), Matchers.equalTo(0.2f));
assertThat(allocator.getShardBalance(), Matchers.equalTo(0.3f)); assertThat(allocator.getShardBalance(), Matchers.equalTo(0.3f));
assertThat(allocator.getThreshold(), Matchers.equalTo(2.0f)); assertThat(allocator.getThreshold(), Matchers.equalTo(2.0f));
settings = settingsBuilder(); settings = Settings.builder();
settings.put(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING.getKey(), 0.2); settings.put(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING.getKey(), 0.2);
settings.put(BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING.getKey(), 0.3); settings.put(BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING.getKey(), 0.3);
settings.put(BalancedShardsAllocator.THRESHOLD_SETTING.getKey(), 2.0); settings.put(BalancedShardsAllocator.THRESHOLD_SETTING.getKey(), 2.0);
@ -300,7 +299,7 @@ public class BalanceConfigurationTests extends ESAllocationTestCase {
assertThat(allocator.getShardBalance(), Matchers.equalTo(0.3f)); assertThat(allocator.getShardBalance(), Matchers.equalTo(0.3f));
assertThat(allocator.getThreshold(), Matchers.equalTo(2.0f)); assertThat(allocator.getThreshold(), Matchers.equalTo(2.0f));
settings = settingsBuilder(); settings = Settings.builder();
settings.put(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING.getKey(), 0.5); settings.put(BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING.getKey(), 0.5);
settings.put(BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING.getKey(), 0.1); settings.put(BalancedShardsAllocator.SHARD_BALANCE_FACTOR_SETTING.getKey(), 0.1);
settings.put(BalancedShardsAllocator.THRESHOLD_SETTING.getKey(), 3.0); settings.put(BalancedShardsAllocator.THRESHOLD_SETTING.getKey(), 3.0);
@ -311,7 +310,7 @@ public class BalanceConfigurationTests extends ESAllocationTestCase {
} }
public void testNoRebalanceOnPrimaryOverload() { public void testNoRebalanceOnPrimaryOverload() {
Settings.Builder settings = settingsBuilder(); Settings.Builder settings = Settings.builder();
AllocationService strategy = new AllocationService(settings.build(), randomAllocationDeciders(settings.build(), AllocationService strategy = new AllocationService(settings.build(), randomAllocationDeciders(settings.build(),
new ClusterSettings(Settings.Builder.EMPTY_SETTINGS, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), random()), new ClusterSettings(Settings.Builder.EMPTY_SETTINGS, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS), random()),
NoopGatewayAllocator.INSTANCE, new ShardsAllocator() { NoopGatewayAllocator.INSTANCE, new ShardsAllocator() {

View File

@ -26,6 +26,7 @@ import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.routing.IndexShardRoutingTable; import org.elasticsearch.cluster.routing.IndexShardRoutingTable;
import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.common.settings.Settings;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -35,7 +36,6 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
/** /**
* see issue #9023 * see issue #9023
@ -54,7 +54,7 @@ public class BalanceUnbalancedClusterTests extends CatAllocationTestCase {
@Override @Override
protected ClusterState allocateNew(ClusterState state) { protected ClusterState allocateNew(ClusterState state) {
String index = "tweets-2014-12-29:00"; String index = "tweets-2014-12-29:00";
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.build()); .build());
MetaData metaData = MetaData.builder(state.metaData()) MetaData metaData = MetaData.builder(state.metaData())
.put(IndexMetaData.builder(index).settings(settings(Version.CURRENT)).numberOfShards(5).numberOfReplicas(1)) .put(IndexMetaData.builder(index).settings(settings(Version.CURRENT)).numberOfShards(5).numberOfReplicas(1))

View File

@ -30,6 +30,7 @@ import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.ShardRoutingState; import org.elasticsearch.cluster.routing.ShardRoutingState;
import org.elasticsearch.cluster.routing.TestShardRouting; import org.elasticsearch.cluster.routing.TestShardRouting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESAllocationTestCase; import org.elasticsearch.test.ESAllocationTestCase;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -47,7 +48,6 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
/** /**
* A base testcase that allows to run tests based on the output of the CAT API * A base testcase that allows to run tests based on the output of the CAT API
@ -134,7 +134,7 @@ public abstract class CatAllocationTestCase extends ESAllocationTestCase {
} }
private ClusterState rebalance(ClusterState clusterState) { private ClusterState rebalance(ClusterState clusterState) {
RoutingTable routingTable;AllocationService strategy = createAllocationService(settingsBuilder() RoutingTable routingTable;AllocationService strategy = createAllocationService(Settings.builder()
.build()); .build());
RoutingAllocation.Result reroute = strategy.reroute(clusterState, "reroute"); RoutingAllocation.Result reroute = strategy.reroute(clusterState, "reroute");
routingTable = reroute.routingTable(); routingTable = reroute.routingTable();

View File

@ -40,7 +40,6 @@ import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING; import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED; import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
@ -48,7 +47,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
private final ESLogger logger = Loggers.getLogger(ClusterRebalanceRoutingTests.class); private final ESLogger logger = Loggers.getLogger(ClusterRebalanceRoutingTests.class);
public void testAlways() { public void testAlways() {
AllocationService strategy = createAllocationService(settingsBuilder().put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), AllocationService strategy = createAllocationService(Settings.builder().put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(),
ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()).build()); ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()).build());
MetaData metaData = MetaData.builder() MetaData metaData = MetaData.builder()
@ -134,7 +133,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
public void testClusterPrimariesActive1() { public void testClusterPrimariesActive1() {
AllocationService strategy = createAllocationService(settingsBuilder().put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), AllocationService strategy = createAllocationService(Settings.builder().put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(),
ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_PRIMARIES_ACTIVE.toString()).build()); ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_PRIMARIES_ACTIVE.toString()).build());
MetaData metaData = MetaData.builder() MetaData metaData = MetaData.builder()
@ -238,7 +237,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
} }
public void testClusterPrimariesActive2() { public void testClusterPrimariesActive2() {
AllocationService strategy = createAllocationService(settingsBuilder().put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), AllocationService strategy = createAllocationService(Settings.builder().put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(),
ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_PRIMARIES_ACTIVE.toString()).build()); ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_PRIMARIES_ACTIVE.toString()).build());
MetaData metaData = MetaData.builder() MetaData metaData = MetaData.builder()
@ -322,7 +321,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
} }
public void testClusterAllActive1() { public void testClusterAllActive1() {
AllocationService strategy = createAllocationService(settingsBuilder().put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), AllocationService strategy = createAllocationService(Settings.builder().put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(),
ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_ALL_ACTIVE.toString()).build()); ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_ALL_ACTIVE.toString()).build());
MetaData metaData = MetaData.builder() MetaData metaData = MetaData.builder()
@ -445,7 +444,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
} }
public void testClusterAllActive2() { public void testClusterAllActive2() {
AllocationService strategy = createAllocationService(settingsBuilder().put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), AllocationService strategy = createAllocationService(Settings.builder().put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(),
ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_ALL_ACTIVE.toString()).build()); ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_ALL_ACTIVE.toString()).build());
MetaData metaData = MetaData.builder() MetaData metaData = MetaData.builder()
@ -529,7 +528,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
} }
public void testClusterAllActive3() { public void testClusterAllActive3() {
AllocationService strategy = createAllocationService(settingsBuilder().put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), AllocationService strategy = createAllocationService(Settings.builder().put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(),
ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_ALL_ACTIVE.toString()).build()); ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_ALL_ACTIVE.toString()).build());
MetaData metaData = MetaData.builder() MetaData metaData = MetaData.builder()
@ -739,7 +738,7 @@ public class ClusterRebalanceRoutingTests extends ESAllocationTestCase {
public void testRebalanceWhileShardFetching() { public void testRebalanceWhileShardFetching() {
final AtomicBoolean hasFetches = new AtomicBoolean(true); final AtomicBoolean hasFetches = new AtomicBoolean(true);
AllocationService strategy = createAllocationService(settingsBuilder().put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), AllocationService strategy = createAllocationService(Settings.builder().put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(),
ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()).build(), new NoopGatewayAllocator() { ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()).build(), new NoopGatewayAllocator() {
@Override @Override
public boolean allocateUnassigned(RoutingAllocation allocation) { public boolean allocateUnassigned(RoutingAllocation allocation) {

View File

@ -28,13 +28,13 @@ import org.elasticsearch.cluster.routing.RoutingNodes;
import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESAllocationTestCase; import org.elasticsearch.test.ESAllocationTestCase;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING; import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED; import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.nullValue;
@ -42,7 +42,7 @@ public class ConcurrentRebalanceRoutingTests extends ESAllocationTestCase {
private final ESLogger logger = Loggers.getLogger(ConcurrentRebalanceRoutingTests.class); private final ESLogger logger = Loggers.getLogger(ConcurrentRebalanceRoutingTests.class);
public void testClusterConcurrentRebalance() { public void testClusterConcurrentRebalance() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put("cluster.routing.allocation.cluster_concurrent_rebalance", 3) .put("cluster.routing.allocation.cluster_concurrent_rebalance", 3)
.build()); .build());

View File

@ -30,12 +30,12 @@ import org.elasticsearch.cluster.routing.allocation.command.MoveAllocationComman
import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESAllocationTestCase; import org.elasticsearch.test.ESAllocationTestCase;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING; import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
/** /**
@ -44,7 +44,7 @@ public class DeadNodesAllocationTests extends ESAllocationTestCase {
private final ESLogger logger = Loggers.getLogger(DeadNodesAllocationTests.class); private final ESLogger logger = Loggers.getLogger(DeadNodesAllocationTests.class);
public void testSimpleDeadNodeOnStartedPrimaryShard() { public void testSimpleDeadNodeOnStartedPrimaryShard() {
AllocationService allocation = createAllocationService(settingsBuilder() AllocationService allocation = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.build()); .build());
@ -95,7 +95,7 @@ public class DeadNodesAllocationTests extends ESAllocationTestCase {
} }
public void testDeadNodeWhileRelocatingOnToNode() { public void testDeadNodeWhileRelocatingOnToNode() {
AllocationService allocation = createAllocationService(settingsBuilder() AllocationService allocation = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.build()); .build());
@ -169,7 +169,7 @@ public class DeadNodesAllocationTests extends ESAllocationTestCase {
} }
public void testDeadNodeWhileRelocatingOnFromNode() { public void testDeadNodeWhileRelocatingOnFromNode() {
AllocationService allocation = createAllocationService(settingsBuilder() AllocationService allocation = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.build()); .build());

View File

@ -29,11 +29,11 @@ import org.elasticsearch.cluster.routing.RoutingNodes;
import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESAllocationTestCase; import org.elasticsearch.test.ESAllocationTestCase;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
/** /**
@ -43,7 +43,7 @@ public class ElectReplicaAsPrimaryDuringRelocationTests extends ESAllocationTest
private final ESLogger logger = Loggers.getLogger(ElectReplicaAsPrimaryDuringRelocationTests.class); private final ESLogger logger = Loggers.getLogger(ElectReplicaAsPrimaryDuringRelocationTests.class);
public void testElectReplicaAsPrimaryDuringRelocation() { public void testElectReplicaAsPrimaryDuringRelocation() {
AllocationService strategy = createAllocationService(settingsBuilder().put("cluster.routing.allocation.node_concurrent_recoveries", 10).build()); AllocationService strategy = createAllocationService(Settings.builder().put("cluster.routing.allocation.node_concurrent_recoveries", 10).build());
logger.info("Building initial routing table"); logger.info("Building initial routing table");

View File

@ -30,18 +30,18 @@ import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESAllocationTestCase; import org.elasticsearch.test.ESAllocationTestCase;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
public class FailedNodeRoutingTests extends ESAllocationTestCase { public class FailedNodeRoutingTests extends ESAllocationTestCase {
private final ESLogger logger = Loggers.getLogger(FailedNodeRoutingTests.class); private final ESLogger logger = Loggers.getLogger(FailedNodeRoutingTests.class);
public void testSimpleFailedNodeTest() { public void testSimpleFailedNodeTest() {
AllocationService strategy = createAllocationService(settingsBuilder().put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), AllocationService strategy = createAllocationService(Settings.builder().put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(),
ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()).build()); ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()).build());
MetaData metaData = MetaData.builder() MetaData metaData = MetaData.builder()

View File

@ -32,6 +32,7 @@ import org.elasticsearch.cluster.routing.allocation.command.MoveAllocationComman
import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESAllocationTestCase; import org.elasticsearch.test.ESAllocationTestCase;
import java.util.ArrayList; import java.util.ArrayList;
@ -41,7 +42,6 @@ import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING; import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED; import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.lessThan; import static org.hamcrest.Matchers.lessThan;
@ -55,7 +55,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
private final ESLogger logger = Loggers.getLogger(FailedShardsRoutingTests.class); private final ESLogger logger = Loggers.getLogger(FailedShardsRoutingTests.class);
public void testFailedShardPrimaryRelocatingToAndFrom() { public void testFailedShardPrimaryRelocatingToAndFrom() {
AllocationService allocation = createAllocationService(settingsBuilder() AllocationService allocation = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.build()); .build());
@ -143,7 +143,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
} }
public void testFailPrimaryStartedCheckReplicaElected() { public void testFailPrimaryStartedCheckReplicaElected() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.build()); .build());
@ -224,7 +224,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
} }
public void testFirstAllocationFailureSingleNode() { public void testFirstAllocationFailureSingleNode() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.build()); .build());
@ -280,7 +280,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
} }
public void testSingleShardMultipleAllocationFailures() { public void testSingleShardMultipleAllocationFailures() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.build()); .build());
@ -336,7 +336,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
} }
public void testFirstAllocationFailureTwoNodes() { public void testFirstAllocationFailureTwoNodes() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.build()); .build());
@ -396,7 +396,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
} }
public void testRebalanceFailure() { public void testRebalanceFailure() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.build()); .build());
@ -491,7 +491,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
} }
public void testFailAllReplicasInitializingOnPrimaryFail() { public void testFailAllReplicasInitializingOnPrimaryFail() {
AllocationService allocation = createAllocationService(settingsBuilder() AllocationService allocation = createAllocationService(Settings.builder()
.build()); .build());
MetaData metaData = MetaData.builder() MetaData metaData = MetaData.builder()
@ -537,7 +537,7 @@ public class FailedShardsRoutingTests extends ESAllocationTestCase {
} }
public void testFailAllReplicasInitializingOnPrimaryFailWhileHavingAReplicaToElect() { public void testFailAllReplicasInitializingOnPrimaryFailWhileHavingAReplicaToElect() {
AllocationService allocation = createAllocationService(settingsBuilder() AllocationService allocation = createAllocationService(Settings.builder()
.build()); .build());
MetaData metaData = MetaData.builder() MetaData metaData = MetaData.builder()

View File

@ -30,6 +30,7 @@ import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.ShardRoutingState; import org.elasticsearch.cluster.routing.ShardRoutingState;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESAllocationTestCase; import org.elasticsearch.test.ESAllocationTestCase;
import org.hamcrest.Matchers; import org.hamcrest.Matchers;
@ -38,7 +39,6 @@ import java.util.List;
import static java.util.Collections.singletonMap; import static java.util.Collections.singletonMap;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
/** /**
@ -47,7 +47,7 @@ public class FilterRoutingTests extends ESAllocationTestCase {
private final ESLogger logger = Loggers.getLogger(FilterRoutingTests.class); private final ESLogger logger = Loggers.getLogger(FilterRoutingTests.class);
public void testClusterFilters() { public void testClusterFilters() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.include.tag1", "value1,value2") .put("cluster.routing.allocation.include.tag1", "value1,value2")
.put("cluster.routing.allocation.exclude.tag1", "value3,value4") .put("cluster.routing.allocation.exclude.tag1", "value3,value4")
.build()); .build());
@ -92,7 +92,7 @@ public class FilterRoutingTests extends ESAllocationTestCase {
} }
public void testIndexFilters() { public void testIndexFilters() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.build()); .build());
logger.info("Building initial routing table"); logger.info("Building initial routing table");
@ -166,7 +166,7 @@ public class FilterRoutingTests extends ESAllocationTestCase {
} }
public void testRebalanceAfterShardsCannotRemainOnNode() { public void testRebalanceAfterShardsCannotRemainOnNode() {
AllocationService strategy = createAllocationService(settingsBuilder().build()); AllocationService strategy = createAllocationService(Settings.builder().build());
logger.info("Building initial routing table"); logger.info("Building initial routing table");
MetaData metaData = MetaData.builder() MetaData metaData = MetaData.builder()
@ -198,7 +198,7 @@ public class FilterRoutingTests extends ESAllocationTestCase {
assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(4)); assertThat(clusterState.getRoutingNodes().shardsWithState(STARTED).size(), equalTo(4));
logger.info("--> disable allocation for node1 and reroute"); logger.info("--> disable allocation for node1 and reroute");
strategy = createAllocationService(settingsBuilder() strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.cluster_concurrent_rebalance", "1") .put("cluster.routing.allocation.cluster_concurrent_rebalance", "1")
.put("cluster.routing.allocation.exclude.tag1", "value1") .put("cluster.routing.allocation.exclude.tag1", "value1")
.build()); .build());

View File

@ -29,12 +29,12 @@ import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESAllocationTestCase; import org.elasticsearch.test.ESAllocationTestCase;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED; import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.nullValue;
@ -45,7 +45,7 @@ public class IndexBalanceTests extends ESAllocationTestCase {
private final ESLogger logger = Loggers.getLogger(IndexBalanceTests.class); private final ESLogger logger = Loggers.getLogger(IndexBalanceTests.class);
public void testBalanceAllNodesStarted() { public void testBalanceAllNodesStarted() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put("cluster.routing.allocation.node_initial_primaries_recoveries", 10) .put("cluster.routing.allocation.node_initial_primaries_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
@ -175,7 +175,7 @@ public class IndexBalanceTests extends ESAllocationTestCase {
} }
public void testBalanceIncrementallyStartNodes() { public void testBalanceIncrementallyStartNodes() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put("cluster.routing.allocation.node_initial_primaries_recoveries", 10) .put("cluster.routing.allocation.node_initial_primaries_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
@ -337,7 +337,7 @@ public class IndexBalanceTests extends ESAllocationTestCase {
} }
public void testBalanceAllNodesStartedAddIndex() { public void testBalanceAllNodesStartedAddIndex() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put("cluster.routing.allocation.node_initial_primaries_recoveries", 10) .put("cluster.routing.allocation.node_initial_primaries_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")

View File

@ -60,7 +60,6 @@ import static java.util.Collections.shuffle;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED; import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.test.VersionUtils.randomVersion; import static org.elasticsearch.test.VersionUtils.randomVersion;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
@ -74,7 +73,7 @@ public class NodeVersionAllocationDeciderTests extends ESAllocationTestCase {
private final ESLogger logger = Loggers.getLogger(NodeVersionAllocationDeciderTests.class); private final ESLogger logger = Loggers.getLogger(NodeVersionAllocationDeciderTests.class);
public void testDoNotAllocateFromPrimary() { public void testDoNotAllocateFromPrimary() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1) .put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
@ -188,7 +187,7 @@ public class NodeVersionAllocationDeciderTests extends ESAllocationTestCase {
} }
public void testRandom() { public void testRandom() {
AllocationService service = createAllocationService(settingsBuilder() AllocationService service = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1) .put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
@ -237,7 +236,7 @@ public class NodeVersionAllocationDeciderTests extends ESAllocationTestCase {
} }
public void testRollingRestart() { public void testRollingRestart() {
AllocationService service = createAllocationService(settingsBuilder() AllocationService service = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1) .put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)

View File

@ -25,6 +25,7 @@ import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESAllocationTestCase; import org.elasticsearch.test.ESAllocationTestCase;
import static java.util.Collections.singletonMap; import static java.util.Collections.singletonMap;
@ -32,7 +33,6 @@ import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING; import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED; import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
/** /**
@ -45,7 +45,7 @@ public class PreferLocalPrimariesToRelocatingPrimariesTests extends ESAllocation
int totalNumberOfShards = numberOfShards * 2; int totalNumberOfShards = numberOfShards * 2;
logger.info("create an allocation with [{}] initial primary recoveries and [{}] concurrent recoveries", primaryRecoveries, concurrentRecoveries); logger.info("create an allocation with [{}] initial primary recoveries and [{}] concurrent recoveries", primaryRecoveries, concurrentRecoveries);
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", concurrentRecoveries) .put("cluster.routing.allocation.node_concurrent_recoveries", concurrentRecoveries)
.put("cluster.routing.allocation.node_initial_primaries_recoveries", primaryRecoveries) .put("cluster.routing.allocation.node_initial_primaries_recoveries", primaryRecoveries)
.build()); .build());

View File

@ -28,10 +28,10 @@ import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.cluster.routing.allocation.decider.ThrottlingAllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.ThrottlingAllocationDecider;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESAllocationTestCase; import org.elasticsearch.test.ESAllocationTestCase;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
/** /**
@ -41,7 +41,7 @@ public class PreferPrimaryAllocationTests extends ESAllocationTestCase {
public void testPreferPrimaryAllocationOverReplicas() { public void testPreferPrimaryAllocationOverReplicas() {
logger.info("create an allocation with 1 initial recoveries"); logger.info("create an allocation with 1 initial recoveries");
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 1) .put("cluster.routing.allocation.node_concurrent_recoveries", 1)
.put(ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_OUTGOING_RECOVERIES_SETTING.getKey(), 10) .put(ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_OUTGOING_RECOVERIES_SETTING.getKey(), 10)
.put("cluster.routing.allocation.node_initial_primaries_recoveries", 1) .put("cluster.routing.allocation.node_initial_primaries_recoveries", 1)

View File

@ -28,11 +28,11 @@ import org.elasticsearch.cluster.routing.RoutingNodes;
import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESAllocationTestCase; import org.elasticsearch.test.ESAllocationTestCase;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.nullValue;
@ -43,7 +43,7 @@ public class PrimaryElectionRoutingTests extends ESAllocationTestCase {
private final ESLogger logger = Loggers.getLogger(PrimaryElectionRoutingTests.class); private final ESLogger logger = Loggers.getLogger(PrimaryElectionRoutingTests.class);
public void testBackupElectionToPrimaryWhenPrimaryCanBeAllocatedToAnotherNode() { public void testBackupElectionToPrimaryWhenPrimaryCanBeAllocatedToAnotherNode() {
AllocationService strategy = createAllocationService(settingsBuilder().put("cluster.routing.allocation.node_concurrent_recoveries", 10).build()); AllocationService strategy = createAllocationService(Settings.builder().put("cluster.routing.allocation.node_concurrent_recoveries", 10).build());
logger.info("Building initial routing table"); logger.info("Building initial routing table");
@ -96,7 +96,7 @@ public class PrimaryElectionRoutingTests extends ESAllocationTestCase {
} }
public void testRemovingInitializingReplicasIfPrimariesFails() { public void testRemovingInitializingReplicasIfPrimariesFails() {
AllocationService allocation = createAllocationService(settingsBuilder().put("cluster.routing.allocation.node_concurrent_recoveries", 10).build()); AllocationService allocation = createAllocationService(Settings.builder().put("cluster.routing.allocation.node_concurrent_recoveries", 10).build());
logger.info("Building initial routing table"); logger.info("Building initial routing table");

View File

@ -28,11 +28,11 @@ import org.elasticsearch.cluster.routing.RoutingNodes;
import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESAllocationTestCase; import org.elasticsearch.test.ESAllocationTestCase;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
/** /**
@ -42,7 +42,7 @@ public class PrimaryNotRelocatedWhileBeingRecoveredTests extends ESAllocationTes
private final ESLogger logger = Loggers.getLogger(PrimaryNotRelocatedWhileBeingRecoveredTests.class); private final ESLogger logger = Loggers.getLogger(PrimaryNotRelocatedWhileBeingRecoveredTests.class);
public void testPrimaryNotRelocatedWhileBeingRecoveredFrom() { public void testPrimaryNotRelocatedWhileBeingRecoveredFrom() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put("cluster.routing.allocation.concurrent_source_recoveries", 10) .put("cluster.routing.allocation.concurrent_source_recoveries", 10)
.put("cluster.routing.allocation.node_initial_primaries_recoveries", 10) .put("cluster.routing.allocation.node_initial_primaries_recoveries", 10)

View File

@ -46,7 +46,6 @@ import java.util.HashSet;
import java.util.Random; import java.util.Random;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
public class RandomAllocationDeciderTests extends ESAllocationTestCase { public class RandomAllocationDeciderTests extends ESAllocationTestCase {
@ -57,7 +56,7 @@ public class RandomAllocationDeciderTests extends ESAllocationTestCase {
* balance.*/ * balance.*/
public void testRandomDecisions() { public void testRandomDecisions() {
RandomAllocationDecider randomAllocationDecider = new RandomAllocationDecider(random()); RandomAllocationDecider randomAllocationDecider = new RandomAllocationDecider(random());
AllocationService strategy = new AllocationService(settingsBuilder().build(), new AllocationDeciders(Settings.EMPTY, AllocationService strategy = new AllocationService(Settings.builder().build(), new AllocationDeciders(Settings.EMPTY,
new HashSet<>(Arrays.asList(new SameShardAllocationDecider(Settings.EMPTY), new ReplicaAfterPrimaryActiveAllocationDecider(Settings.EMPTY), new HashSet<>(Arrays.asList(new SameShardAllocationDecider(Settings.EMPTY), new ReplicaAfterPrimaryActiveAllocationDecider(Settings.EMPTY),
randomAllocationDecider))), NoopGatewayAllocator.INSTANCE, new BalancedShardsAllocator(Settings.EMPTY), EmptyClusterInfoService.INSTANCE); randomAllocationDecider))), NoopGatewayAllocator.INSTANCE, new BalancedShardsAllocator(Settings.EMPTY), EmptyClusterInfoService.INSTANCE);
int indices = scaledRandomIntBetween(1, 20); int indices = scaledRandomIntBetween(1, 20);

View File

@ -33,13 +33,13 @@ import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESAllocationTestCase; import org.elasticsearch.test.ESAllocationTestCase;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING; import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED; import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.nullValue;
@ -55,7 +55,7 @@ public class RebalanceAfterActiveTests extends ESAllocationTestCase {
sizes[i] = randomIntBetween(0, Integer.MAX_VALUE); sizes[i] = randomIntBetween(0, Integer.MAX_VALUE);
} }
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1) .put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)

View File

@ -28,12 +28,12 @@ import org.elasticsearch.cluster.routing.RoutingNodes;
import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESAllocationTestCase; import org.elasticsearch.test.ESAllocationTestCase;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED; import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.nullValue;
@ -45,7 +45,7 @@ public class ReplicaAllocatedAfterPrimaryTests extends ESAllocationTestCase {
private final ESLogger logger = Loggers.getLogger(ReplicaAllocatedAfterPrimaryTests.class); private final ESLogger logger = Loggers.getLogger(ReplicaAllocatedAfterPrimaryTests.class);
public void testBackupIsAllocatedAfterPrimary() { public void testBackupIsAllocatedAfterPrimary() {
AllocationService strategy = createAllocationService(settingsBuilder().put("cluster.routing.allocation.node_concurrent_recoveries", 10).build()); AllocationService strategy = createAllocationService(Settings.builder().put("cluster.routing.allocation.node_concurrent_recoveries", 10).build());
logger.info("Building initial routing table"); logger.info("Building initial routing table");

View File

@ -31,11 +31,11 @@ import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllo
import org.elasticsearch.cluster.routing.allocation.decider.ThrottlingAllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.ThrottlingAllocationDecider;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESAllocationTestCase; import org.elasticsearch.test.ESAllocationTestCase;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
/** /**
@ -45,7 +45,7 @@ public class RoutingNodesIntegrityTests extends ESAllocationTestCase {
private final ESLogger logger = Loggers.getLogger(IndexBalanceTests.class); private final ESLogger logger = Loggers.getLogger(IndexBalanceTests.class);
public void testBalanceAllNodesStarted() { public void testBalanceAllNodesStarted() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put("cluster.routing.allocation.node_initial_primaries_recoveries", 10) .put("cluster.routing.allocation.node_initial_primaries_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
@ -117,7 +117,7 @@ public class RoutingNodesIntegrityTests extends ESAllocationTestCase {
} }
public void testBalanceIncrementallyStartNodes() { public void testBalanceIncrementallyStartNodes() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put("cluster.routing.allocation.node_initial_primaries_recoveries", 10) .put("cluster.routing.allocation.node_initial_primaries_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
@ -209,7 +209,7 @@ public class RoutingNodesIntegrityTests extends ESAllocationTestCase {
} }
public void testBalanceAllNodesStartedAddIndex() { public void testBalanceAllNodesStartedAddIndex() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 1) .put("cluster.routing.allocation.node_concurrent_recoveries", 1)
.put("cluster.routing.allocation.node_initial_primaries_recoveries", 3) .put("cluster.routing.allocation.node_initial_primaries_recoveries", 3)
.put(ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_OUTGOING_RECOVERIES_SETTING.getKey(), 10) .put(ThrottlingAllocationDecider.CLUSTER_ROUTING_ALLOCATION_NODE_CONCURRENT_OUTGOING_RECOVERIES_SETTING.getKey(), 10)

View File

@ -31,13 +31,13 @@ import org.elasticsearch.cluster.routing.ShardRoutingState;
import org.elasticsearch.cluster.routing.allocation.decider.SameShardAllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.SameShardAllocationDecider;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.DummyTransportAddress; import org.elasticsearch.common.transport.DummyTransportAddress;
import org.elasticsearch.test.ESAllocationTestCase; import org.elasticsearch.test.ESAllocationTestCase;
import static java.util.Collections.emptyMap; import static java.util.Collections.emptyMap;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.allocation.RoutingNodesUtils.numberOfShardsOfType; import static org.elasticsearch.cluster.routing.allocation.RoutingNodesUtils.numberOfShardsOfType;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
/** /**
@ -46,7 +46,7 @@ public class SameShardRoutingTests extends ESAllocationTestCase {
private final ESLogger logger = Loggers.getLogger(SameShardRoutingTests.class); private final ESLogger logger = Loggers.getLogger(SameShardRoutingTests.class);
public void testSameHost() { public void testSameHost() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put(SameShardAllocationDecider.SAME_HOST_SETTING, true).build()); .put(SameShardAllocationDecider.SAME_HOST_SETTING, true).build());
MetaData metaData = MetaData.builder() MetaData metaData = MetaData.builder()

View File

@ -29,19 +29,19 @@ import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESAllocationTestCase; import org.elasticsearch.test.ESAllocationTestCase;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED; import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
public class ShardVersioningTests extends ESAllocationTestCase { public class ShardVersioningTests extends ESAllocationTestCase {
private final ESLogger logger = Loggers.getLogger(ShardVersioningTests.class); private final ESLogger logger = Loggers.getLogger(ShardVersioningTests.class);
public void testSimple() { public void testSimple() {
AllocationService strategy = createAllocationService(settingsBuilder().put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), AllocationService strategy = createAllocationService(Settings.builder().put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(),
ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()).build()); ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()).build());
MetaData metaData = MetaData.builder() MetaData metaData = MetaData.builder()

View File

@ -31,13 +31,13 @@ import org.elasticsearch.cluster.routing.ShardRoutingState;
import org.elasticsearch.cluster.routing.allocation.decider.ShardsLimitAllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.ShardsLimitAllocationDecider;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESAllocationTestCase; import org.elasticsearch.test.ESAllocationTestCase;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING; import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.cluster.routing.allocation.RoutingNodesUtils.numberOfShardsOfType; import static org.elasticsearch.cluster.routing.allocation.RoutingNodesUtils.numberOfShardsOfType;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
/** /**
@ -46,7 +46,7 @@ public class ShardsLimitAllocationTests extends ESAllocationTestCase {
private final ESLogger logger = Loggers.getLogger(ShardsLimitAllocationTests.class); private final ESLogger logger = Loggers.getLogger(ShardsLimitAllocationTests.class);
public void testIndexLevelShardsLimitAllocate() { public void testIndexLevelShardsLimitAllocate() {
AllocationService strategy = createAllocationService(settingsBuilder().put("cluster.routing.allocation.node_concurrent_recoveries", 10).build()); AllocationService strategy = createAllocationService(Settings.builder().put("cluster.routing.allocation.node_concurrent_recoveries", 10).build());
logger.info("Building initial routing table"); logger.info("Building initial routing table");
@ -88,7 +88,7 @@ public class ShardsLimitAllocationTests extends ESAllocationTestCase {
} }
public void testClusterLevelShardsLimitAllocate() { public void testClusterLevelShardsLimitAllocate() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ShardsLimitAllocationDecider.CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING.getKey(), 1) .put(ShardsLimitAllocationDecider.CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING.getKey(), 1)
.build()); .build());
@ -124,7 +124,7 @@ public class ShardsLimitAllocationTests extends ESAllocationTestCase {
assertThat(clusterState.getRoutingNodes().unassigned().size(), equalTo(2)); assertThat(clusterState.getRoutingNodes().unassigned().size(), equalTo(2));
// Bump the cluster total shards to 2 // Bump the cluster total shards to 2
strategy = createAllocationService(settingsBuilder() strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ShardsLimitAllocationDecider.CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING.getKey(), 2) .put(ShardsLimitAllocationDecider.CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING.getKey(), 2)
.build()); .build());
@ -146,7 +146,7 @@ public class ShardsLimitAllocationTests extends ESAllocationTestCase {
} }
public void testIndexLevelShardsLimitRemain() { public void testIndexLevelShardsLimitRemain() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put("cluster.routing.allocation.node_initial_primaries_recoveries", 10) .put("cluster.routing.allocation.node_initial_primaries_recoveries", 10)
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1) .put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)

View File

@ -32,6 +32,7 @@ import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESAllocationTestCase; import org.elasticsearch.test.ESAllocationTestCase;
import java.util.ArrayList; import java.util.ArrayList;
@ -44,7 +45,6 @@ import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED; import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.cluster.routing.allocation.RoutingNodesUtils.numberOfShardsOfType; import static org.elasticsearch.cluster.routing.allocation.RoutingNodesUtils.numberOfShardsOfType;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.hasItem;
@ -59,7 +59,7 @@ public class SingleShardNoReplicasRoutingTests extends ESAllocationTestCase {
private final ESLogger logger = Loggers.getLogger(SingleShardNoReplicasRoutingTests.class); private final ESLogger logger = Loggers.getLogger(SingleShardNoReplicasRoutingTests.class);
public void testSingleIndexStartedShard() { public void testSingleIndexStartedShard() {
AllocationService strategy = createAllocationService(settingsBuilder().put("cluster.routing.allocation.node_concurrent_recoveries", 10).build()); AllocationService strategy = createAllocationService(Settings.builder().put("cluster.routing.allocation.node_concurrent_recoveries", 10).build());
logger.info("Building initial routing table"); logger.info("Building initial routing table");
@ -160,7 +160,7 @@ public class SingleShardNoReplicasRoutingTests extends ESAllocationTestCase {
} }
public void testSingleIndexShardFailed() { public void testSingleIndexShardFailed() {
AllocationService strategy = createAllocationService(settingsBuilder().put("cluster.routing.allocation.node_concurrent_recoveries", 10).build()); AllocationService strategy = createAllocationService(Settings.builder().put("cluster.routing.allocation.node_concurrent_recoveries", 10).build());
logger.info("Building initial routing table"); logger.info("Building initial routing table");
@ -209,7 +209,7 @@ public class SingleShardNoReplicasRoutingTests extends ESAllocationTestCase {
} }
public void testMultiIndexEvenDistribution() { public void testMultiIndexEvenDistribution() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1) .put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
@ -321,7 +321,7 @@ public class SingleShardNoReplicasRoutingTests extends ESAllocationTestCase {
} }
public void testMultiIndexUnevenNodes() { public void testMultiIndexUnevenNodes() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1) .put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)

View File

@ -28,12 +28,12 @@ import org.elasticsearch.cluster.routing.RoutingNodes;
import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESAllocationTestCase; import org.elasticsearch.test.ESAllocationTestCase;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED; import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.nullValue;
@ -44,7 +44,7 @@ public class SingleShardOneReplicaRoutingTests extends ESAllocationTestCase {
private final ESLogger logger = Loggers.getLogger(SingleShardOneReplicaRoutingTests.class); private final ESLogger logger = Loggers.getLogger(SingleShardOneReplicaRoutingTests.class);
public void testSingleIndexFirstStartPrimaryThenBackups() { public void testSingleIndexFirstStartPrimaryThenBackups() {
AllocationService strategy = createAllocationService(settingsBuilder().put("cluster.routing.allocation.node_concurrent_recoveries", 10).build()); AllocationService strategy = createAllocationService(Settings.builder().put("cluster.routing.allocation.node_concurrent_recoveries", 10).build());
logger.info("Building initial routing table"); logger.info("Building initial routing table");

View File

@ -29,13 +29,13 @@ import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider; import org.elasticsearch.cluster.routing.allocation.decider.ClusterRebalanceAllocationDecider;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESAllocationTestCase; import org.elasticsearch.test.ESAllocationTestCase;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING; import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED; import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.lessThan; import static org.hamcrest.Matchers.lessThan;
import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.nullValue;
@ -47,7 +47,7 @@ public class TenShardsOneReplicaRoutingTests extends ESAllocationTestCase {
private final ESLogger logger = Loggers.getLogger(TenShardsOneReplicaRoutingTests.class); private final ESLogger logger = Loggers.getLogger(TenShardsOneReplicaRoutingTests.class);
public void testSingleIndexFirstStartPrimaryThenBackups() { public void testSingleIndexFirstStartPrimaryThenBackups() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put("cluster.routing.allocation.node_initial_primaries_recoveries", 10) .put("cluster.routing.allocation.node_initial_primaries_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")

View File

@ -37,7 +37,6 @@ import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING; import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED; import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
/** /**
@ -47,7 +46,7 @@ public class ThrottlingAllocationTests extends ESAllocationTestCase {
private final ESLogger logger = Loggers.getLogger(ThrottlingAllocationTests.class); private final ESLogger logger = Loggers.getLogger(ThrottlingAllocationTests.class);
public void testPrimaryRecoveryThrottling() { public void testPrimaryRecoveryThrottling() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 3) .put("cluster.routing.allocation.node_concurrent_recoveries", 3)
.put("cluster.routing.allocation.node_initial_primaries_recoveries", 3) .put("cluster.routing.allocation.node_initial_primaries_recoveries", 3)
.build()); .build());
@ -107,7 +106,7 @@ public class ThrottlingAllocationTests extends ESAllocationTestCase {
} }
public void testReplicaAndPrimaryRecoveryThrottling() { public void testReplicaAndPrimaryRecoveryThrottling() {
AllocationService strategy = createAllocationService(settingsBuilder() AllocationService strategy = createAllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 3) .put("cluster.routing.allocation.node_concurrent_recoveries", 3)
.put("cluster.routing.allocation.concurrent_source_recoveries", 3) .put("cluster.routing.allocation.concurrent_source_recoveries", 3)
.put("cluster.routing.allocation.node_initial_primaries_recoveries", 3) .put("cluster.routing.allocation.node_initial_primaries_recoveries", 3)
@ -177,7 +176,7 @@ public class ThrottlingAllocationTests extends ESAllocationTestCase {
} }
public void testThrottleIncomingAndOutgoing() { public void testThrottleIncomingAndOutgoing() {
Settings settings = settingsBuilder() Settings settings = Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 5) .put("cluster.routing.allocation.node_concurrent_recoveries", 5)
.put("cluster.routing.allocation.node_initial_primaries_recoveries", 5) .put("cluster.routing.allocation.node_initial_primaries_recoveries", 5)
.put("cluster.routing.allocation.cluster_concurrent_rebalance", 5) .put("cluster.routing.allocation.cluster_concurrent_rebalance", 5)
@ -244,7 +243,7 @@ public class ThrottlingAllocationTests extends ESAllocationTestCase {
} }
public void testOutgoingThrottlesAllocaiton() { public void testOutgoingThrottlesAllocaiton() {
Settings settings = settingsBuilder() Settings settings = Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 1) .put("cluster.routing.allocation.node_concurrent_recoveries", 1)
.put("cluster.routing.allocation.node_initial_primaries_recoveries", 1) .put("cluster.routing.allocation.node_initial_primaries_recoveries", 1)
.put("cluster.routing.allocation.cluster_concurrent_rebalance", 1) .put("cluster.routing.allocation.cluster_concurrent_rebalance", 1)

View File

@ -28,12 +28,12 @@ import org.elasticsearch.cluster.routing.RoutingNodes;
import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.cluster.routing.RoutingTable;
import org.elasticsearch.common.logging.ESLogger; import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESAllocationTestCase; import org.elasticsearch.test.ESAllocationTestCase;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED; import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.not;
@ -46,7 +46,7 @@ public class UpdateNumberOfReplicasTests extends ESAllocationTestCase {
private final ESLogger logger = Loggers.getLogger(UpdateNumberOfReplicasTests.class); private final ESLogger logger = Loggers.getLogger(UpdateNumberOfReplicasTests.class);
public void testUpdateNumberOfReplicas() { public void testUpdateNumberOfReplicas() {
AllocationService strategy = createAllocationService(settingsBuilder().put("cluster.routing.allocation.node_concurrent_recoveries", 10).build()); AllocationService strategy = createAllocationService(Settings.builder().put("cluster.routing.allocation.node_concurrent_recoveries", 10).build());
logger.info("Building initial routing table"); logger.info("Building initial routing table");

View File

@ -60,7 +60,6 @@ import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING; import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED; import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED; import static org.elasticsearch.cluster.routing.ShardRoutingState.UNASSIGNED;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
@ -69,7 +68,7 @@ import static org.hamcrest.Matchers.nullValue;
public class DiskThresholdDeciderTests extends ESAllocationTestCase { public class DiskThresholdDeciderTests extends ESAllocationTestCase {
public void testDiskThreshold() { public void testDiskThreshold() {
Settings diskSettings = settingsBuilder() Settings diskSettings = Settings.builder()
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), true) .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), true)
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), 0.7) .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), 0.7)
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING.getKey(), 0.8).build(); .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING.getKey(), 0.8).build();
@ -104,7 +103,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
// noop // noop
} }
}; };
AllocationService strategy = new AllocationService(settingsBuilder() AllocationService strategy = new AllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1) .put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
@ -183,7 +182,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
// Set the low threshold to 60 instead of 70 // Set the low threshold to 60 instead of 70
// Set the high threshold to 70 instead of 80 // Set the high threshold to 70 instead of 80
// node2 now should not have new shards allocated to it, but shards can remain // node2 now should not have new shards allocated to it, but shards can remain
diskSettings = settingsBuilder() diskSettings = Settings.builder()
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), true) .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), true)
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), "60%") .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), "60%")
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING.getKey(), 0.7).build(); .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING.getKey(), 0.7).build();
@ -193,7 +192,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
new SameShardAllocationDecider(Settings.EMPTY), new SameShardAllocationDecider(Settings.EMPTY),
new DiskThresholdDecider(diskSettings)))); new DiskThresholdDecider(diskSettings))));
strategy = new AllocationService(settingsBuilder() strategy = new AllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1) .put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
@ -214,7 +213,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
// Set the low threshold to 50 instead of 60 // Set the low threshold to 50 instead of 60
// Set the high threshold to 60 instead of 70 // Set the high threshold to 60 instead of 70
// node2 now should not have new shards allocated to it, and shards cannot remain // node2 now should not have new shards allocated to it, and shards cannot remain
diskSettings = settingsBuilder() diskSettings = Settings.builder()
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), true) .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), true)
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), 0.5) .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), 0.5)
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING.getKey(), 0.6).build(); .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING.getKey(), 0.6).build();
@ -224,7 +223,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
new SameShardAllocationDecider(Settings.EMPTY), new SameShardAllocationDecider(Settings.EMPTY),
new DiskThresholdDecider(diskSettings)))); new DiskThresholdDecider(diskSettings))));
strategy = new AllocationService(settingsBuilder() strategy = new AllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1) .put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
@ -268,7 +267,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
} }
public void testDiskThresholdWithAbsoluteSizes() { public void testDiskThresholdWithAbsoluteSizes() {
Settings diskSettings = settingsBuilder() Settings diskSettings = Settings.builder()
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), true) .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), true)
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), "30b") .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), "30b")
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING.getKey(), "9b").build(); .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING.getKey(), "9b").build();
@ -305,7 +304,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
} }
}; };
AllocationService strategy = new AllocationService(settingsBuilder() AllocationService strategy = new AllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1) .put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
@ -363,7 +362,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
// noop // noop
} }
}; };
strategy = new AllocationService(settingsBuilder() strategy = new AllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1) .put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
@ -422,7 +421,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
// Set the low threshold to 60 instead of 70 // Set the low threshold to 60 instead of 70
// Set the high threshold to 70 instead of 80 // Set the high threshold to 70 instead of 80
// node2 now should not have new shards allocated to it, but shards can remain // node2 now should not have new shards allocated to it, but shards can remain
diskSettings = settingsBuilder() diskSettings = Settings.builder()
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), true) .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), true)
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), "40b") .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), "40b")
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING.getKey(), "30b").build(); .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING.getKey(), "30b").build();
@ -432,7 +431,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
new SameShardAllocationDecider(Settings.EMPTY), new SameShardAllocationDecider(Settings.EMPTY),
new DiskThresholdDecider(diskSettings)))); new DiskThresholdDecider(diskSettings))));
strategy = new AllocationService(settingsBuilder() strategy = new AllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1) .put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
@ -453,7 +452,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
// Set the low threshold to 50 instead of 60 // Set the low threshold to 50 instead of 60
// Set the high threshold to 60 instead of 70 // Set the high threshold to 60 instead of 70
// node2 now should not have new shards allocated to it, and shards cannot remain // node2 now should not have new shards allocated to it, and shards cannot remain
diskSettings = settingsBuilder() diskSettings = Settings.builder()
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), true) .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), true)
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), "50b") .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), "50b")
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING.getKey(), "40b").build(); .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING.getKey(), "40b").build();
@ -463,7 +462,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
new SameShardAllocationDecider(Settings.EMPTY), new SameShardAllocationDecider(Settings.EMPTY),
new DiskThresholdDecider(diskSettings)))); new DiskThresholdDecider(diskSettings))));
strategy = new AllocationService(settingsBuilder() strategy = new AllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1) .put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
@ -541,7 +540,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
} }
public void testDiskThresholdWithShardSizes() { public void testDiskThresholdWithShardSizes() {
Settings diskSettings = settingsBuilder() Settings diskSettings = Settings.builder()
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), true) .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), true)
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), 0.7) .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), 0.7)
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING.getKey(), "71%").build(); .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING.getKey(), "71%").build();
@ -574,7 +573,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
} }
}; };
AllocationService strategy = new AllocationService(settingsBuilder() AllocationService strategy = new AllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1) .put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
@ -610,7 +609,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
} }
public void testUnknownDiskUsage() { public void testUnknownDiskUsage() {
Settings diskSettings = settingsBuilder() Settings diskSettings = Settings.builder()
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), true) .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), true)
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), 0.7) .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), 0.7)
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING.getKey(), 0.85).build(); .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_HIGH_DISK_WATERMARK_SETTING.getKey(), 0.85).build();
@ -644,7 +643,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
} }
}; };
AllocationService strategy = new AllocationService(settingsBuilder() AllocationService strategy = new AllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1) .put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
@ -711,7 +710,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
} }
public void testShardRelocationsTakenIntoAccount() { public void testShardRelocationsTakenIntoAccount() {
Settings diskSettings = settingsBuilder() Settings diskSettings = Settings.builder()
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), true) .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), true)
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING.getKey(), true) .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING.getKey(), true)
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), 0.7) .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), 0.7)
@ -749,7 +748,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
} }
}; };
AllocationService strategy = new AllocationService(settingsBuilder() AllocationService strategy = new AllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1) .put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
@ -820,7 +819,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
} }
public void testCanRemainWithShardRelocatingAway() { public void testCanRemainWithShardRelocatingAway() {
Settings diskSettings = settingsBuilder() Settings diskSettings = Settings.builder()
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), true) .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), true)
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING.getKey(), true) .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING.getKey(), true)
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), "60%") .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), "60%")
@ -917,7 +916,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
AllocationDeciders deciders = new AllocationDeciders(Settings.EMPTY, new HashSet<>(Arrays.asList( AllocationDeciders deciders = new AllocationDeciders(Settings.EMPTY, new HashSet<>(Arrays.asList(
new SameShardAllocationDecider(Settings.EMPTY), diskThresholdDecider new SameShardAllocationDecider(Settings.EMPTY), diskThresholdDecider
))); )));
AllocationService strategy = new AllocationService(settingsBuilder() AllocationService strategy = new AllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1) .put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
@ -935,7 +934,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
} }
public void testForSingleDataNode() { public void testForSingleDataNode() {
Settings diskSettings = settingsBuilder() Settings diskSettings = Settings.builder()
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), true) .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_DISK_THRESHOLD_ENABLED_SETTING.getKey(), true)
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING.getKey(), true) .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_INCLUDE_RELOCATIONS_SETTING.getKey(), true)
.put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), "60%") .put(DiskThresholdDecider.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), "60%")
@ -1014,7 +1013,7 @@ public class DiskThresholdDeciderTests extends ESAllocationTestCase {
new SameShardAllocationDecider(Settings.EMPTY), diskThresholdDecider new SameShardAllocationDecider(Settings.EMPTY), diskThresholdDecider
))); )));
AllocationService strategy = new AllocationService(settingsBuilder() AllocationService strategy = new AllocationService(Settings.builder()
.put("cluster.routing.allocation.node_concurrent_recoveries", 10) .put("cluster.routing.allocation.node_concurrent_recoveries", 10)
.put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always") .put(ClusterRebalanceAllocationDecider.CLUSTER_ROUTING_ALLOCATION_ALLOW_REBALANCE_SETTING.getKey(), "always")

Some files were not shown because too many files have changed in this diff Show More