cleanup MetaData#Builder construction
have a better method name, and only allow to create a copy of the builder based on existing meta data when constructing the builder
This commit is contained in:
parent
acc5f584d4
commit
d111e169a4
|
@ -225,7 +225,7 @@ public class TransportClusterUpdateSettingsAction extends TransportMasterNodeOpe
|
||||||
return currentState;
|
return currentState;
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaData.Builder metaData = MetaData.builder().metaData(currentState.metaData())
|
MetaData.Builder metaData = MetaData.builder(currentState.metaData())
|
||||||
.persistentSettings(persistentSettings.build())
|
.persistentSettings(persistentSettings.build())
|
||||||
.transientSettings(transientSettings.build());
|
.transientSettings(transientSettings.build());
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,6 @@ import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.transport.TransportService;
|
import org.elasticsearch.transport.TransportService;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -93,9 +92,11 @@ public class TransportClusterStateAction extends TransportMasterNodeOperationAct
|
||||||
builder.blocks(currentState.blocks());
|
builder.blocks(currentState.blocks());
|
||||||
}
|
}
|
||||||
if (!request.filterMetaData()) {
|
if (!request.filterMetaData()) {
|
||||||
MetaData.Builder mdBuilder = newMetaDataBuilder();
|
MetaData.Builder mdBuilder;
|
||||||
if (request.filteredIndices().length == 0 && request.filteredIndexTemplates().length == 0) {
|
if (request.filteredIndices().length == 0 && request.filteredIndexTemplates().length == 0) {
|
||||||
mdBuilder.metaData(currentState.metaData());
|
mdBuilder = MetaData.builder(currentState.metaData());
|
||||||
|
} else {
|
||||||
|
mdBuilder = MetaData.builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.filteredIndices().length > 0) {
|
if (request.filteredIndices().length > 0) {
|
||||||
|
|
|
@ -125,7 +125,7 @@ public class TransportDeleteWarmerAction extends TransportMasterNodeOperationAct
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ClusterState execute(ClusterState currentState) {
|
public ClusterState execute(ClusterState currentState) {
|
||||||
MetaData.Builder mdBuilder = MetaData.builder().metaData(currentState.metaData());
|
MetaData.Builder mdBuilder = MetaData.builder(currentState.metaData());
|
||||||
|
|
||||||
boolean globalFoundAtLeastOne = false;
|
boolean globalFoundAtLeastOne = false;
|
||||||
for (String index : request.indices()) {
|
for (String index : request.indices()) {
|
||||||
|
|
|
@ -144,7 +144,7 @@ public class TransportPutWarmerAction extends TransportMasterNodeOperationAction
|
||||||
}
|
}
|
||||||
|
|
||||||
// now replace it on the metadata
|
// now replace it on the metadata
|
||||||
MetaData.Builder mdBuilder = MetaData.builder().metaData(currentState.metaData());
|
MetaData.Builder mdBuilder = MetaData.builder(currentState.metaData());
|
||||||
|
|
||||||
for (String index : concreteIndices) {
|
for (String index : concreteIndices) {
|
||||||
IndexMetaData indexMetaData = metaData.index(index);
|
IndexMetaData indexMetaData = metaData.index(index);
|
||||||
|
|
|
@ -99,7 +99,7 @@ public class MetaData implements Iterable<IndexMetaData> {
|
||||||
|
|
||||||
public static final ClusterBlock CLUSTER_READ_ONLY_BLOCK = new ClusterBlock(6, "cluster read-only (api)", false, false, RestStatus.FORBIDDEN, ClusterBlockLevel.WRITE, ClusterBlockLevel.METADATA);
|
public static final ClusterBlock CLUSTER_READ_ONLY_BLOCK = new ClusterBlock(6, "cluster read-only (api)", false, false, RestStatus.FORBIDDEN, ClusterBlockLevel.WRITE, ClusterBlockLevel.METADATA);
|
||||||
|
|
||||||
public static final MetaData EMPTY_META_DATA = newMetaDataBuilder().build();
|
public static final MetaData EMPTY_META_DATA = builder().build();
|
||||||
|
|
||||||
private final long version;
|
private final long version;
|
||||||
|
|
||||||
|
@ -920,9 +920,8 @@ public class MetaData implements Iterable<IndexMetaData> {
|
||||||
return new Builder();
|
return new Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Builder builder(MetaData metaData) {
|
||||||
public static Builder newMetaDataBuilder() {
|
return new Builder(metaData);
|
||||||
return new Builder();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
|
@ -933,19 +932,20 @@ public class MetaData implements Iterable<IndexMetaData> {
|
||||||
private Settings persistentSettings = ImmutableSettings.Builder.EMPTY_SETTINGS;
|
private Settings persistentSettings = ImmutableSettings.Builder.EMPTY_SETTINGS;
|
||||||
|
|
||||||
private MapBuilder<String, IndexMetaData> indices = newMapBuilder();
|
private MapBuilder<String, IndexMetaData> indices = newMapBuilder();
|
||||||
|
|
||||||
private MapBuilder<String, IndexTemplateMetaData> templates = newMapBuilder();
|
private MapBuilder<String, IndexTemplateMetaData> templates = newMapBuilder();
|
||||||
|
|
||||||
private MapBuilder<String, Custom> customs = newMapBuilder();
|
private MapBuilder<String, Custom> customs = newMapBuilder();
|
||||||
|
|
||||||
public Builder metaData(MetaData metaData) {
|
public Builder() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder(MetaData metaData) {
|
||||||
this.transientSettings = metaData.transientSettings;
|
this.transientSettings = metaData.transientSettings;
|
||||||
this.persistentSettings = metaData.persistentSettings;
|
this.persistentSettings = metaData.persistentSettings;
|
||||||
this.version = metaData.version;
|
this.version = metaData.version;
|
||||||
this.indices.putAll(metaData.indices);
|
this.indices.putAll(metaData.indices);
|
||||||
this.templates.putAll(metaData.templates);
|
this.templates.putAll(metaData.templates);
|
||||||
this.customs.putAll(metaData.customs);
|
this.customs.putAll(metaData.customs);
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder put(IndexMetaData.Builder indexMetaDataBuilder) {
|
public Builder put(IndexMetaData.Builder indexMetaDataBuilder) {
|
||||||
|
|
|
@ -76,7 +76,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import static com.google.common.collect.Maps.newHashMap;
|
import static com.google.common.collect.Maps.newHashMap;
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.*;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -311,8 +310,7 @@ public class MetaDataCreateIndexService extends AbstractComponent {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaData newMetaData = newMetaDataBuilder()
|
MetaData newMetaData = MetaData.builder(currentState.metaData())
|
||||||
.metaData(currentState.metaData())
|
|
||||||
.put(indexMetaData, false)
|
.put(indexMetaData, false)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -126,8 +125,7 @@ public class MetaDataDeleteIndexService extends AbstractComponent {
|
||||||
RoutingTable.Builder routingTableBuilder = RoutingTable.builder().routingTable(currentState.routingTable());
|
RoutingTable.Builder routingTableBuilder = RoutingTable.builder().routingTable(currentState.routingTable());
|
||||||
routingTableBuilder.remove(request.index);
|
routingTableBuilder.remove(request.index);
|
||||||
|
|
||||||
MetaData newMetaData = newMetaDataBuilder()
|
MetaData newMetaData = MetaData.builder(currentState.metaData())
|
||||||
.metaData(currentState.metaData())
|
|
||||||
.remove(request.index)
|
.remove(request.index)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,6 @@ import java.util.Map;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -103,7 +102,7 @@ public class MetaDataIndexAliasesService extends AbstractComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
MetaData.Builder builder = newMetaDataBuilder().metaData(currentState.metaData());
|
MetaData.Builder builder = MetaData.builder(currentState.metaData());
|
||||||
for (AliasAction aliasAction : request.actions) {
|
for (AliasAction aliasAction : request.actions) {
|
||||||
IndexMetaData indexMetaData = builder.get(aliasAction.index());
|
IndexMetaData indexMetaData = builder.get(aliasAction.index());
|
||||||
if (indexMetaData == null) {
|
if (indexMetaData == null) {
|
||||||
|
|
|
@ -113,8 +113,7 @@ public class MetaDataIndexStateService extends AbstractComponent {
|
||||||
|
|
||||||
logger.info("closing indices [{}]", indicesAsString);
|
logger.info("closing indices [{}]", indicesAsString);
|
||||||
|
|
||||||
MetaData.Builder mdBuilder = MetaData.builder()
|
MetaData.Builder mdBuilder = MetaData.builder(currentState.metaData());
|
||||||
.metaData(currentState.metaData());
|
|
||||||
ClusterBlocks.Builder blocksBuilder = ClusterBlocks.builder()
|
ClusterBlocks.Builder blocksBuilder = ClusterBlocks.builder()
|
||||||
.blocks(currentState.blocks());
|
.blocks(currentState.blocks());
|
||||||
for (String index : indicesToClose) {
|
for (String index : indicesToClose) {
|
||||||
|
@ -185,8 +184,7 @@ public class MetaDataIndexStateService extends AbstractComponent {
|
||||||
|
|
||||||
logger.info("opening indices [{}]", indicesAsString);
|
logger.info("opening indices [{}]", indicesAsString);
|
||||||
|
|
||||||
MetaData.Builder mdBuilder = MetaData.builder()
|
MetaData.Builder mdBuilder = MetaData.builder(currentState.metaData());
|
||||||
.metaData(currentState.metaData());
|
|
||||||
ClusterBlocks.Builder blocksBuilder = ClusterBlocks.builder()
|
ClusterBlocks.Builder blocksBuilder = ClusterBlocks.builder()
|
||||||
.blocks(currentState.blocks());
|
.blocks(currentState.blocks());
|
||||||
for (String index : indicesToOpen) {
|
for (String index : indicesToOpen) {
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class MetaDataIndexTemplateService extends AbstractComponent {
|
||||||
}
|
}
|
||||||
throw new IndexTemplateMissingException(request.name);
|
throw new IndexTemplateMissingException(request.name);
|
||||||
}
|
}
|
||||||
MetaData.Builder metaData = MetaData.builder().metaData(currentState.metaData());
|
MetaData.Builder metaData = MetaData.builder(currentState.metaData());
|
||||||
for (String templateName : templateNames) {
|
for (String templateName : templateNames) {
|
||||||
metaData.removeTemplate(templateName);
|
metaData.removeTemplate(templateName);
|
||||||
}
|
}
|
||||||
|
@ -161,8 +161,7 @@ public class MetaDataIndexTemplateService extends AbstractComponent {
|
||||||
if (request.create && currentState.metaData().templates().containsKey(request.name)) {
|
if (request.create && currentState.metaData().templates().containsKey(request.name)) {
|
||||||
throw new IndexTemplateAlreadyExistsException(request.name);
|
throw new IndexTemplateAlreadyExistsException(request.name);
|
||||||
}
|
}
|
||||||
MetaData.Builder builder = MetaData.builder().metaData(currentState.metaData())
|
MetaData.Builder builder = MetaData.builder(currentState.metaData()).put(template);
|
||||||
.put(template);
|
|
||||||
|
|
||||||
return ClusterState.builder().state(currentState).metaData(builder).build();
|
return ClusterState.builder().state(currentState).metaData(builder).build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,6 @@ import java.util.concurrent.BlockingQueue;
|
||||||
import static com.google.common.collect.Maps.newHashMap;
|
import static com.google.common.collect.Maps.newHashMap;
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.index.mapper.DocumentMapper.MergeFlags.mergeFlags;
|
import static org.elasticsearch.index.mapper.DocumentMapper.MergeFlags.mergeFlags;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -142,7 +141,7 @@ public class MetaDataMappingService extends AbstractComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean dirty = false;
|
boolean dirty = false;
|
||||||
MetaData.Builder mdBuilder = newMetaDataBuilder().metaData(currentState.metaData());
|
MetaData.Builder mdBuilder = MetaData.builder(currentState.metaData());
|
||||||
for (Map.Entry<String, List<MappingTask>> entry : tasksPerIndex.entrySet()) {
|
for (Map.Entry<String, List<MappingTask>> entry : tasksPerIndex.entrySet()) {
|
||||||
String index = entry.getKey();
|
String index = entry.getKey();
|
||||||
List<MappingTask> tasks = entry.getValue();
|
List<MappingTask> tasks = entry.getValue();
|
||||||
|
@ -334,7 +333,7 @@ public class MetaDataMappingService extends AbstractComponent {
|
||||||
throw new IndexMissingException(new Index("_all"));
|
throw new IndexMissingException(new Index("_all"));
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaData.Builder builder = newMetaDataBuilder().metaData(currentState.metaData());
|
MetaData.Builder builder = MetaData.builder(currentState.metaData());
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
String latestIndexWithout = null;
|
String latestIndexWithout = null;
|
||||||
for (String indexName : request.indices()) {
|
for (String indexName : request.indices()) {
|
||||||
|
@ -492,7 +491,7 @@ public class MetaDataMappingService extends AbstractComponent {
|
||||||
return currentState;
|
return currentState;
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaData.Builder builder = newMetaDataBuilder().metaData(currentState.metaData());
|
MetaData.Builder builder = MetaData.builder(currentState.metaData());
|
||||||
for (String indexName : request.indices) {
|
for (String indexName : request.indices) {
|
||||||
IndexMetaData indexMetaData = currentState.metaData().index(indexName);
|
IndexMetaData indexMetaData = currentState.metaData().index(indexName);
|
||||||
if (indexMetaData == null) {
|
if (indexMetaData == null) {
|
||||||
|
|
|
@ -232,7 +232,7 @@ public class MetaDataUpdateSettingsService extends AbstractComponent implements
|
||||||
public ClusterState execute(ClusterState currentState) {
|
public ClusterState execute(ClusterState currentState) {
|
||||||
String[] actualIndices = currentState.metaData().concreteIndices(request.indices());
|
String[] actualIndices = currentState.metaData().concreteIndices(request.indices());
|
||||||
RoutingTable.Builder routingTableBuilder = RoutingTable.builder().routingTable(currentState.routingTable());
|
RoutingTable.Builder routingTableBuilder = RoutingTable.builder().routingTable(currentState.routingTable());
|
||||||
MetaData.Builder metaDataBuilder = MetaData.newMetaDataBuilder().metaData(currentState.metaData());
|
MetaData.Builder metaDataBuilder = MetaData.builder(currentState.metaData());
|
||||||
|
|
||||||
// allow to change any settings to a close index, and only allow dynamic settings to be changed
|
// allow to change any settings to a close index, and only allow dynamic settings to be changed
|
||||||
// on an open index
|
// on an open index
|
||||||
|
|
|
@ -330,7 +330,7 @@ public class InternalClusterService extends AbstractLifecycleComponent<ClusterSe
|
||||||
builder.routingTable(RoutingTable.builder().routingTable(newClusterState.routingTable()).version(newClusterState.routingTable().version() + 1));
|
builder.routingTable(RoutingTable.builder().routingTable(newClusterState.routingTable()).version(newClusterState.routingTable().version() + 1));
|
||||||
}
|
}
|
||||||
if (previousClusterState.metaData() != newClusterState.metaData()) {
|
if (previousClusterState.metaData() != newClusterState.metaData()) {
|
||||||
builder.metaData(MetaData.builder().metaData(newClusterState.metaData()).version(newClusterState.metaData().version() + 1));
|
builder.metaData(MetaData.builder(newClusterState.metaData()).version(newClusterState.metaData().version() + 1));
|
||||||
}
|
}
|
||||||
newClusterState = builder.build();
|
newClusterState = builder.build();
|
||||||
|
|
||||||
|
@ -356,7 +356,7 @@ public class InternalClusterService extends AbstractLifecycleComponent<ClusterSe
|
||||||
// have a fresh instances of routing and metadata to remove the chance that version might be the same
|
// have a fresh instances of routing and metadata to remove the chance that version might be the same
|
||||||
Builder builder = ClusterState.builder().state(newClusterState);
|
Builder builder = ClusterState.builder().state(newClusterState);
|
||||||
builder.routingTable(RoutingTable.builder().routingTable(newClusterState.routingTable()));
|
builder.routingTable(RoutingTable.builder().routingTable(newClusterState.routingTable()));
|
||||||
builder.metaData(MetaData.builder().metaData(newClusterState.metaData()));
|
builder.metaData(MetaData.builder(newClusterState.metaData()));
|
||||||
newClusterState = builder.build();
|
newClusterState = builder.build();
|
||||||
logger.debug("got first state from fresh master [{}]", newClusterState.nodes().masterNodeId());
|
logger.debug("got first state from fresh master [{}]", newClusterState.nodes().masterNodeId());
|
||||||
} else if (newClusterState.version() < previousClusterState.version()) {
|
} else if (newClusterState.version() < previousClusterState.version()) {
|
||||||
|
|
|
@ -601,7 +601,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
||||||
builder.metaData(currentState.metaData());
|
builder.metaData(currentState.metaData());
|
||||||
} else {
|
} else {
|
||||||
// if its not the same version, only copy over new indices or ones that changed the version
|
// if its not the same version, only copy over new indices or ones that changed the version
|
||||||
MetaData.Builder metaDataBuilder = MetaData.builder().metaData(newState.metaData()).removeAllIndices();
|
MetaData.Builder metaDataBuilder = MetaData.builder(newState.metaData()).removeAllIndices();
|
||||||
for (IndexMetaData indexMetaData : newState.metaData()) {
|
for (IndexMetaData indexMetaData : newState.metaData()) {
|
||||||
IndexMetaData currentIndexMetaData = currentState.metaData().index(indexMetaData.index());
|
IndexMetaData currentIndexMetaData = currentState.metaData().index(indexMetaData.index());
|
||||||
if (currentIndexMetaData == null || currentIndexMetaData.version() != indexMetaData.version()) {
|
if (currentIndexMetaData == null || currentIndexMetaData.version() != indexMetaData.version()) {
|
||||||
|
|
|
@ -43,7 +43,6 @@ import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -248,8 +247,7 @@ public class GatewayService extends AbstractLifecycleComponent<GatewayService> i
|
||||||
.blocks(recoveredState.blocks())
|
.blocks(recoveredState.blocks())
|
||||||
.removeGlobalBlock(STATE_NOT_RECOVERED_BLOCK);
|
.removeGlobalBlock(STATE_NOT_RECOVERED_BLOCK);
|
||||||
|
|
||||||
MetaData.Builder metaDataBuilder = newMetaDataBuilder()
|
MetaData.Builder metaDataBuilder = MetaData.builder(recoveredState.metaData());
|
||||||
.metaData(recoveredState.metaData());
|
|
||||||
|
|
||||||
if (recoveredState.metaData().settings().getAsBoolean(MetaData.SETTING_READ_ONLY, false) || currentState.metaData().settings().getAsBoolean(MetaData.SETTING_READ_ONLY, false)) {
|
if (recoveredState.metaData().settings().getAsBoolean(MetaData.SETTING_READ_ONLY, false) || currentState.metaData().settings().getAsBoolean(MetaData.SETTING_READ_ONLY, false)) {
|
||||||
blocks.addGlobalBlock(MetaData.CLUSTER_READ_ONLY_BLOCK);
|
blocks.addGlobalBlock(MetaData.CLUSTER_READ_ONLY_BLOCK);
|
||||||
|
|
|
@ -135,7 +135,6 @@ public class LocalGateway extends AbstractLifecycleComponent<Gateway> implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaData.Builder metaDataBuilder = MetaData.builder();
|
|
||||||
ObjectFloatOpenHashMap<String> indices = new ObjectFloatOpenHashMap<String>();
|
ObjectFloatOpenHashMap<String> indices = new ObjectFloatOpenHashMap<String>();
|
||||||
MetaData electedGlobalState = null;
|
MetaData electedGlobalState = null;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
|
@ -158,7 +157,7 @@ public class LocalGateway extends AbstractLifecycleComponent<Gateway> implements
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// update the global state, and clean the indices, we elect them in the next phase
|
// update the global state, and clean the indices, we elect them in the next phase
|
||||||
metaDataBuilder.metaData(electedGlobalState).removeAllIndices();
|
MetaData.Builder metaDataBuilder = MetaData.builder(electedGlobalState).removeAllIndices();
|
||||||
final boolean[] states = indices.allocated;
|
final boolean[] states = indices.allocated;
|
||||||
final Object[] keys = indices.keys;
|
final Object[] keys = indices.keys;
|
||||||
for (int i = 0; i < states.length; i++) {
|
for (int i = 0; i < states.length; i++) {
|
||||||
|
|
|
@ -120,8 +120,7 @@ public class LocalAllocateDangledIndices extends AbstractComponent {
|
||||||
if (currentState.blocks().disableStatePersistence()) {
|
if (currentState.blocks().disableStatePersistence()) {
|
||||||
return currentState;
|
return currentState;
|
||||||
}
|
}
|
||||||
MetaData.Builder metaData = MetaData.builder()
|
MetaData.Builder metaData = MetaData.builder(currentState.metaData());
|
||||||
.metaData(currentState.metaData());
|
|
||||||
ClusterBlocks.Builder blocks = ClusterBlocks.builder().blocks(currentState.blocks());
|
ClusterBlocks.Builder blocks = ClusterBlocks.builder().blocks(currentState.blocks());
|
||||||
RoutingTable.Builder routingTableBuilder = RoutingTable.builder().routingTable(currentState.routingTable());
|
RoutingTable.Builder routingTableBuilder = RoutingTable.builder().routingTable(currentState.routingTable());
|
||||||
|
|
||||||
|
|
|
@ -387,7 +387,7 @@ public class LocalGatewayMetaState extends AbstractComponent implements ClusterS
|
||||||
private void writeGlobalState(String reason, MetaData metaData, @Nullable MetaData previousMetaData) throws Exception {
|
private void writeGlobalState(String reason, MetaData metaData, @Nullable MetaData previousMetaData) throws Exception {
|
||||||
logger.trace("[_global] writing state, reason [{}]", reason);
|
logger.trace("[_global] writing state, reason [{}]", reason);
|
||||||
// create metadata to write with just the global state
|
// create metadata to write with just the global state
|
||||||
MetaData globalMetaData = MetaData.builder().metaData(metaData).removeAllIndices().build();
|
MetaData globalMetaData = MetaData.builder(metaData).removeAllIndices().build();
|
||||||
|
|
||||||
XContentBuilder builder = XContentFactory.contentBuilder(format);
|
XContentBuilder builder = XContentFactory.contentBuilder(format);
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
|
@ -442,10 +442,12 @@ public class LocalGatewayMetaState extends AbstractComponent implements ClusterS
|
||||||
}
|
}
|
||||||
|
|
||||||
private MetaData loadState() throws Exception {
|
private MetaData loadState() throws Exception {
|
||||||
MetaData.Builder metaDataBuilder = MetaData.builder();
|
|
||||||
MetaData globalMetaData = loadGlobalState();
|
MetaData globalMetaData = loadGlobalState();
|
||||||
|
MetaData.Builder metaDataBuilder;
|
||||||
if (globalMetaData != null) {
|
if (globalMetaData != null) {
|
||||||
metaDataBuilder.metaData(globalMetaData);
|
metaDataBuilder = MetaData.builder(globalMetaData);
|
||||||
|
} else {
|
||||||
|
metaDataBuilder = MetaData.builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<String> indices = nodeEnv.findAllIndices();
|
Set<String> indices = nodeEnv.findAllIndices();
|
||||||
|
@ -618,7 +620,7 @@ public class LocalGatewayMetaState extends AbstractComponent implements ClusterS
|
||||||
|
|
||||||
logger.info("found old metadata state, loading metadata from [{}] and converting to new metadata location and strucutre...", metaDataFile.getAbsolutePath());
|
logger.info("found old metadata state, loading metadata from [{}] and converting to new metadata location and strucutre...", metaDataFile.getAbsolutePath());
|
||||||
|
|
||||||
writeGlobalState("upgrade", MetaData.builder().metaData(metaData).version(version).build(), null);
|
writeGlobalState("upgrade", MetaData.builder(metaData).version(version).build(), null);
|
||||||
for (IndexMetaData indexMetaData : metaData) {
|
for (IndexMetaData indexMetaData : metaData) {
|
||||||
IndexMetaData.Builder indexMetaDataBuilder = IndexMetaData.newIndexMetaDataBuilder(indexMetaData).version(version);
|
IndexMetaData.Builder indexMetaDataBuilder = IndexMetaData.newIndexMetaDataBuilder(indexMetaData).version(version);
|
||||||
// set the created version to 0.18
|
// set the created version to 0.18
|
||||||
|
|
|
@ -28,9 +28,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.metadata.AliasMetaData.newAliasMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.AliasMetaData.newAliasMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.nullValue;
|
import static org.hamcrest.Matchers.nullValue;
|
||||||
|
|
||||||
|
@ -41,7 +39,7 @@ public class ToAndFromJsonMetaDataTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSimpleJsonFromAndTo() throws IOException {
|
public void testSimpleJsonFromAndTo() throws IOException {
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test1")
|
.put(newIndexMetaDataBuilder("test1")
|
||||||
.numberOfShards(1)
|
.numberOfShards(1)
|
||||||
.numberOfReplicas(2))
|
.numberOfReplicas(2))
|
||||||
|
|
|
@ -19,14 +19,12 @@ import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
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.allocation.RoutingAllocationTests.newNode;
|
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
|
|
||||||
public class AddIncrementallyTests extends ElasticsearchTestCase {
|
public class AddIncrementallyTests extends ElasticsearchTestCase {
|
||||||
private final ESLogger logger = Loggers.getLogger(AddIncrementallyTests.class);
|
private final ESLogger logger = Loggers.getLogger(AddIncrementallyTests.class);
|
||||||
|
@ -271,7 +269,7 @@ public class AddIncrementallyTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
private ClusterState initCluster(AllocationService service, int numberOfNodes, int numberOfIndices, int numberOfShards,
|
private ClusterState initCluster(AllocationService service, int numberOfNodes, int numberOfIndices, int numberOfShards,
|
||||||
int numberOfReplicas) {
|
int numberOfReplicas) {
|
||||||
MetaData.Builder metaDataBuilder = newMetaDataBuilder();
|
MetaData.Builder metaDataBuilder = MetaData.builder();
|
||||||
RoutingTable.Builder routingTableBuilder = routingTable();
|
RoutingTable.Builder routingTableBuilder = routingTable();
|
||||||
|
|
||||||
for (int i = 0; i < numberOfIndices; i++) {
|
for (int i = 0; i < numberOfIndices; i++) {
|
||||||
|
@ -326,7 +324,7 @@ public class AddIncrementallyTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
private ClusterState addIndex(ClusterState clusterState, AllocationService service, int indexOrdinal, int numberOfShards,
|
private ClusterState addIndex(ClusterState clusterState, AllocationService service, int indexOrdinal, int numberOfShards,
|
||||||
int numberOfReplicas) {
|
int numberOfReplicas) {
|
||||||
MetaData.Builder metaDataBuilder = newMetaDataBuilder().metaData(clusterState.getMetaData());
|
MetaData.Builder metaDataBuilder = MetaData.builder(clusterState.getMetaData());
|
||||||
RoutingTable.Builder routingTableBuilder = routingTable().routingTable(clusterState.routingTable());
|
RoutingTable.Builder routingTableBuilder = routingTable().routingTable(clusterState.routingTable());
|
||||||
|
|
||||||
IndexMetaData.Builder index = newIndexMetaDataBuilder("test" + indexOrdinal).numberOfShards(numberOfShards).numberOfReplicas(
|
IndexMetaData.Builder index = newIndexMetaDataBuilder("test" + indexOrdinal).numberOfShards(numberOfShards).numberOfReplicas(
|
||||||
|
@ -399,7 +397,7 @@ public class AddIncrementallyTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("complete rebalancing");
|
logger.info("complete rebalancing");
|
||||||
RoutingTable prev = routingTable;
|
RoutingTable prev = routingTable;
|
||||||
while(true) {
|
while (true) {
|
||||||
routingTable = service.applyStartedShards(clusterState, routingNodes.shardsWithState(INITIALIZING)).routingTable();
|
routingTable = service.applyStartedShards(clusterState, routingNodes.shardsWithState(INITIALIZING)).routingTable();
|
||||||
clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).build();
|
clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).build();
|
||||||
routingNodes = clusterState.routingNodes();
|
routingNodes = clusterState.routingNodes();
|
||||||
|
|
|
@ -29,13 +29,11 @@ import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,7 +47,7 @@ public class AllocatePostApiFlagTests extends ElasticsearchTestCase {
|
||||||
AllocationService allocation = new AllocationService(settingsBuilder().put("cluster.routing.allocation.concurrent_recoveries", 10).build());
|
AllocationService allocation = new AllocationService(settingsBuilder().put("cluster.routing.allocation.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 = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(0))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(0))
|
||||||
.build();
|
.build();
|
||||||
RoutingTable routingTable = routingTable()
|
RoutingTable routingTable = routingTable()
|
||||||
|
|
|
@ -42,14 +42,12 @@ import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
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.allocation.RoutingAllocationTests.newNode;
|
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,7 +61,7 @@ public class AllocationCommandsTests extends ElasticsearchTestCase {
|
||||||
AllocationService allocation = new AllocationService(settingsBuilder().put("cluster.routing.allocation.concurrent_recoveries", 10).build());
|
AllocationService allocation = new AllocationService(settingsBuilder().put("cluster.routing.allocation.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 = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(0))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(0))
|
||||||
.build();
|
.build();
|
||||||
RoutingTable routingTable = routingTable()
|
RoutingTable routingTable = routingTable()
|
||||||
|
@ -110,7 +108,7 @@ public class AllocationCommandsTests extends ElasticsearchTestCase {
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
logger.info("--> building initial routing table");
|
logger.info("--> building initial routing table");
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
RoutingTable routingTable = routingTable()
|
RoutingTable routingTable = routingTable()
|
||||||
|
@ -191,7 +189,7 @@ public class AllocationCommandsTests extends ElasticsearchTestCase {
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
logger.info("--> building initial routing table");
|
logger.info("--> building initial routing table");
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
RoutingTable routingTable = routingTable()
|
RoutingTable routingTable = routingTable()
|
||||||
|
|
|
@ -32,7 +32,6 @@ import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||||
|
@ -56,7 +55,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table for 'moveShardOnceNewNodeWithAttributeAdded1'");
|
logger.info("Building initial routing table for 'moveShardOnceNewNodeWithAttributeAdded1'");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -125,7 +124,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table for 'moveShardOnceNewNodeWithAttributeAdded2'");
|
logger.info("Building initial routing table for 'moveShardOnceNewNodeWithAttributeAdded2'");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -200,7 +199,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table for 'moveShardOnceNewNodeWithAttributeAdded3'");
|
logger.info("Building initial routing table for 'moveShardOnceNewNodeWithAttributeAdded3'");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(5).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(5).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -298,7 +297,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table for 'moveShardOnceNewNodeWithAttributeAdded4'");
|
logger.info("Building initial routing table for 'moveShardOnceNewNodeWithAttributeAdded4'");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test1").numberOfShards(5).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test1").numberOfShards(5).numberOfReplicas(1))
|
||||||
.put(newIndexMetaDataBuilder("test2").numberOfShards(5).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test2").numberOfShards(5).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
@ -381,6 +380,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
||||||
logger.info("--> do another reroute, make sure nothing moves");
|
logger.info("--> do another reroute, make sure nothing moves");
|
||||||
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
|
assertThat(strategy.reroute(clusterState).routingTable(), sameInstance(clusterState.routingTable()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void moveShardOnceNewNodeWithAttributeAdded5() {
|
public void moveShardOnceNewNodeWithAttributeAdded5() {
|
||||||
AllocationService strategy = new AllocationService(settingsBuilder()
|
AllocationService strategy = new AllocationService(settingsBuilder()
|
||||||
|
@ -391,7 +391,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table for 'moveShardOnceNewNodeWithAttributeAdded5'");
|
logger.info("Building initial routing table for 'moveShardOnceNewNodeWithAttributeAdded5'");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(2))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(2))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -470,7 +470,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table for 'moveShardOnceNewNodeWithAttributeAdded6'");
|
logger.info("Building initial routing table for 'moveShardOnceNewNodeWithAttributeAdded6'");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(3))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(3))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -552,7 +552,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table for 'fullAwareness1'");
|
logger.info("Building initial routing table for 'fullAwareness1'");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -620,7 +620,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table for 'fullAwareness2'");
|
logger.info("Building initial routing table for 'fullAwareness2'");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -694,7 +694,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table for 'fullAwareness3'");
|
logger.info("Building initial routing table for 'fullAwareness3'");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test1").numberOfShards(5).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test1").numberOfShards(5).numberOfReplicas(1))
|
||||||
.put(newIndexMetaDataBuilder("test2").numberOfShards(5).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test2").numberOfShards(5).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
@ -776,7 +776,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table for 'testUnbalancedZones'");
|
logger.info("Building initial routing table for 'testUnbalancedZones'");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(5).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(5).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -817,7 +817,7 @@ public class AwarenessAllocationTests extends ElasticsearchTestCase {
|
||||||
assertThat(clusterState.routingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(8));
|
assertThat(clusterState.routingNodes().shardsWithState(ShardRoutingState.STARTED).size(), equalTo(8));
|
||||||
assertThat(clusterState.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).size(), equalTo(2));
|
assertThat(clusterState.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).size(), equalTo(2));
|
||||||
assertThat(clusterState.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), equalTo("A-1"));
|
assertThat(clusterState.routingNodes().shardsWithState(ShardRoutingState.INITIALIZING).get(0).currentNodeId(), equalTo("A-1"));
|
||||||
logger.info("--> starting inizializing shards on the new node");
|
logger.info("--> starting initializing shards on the new node");
|
||||||
|
|
||||||
routingTable = strategy.applyStartedShards(clusterState, clusterState.routingNodes().shardsWithState(INITIALIZING)).routingTable();
|
routingTable = strategy.applyStartedShards(clusterState, clusterState.routingNodes().shardsWithState(INITIALIZING)).routingTable();
|
||||||
clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).build();
|
clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).build();
|
||||||
|
|
|
@ -44,14 +44,12 @@ import java.util.List;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
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.allocation.RoutingAllocationTests.newNode;
|
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
|
|
||||||
public class BalanceConfigurationTests extends ElasticsearchTestCase {
|
public class BalanceConfigurationTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
|
@ -83,10 +81,10 @@ public class BalanceConfigurationTests extends ElasticsearchTestCase {
|
||||||
assertIndexBalance(logger, clusterState.getRoutingNodes(), numberOfNodes, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);
|
assertIndexBalance(logger, clusterState.getRoutingNodes(), numberOfNodes, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);
|
||||||
|
|
||||||
clusterState = addNode(clusterState, strategy);
|
clusterState = addNode(clusterState, strategy);
|
||||||
assertIndexBalance(logger, clusterState.getRoutingNodes(), numberOfNodes+1, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);
|
assertIndexBalance(logger, clusterState.getRoutingNodes(), numberOfNodes + 1, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);
|
||||||
|
|
||||||
clusterState = removeNodes(clusterState, strategy);
|
clusterState = removeNodes(clusterState, strategy);
|
||||||
assertIndexBalance(logger, clusterState.getRoutingNodes(), (numberOfNodes+1)-(numberOfNodes+1)/2, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);
|
assertIndexBalance(logger, clusterState.getRoutingNodes(), (numberOfNodes + 1) - (numberOfNodes + 1) / 2, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,10 +109,10 @@ public class BalanceConfigurationTests extends ElasticsearchTestCase {
|
||||||
assertReplicaBalance(logger, clusterState.getRoutingNodes(), numberOfNodes, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);
|
assertReplicaBalance(logger, clusterState.getRoutingNodes(), numberOfNodes, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);
|
||||||
|
|
||||||
clusterState = addNode(clusterState, strategy);
|
clusterState = addNode(clusterState, strategy);
|
||||||
assertReplicaBalance(logger, clusterState.getRoutingNodes(), numberOfNodes+1, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);
|
assertReplicaBalance(logger, clusterState.getRoutingNodes(), numberOfNodes + 1, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);
|
||||||
|
|
||||||
clusterState = removeNodes(clusterState, strategy);
|
clusterState = removeNodes(clusterState, strategy);
|
||||||
assertReplicaBalance(logger, clusterState.getRoutingNodes(), (numberOfNodes+1)-(numberOfNodes+1)/2, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);
|
assertReplicaBalance(logger, clusterState.getRoutingNodes(), (numberOfNodes + 1) - (numberOfNodes + 1) / 2, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,18 +137,18 @@ public class BalanceConfigurationTests extends ElasticsearchTestCase {
|
||||||
assertPrimaryBalance(logger, clusterstate.getRoutingNodes(), numberOfNodes, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);
|
assertPrimaryBalance(logger, clusterstate.getRoutingNodes(), numberOfNodes, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);
|
||||||
|
|
||||||
clusterstate = addNode(clusterstate, strategy);
|
clusterstate = addNode(clusterstate, strategy);
|
||||||
assertPrimaryBalance(logger, clusterstate.getRoutingNodes(), numberOfNodes+1, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);
|
assertPrimaryBalance(logger, clusterstate.getRoutingNodes(), numberOfNodes + 1, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);
|
||||||
|
|
||||||
clusterstate = removeNodes(clusterstate, strategy);
|
clusterstate = removeNodes(clusterstate, strategy);
|
||||||
assertPrimaryBalance(logger, clusterstate.getRoutingNodes(), numberOfNodes+1-(numberOfNodes+1)/2, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);
|
assertPrimaryBalance(logger, clusterstate.getRoutingNodes(), numberOfNodes + 1 - (numberOfNodes + 1) / 2, numberOfIndices, numberOfReplicas, numberOfShards, balanceTreshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClusterState initCluster(AllocationService strategy) {
|
private ClusterState initCluster(AllocationService strategy) {
|
||||||
MetaData.Builder metaDataBuilder = newMetaDataBuilder();
|
MetaData.Builder metaDataBuilder = MetaData.builder();
|
||||||
RoutingTable.Builder routingTableBuilder = routingTable();
|
RoutingTable.Builder routingTableBuilder = routingTable();
|
||||||
|
|
||||||
for (int i = 0; i < numberOfIndices; i++) {
|
for (int i = 0; i < numberOfIndices; i++) {
|
||||||
IndexMetaData.Builder index = newIndexMetaDataBuilder("test"+i).numberOfShards(numberOfShards).numberOfReplicas(numberOfReplicas);
|
IndexMetaData.Builder index = newIndexMetaDataBuilder("test" + i).numberOfShards(numberOfShards).numberOfReplicas(numberOfReplicas);
|
||||||
metaDataBuilder = metaDataBuilder.put(index);
|
metaDataBuilder = metaDataBuilder.put(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,10 +161,10 @@ public class BalanceConfigurationTests extends ElasticsearchTestCase {
|
||||||
RoutingTable routingTable = routingTableBuilder.build();
|
RoutingTable routingTable = routingTableBuilder.build();
|
||||||
|
|
||||||
|
|
||||||
logger.info("start "+numberOfNodes+" nodes");
|
logger.info("start " + numberOfNodes + " nodes");
|
||||||
DiscoveryNodes.Builder nodes = newNodesBuilder();
|
DiscoveryNodes.Builder nodes = newNodesBuilder();
|
||||||
for (int i = 0; i < numberOfNodes; i++) {
|
for (int i = 0; i < numberOfNodes; i++) {
|
||||||
nodes.put(newNode("node"+i));
|
nodes.put(newNode("node" + i));
|
||||||
}
|
}
|
||||||
ClusterState clusterState = newClusterStateBuilder().nodes(nodes).metaData(metaData).routingTable(routingTable).build();
|
ClusterState clusterState = newClusterStateBuilder().nodes(nodes).metaData(metaData).routingTable(routingTable).build();
|
||||||
routingTable = strategy.reroute(clusterState).routingTable();
|
routingTable = strategy.reroute(clusterState).routingTable();
|
||||||
|
@ -187,7 +185,7 @@ public class BalanceConfigurationTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("complete rebalancing");
|
logger.info("complete rebalancing");
|
||||||
RoutingTable prev = routingTable;
|
RoutingTable prev = routingTable;
|
||||||
while(true) {
|
while (true) {
|
||||||
routingTable = strategy.applyStartedShards(clusterState, routingNodes.shardsWithState(INITIALIZING)).routingTable();
|
routingTable = strategy.applyStartedShards(clusterState, routingNodes.shardsWithState(INITIALIZING)).routingTable();
|
||||||
clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).build();
|
clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).build();
|
||||||
routingNodes = clusterState.routingNodes();
|
routingNodes = clusterState.routingNodes();
|
||||||
|
@ -202,7 +200,7 @@ public class BalanceConfigurationTests extends ElasticsearchTestCase {
|
||||||
private ClusterState addNode(ClusterState clusterState, AllocationService strategy) {
|
private ClusterState addNode(ClusterState clusterState, AllocationService strategy) {
|
||||||
logger.info("now, start 1 more node, check that rebalancing will happen because we set it to always");
|
logger.info("now, start 1 more node, check that rebalancing will happen because we set it to always");
|
||||||
clusterState = newClusterStateBuilder().state(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
clusterState = newClusterStateBuilder().state(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes())
|
||||||
.put(newNode("node"+numberOfNodes)))
|
.put(newNode("node" + numberOfNodes)))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
RoutingTable routingTable = strategy.reroute(clusterState).routingTable();
|
RoutingTable routingTable = strategy.reroute(clusterState).routingTable();
|
||||||
|
@ -212,7 +210,7 @@ public class BalanceConfigurationTests extends ElasticsearchTestCase {
|
||||||
// move initializing to started
|
// move initializing to started
|
||||||
|
|
||||||
RoutingTable prev = routingTable;
|
RoutingTable prev = routingTable;
|
||||||
while(true) {
|
while (true) {
|
||||||
routingTable = strategy.applyStartedShards(clusterState, routingNodes.shardsWithState(INITIALIZING)).routingTable();
|
routingTable = strategy.applyStartedShards(clusterState, routingNodes.shardsWithState(INITIALIZING)).routingTable();
|
||||||
clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).build();
|
clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).build();
|
||||||
routingNodes = clusterState.routingNodes();
|
routingNodes = clusterState.routingNodes();
|
||||||
|
@ -225,11 +223,11 @@ public class BalanceConfigurationTests extends ElasticsearchTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClusterState removeNodes(ClusterState clusterState, AllocationService strategy) {
|
private ClusterState removeNodes(ClusterState clusterState, AllocationService strategy) {
|
||||||
logger.info("Removing half the nodes ("+(numberOfNodes+1)/2+")");
|
logger.info("Removing half the nodes (" + (numberOfNodes + 1) / 2 + ")");
|
||||||
DiscoveryNodes.Builder nodes = newNodesBuilder().putAll(clusterState.nodes());
|
DiscoveryNodes.Builder nodes = newNodesBuilder().putAll(clusterState.nodes());
|
||||||
|
|
||||||
for(int i=(numberOfNodes+1)/2; i<=numberOfNodes; i++){
|
for (int i = (numberOfNodes + 1) / 2; i <= numberOfNodes; i++) {
|
||||||
nodes.remove("node"+i);
|
nodes.remove("node" + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
clusterState = newClusterStateBuilder().state(clusterState).nodes(nodes.build()).build();
|
clusterState = newClusterStateBuilder().state(clusterState).nodes(nodes.build()).build();
|
||||||
|
@ -252,7 +250,7 @@ public class BalanceConfigurationTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("complete rebalancing");
|
logger.info("complete rebalancing");
|
||||||
RoutingTable prev = routingTable;
|
RoutingTable prev = routingTable;
|
||||||
while(true) {
|
while (true) {
|
||||||
routingTable = strategy.applyStartedShards(clusterState, routingNodes.shardsWithState(INITIALIZING)).routingTable();
|
routingTable = strategy.applyStartedShards(clusterState, routingNodes.shardsWithState(INITIALIZING)).routingTable();
|
||||||
clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).build();
|
clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).build();
|
||||||
routingNodes = clusterState.routingNodes();
|
routingNodes = clusterState.routingNodes();
|
||||||
|
@ -266,10 +264,10 @@ public class BalanceConfigurationTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
|
|
||||||
private void assertReplicaBalance(ESLogger logger, RoutingNodes nodes, int numberOfNodes, int numberOfIndices, int numberOfReplicas, int numberOfShards, float treshold) {
|
private void assertReplicaBalance(ESLogger logger, RoutingNodes nodes, int numberOfNodes, int numberOfIndices, int numberOfReplicas, int numberOfShards, float treshold) {
|
||||||
final int numShards = numberOfIndices * numberOfShards * (numberOfReplicas+1);
|
final int numShards = numberOfIndices * numberOfShards * (numberOfReplicas + 1);
|
||||||
final float avgNumShards = (float)(numShards) / (float)(numberOfNodes);
|
final float avgNumShards = (float) (numShards) / (float) (numberOfNodes);
|
||||||
final int minAvgNumberOfShards = Math.round(Math.round(Math.floor(avgNumShards-treshold)));
|
final int minAvgNumberOfShards = Math.round(Math.round(Math.floor(avgNumShards - treshold)));
|
||||||
final int maxAvgNumberOfShards = Math.round(Math.round(Math.ceil(avgNumShards+treshold)));
|
final int maxAvgNumberOfShards = Math.round(Math.round(Math.ceil(avgNumShards + treshold)));
|
||||||
|
|
||||||
for (RoutingNode node : nodes) {
|
for (RoutingNode node : nodes) {
|
||||||
// logger.info(node.nodeId() + ": " + node.shardsWithState(INITIALIZING, STARTED).size() + " shards ("+minAvgNumberOfShards+" to "+maxAvgNumberOfShards+")");
|
// logger.info(node.nodeId() + ": " + node.shardsWithState(INITIALIZING, STARTED).size() + " shards ("+minAvgNumberOfShards+" to "+maxAvgNumberOfShards+")");
|
||||||
|
@ -280,12 +278,12 @@ public class BalanceConfigurationTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
private void assertIndexBalance(ESLogger logger, RoutingNodes nodes, int numberOfNodes, int numberOfIndices, int numberOfReplicas, int numberOfShards, float treshold) {
|
private void assertIndexBalance(ESLogger logger, RoutingNodes nodes, int numberOfNodes, int numberOfIndices, int numberOfReplicas, int numberOfShards, float treshold) {
|
||||||
|
|
||||||
final int numShards = numberOfShards * (numberOfReplicas+1);
|
final int numShards = numberOfShards * (numberOfReplicas + 1);
|
||||||
final float avgNumShards = (float)(numShards) / (float)(numberOfNodes);
|
final float avgNumShards = (float) (numShards) / (float) (numberOfNodes);
|
||||||
final int minAvgNumberOfShards = Math.round(Math.round(Math.floor(avgNumShards-treshold)));
|
final int minAvgNumberOfShards = Math.round(Math.round(Math.floor(avgNumShards - treshold)));
|
||||||
final int maxAvgNumberOfShards = Math.round(Math.round(Math.ceil(avgNumShards+treshold)));
|
final int maxAvgNumberOfShards = Math.round(Math.round(Math.ceil(avgNumShards + treshold)));
|
||||||
|
|
||||||
for(String index : nodes.getRoutingTable().indicesRouting().keySet()) {
|
for (String index : nodes.getRoutingTable().indicesRouting().keySet()) {
|
||||||
for (RoutingNode node : nodes) {
|
for (RoutingNode node : nodes) {
|
||||||
// logger.info(node.nodeId() +":"+index+ ": " + node.shardsWithState(index, INITIALIZING, STARTED).size() + " shards ("+minAvgNumberOfShards+" to "+maxAvgNumberOfShards+")");
|
// logger.info(node.nodeId() +":"+index+ ": " + node.shardsWithState(index, INITIALIZING, STARTED).size() + " shards ("+minAvgNumberOfShards+" to "+maxAvgNumberOfShards+")");
|
||||||
assertThat(node.shardsWithState(index, STARTED).size(), Matchers.greaterThanOrEqualTo(minAvgNumberOfShards));
|
assertThat(node.shardsWithState(index, STARTED).size(), Matchers.greaterThanOrEqualTo(minAvgNumberOfShards));
|
||||||
|
@ -297,15 +295,15 @@ public class BalanceConfigurationTests extends ElasticsearchTestCase {
|
||||||
private void assertPrimaryBalance(ESLogger logger, RoutingNodes nodes, int numberOfNodes, int numberOfIndices, int numberOfReplicas, int numberOfShards, float treshold) {
|
private void assertPrimaryBalance(ESLogger logger, RoutingNodes nodes, int numberOfNodes, int numberOfIndices, int numberOfReplicas, int numberOfShards, float treshold) {
|
||||||
|
|
||||||
final int numShards = numberOfShards;
|
final int numShards = numberOfShards;
|
||||||
final float avgNumShards = (float)(numShards) / (float)(numberOfNodes);
|
final float avgNumShards = (float) (numShards) / (float) (numberOfNodes);
|
||||||
final int minAvgNumberOfShards = Math.round(Math.round(Math.floor(avgNumShards-treshold)));
|
final int minAvgNumberOfShards = Math.round(Math.round(Math.floor(avgNumShards - treshold)));
|
||||||
final int maxAvgNumberOfShards = Math.round(Math.round(Math.ceil(avgNumShards+treshold)));
|
final int maxAvgNumberOfShards = Math.round(Math.round(Math.ceil(avgNumShards + treshold)));
|
||||||
|
|
||||||
for(String index : nodes.getRoutingTable().indicesRouting().keySet()) {
|
for (String index : nodes.getRoutingTable().indicesRouting().keySet()) {
|
||||||
for (RoutingNode node : nodes) {
|
for (RoutingNode node : nodes) {
|
||||||
int primaries = 0;
|
int primaries = 0;
|
||||||
for(ShardRouting shard : node.shardsWithState(index, STARTED)) {
|
for (ShardRouting shard : node.shardsWithState(index, STARTED)) {
|
||||||
primaries += shard.primary()?1:0;
|
primaries += shard.primary() ? 1 : 0;
|
||||||
}
|
}
|
||||||
// logger.info(node.nodeId() + ": " + primaries + " primaries ("+minAvgNumberOfShards+" to "+maxAvgNumberOfShards+")");
|
// logger.info(node.nodeId() + ": " + primaries + " primaries ("+minAvgNumberOfShards+" to "+maxAvgNumberOfShards+")");
|
||||||
assertThat(primaries, Matchers.greaterThanOrEqualTo(minAvgNumberOfShards));
|
assertThat(primaries, Matchers.greaterThanOrEqualTo(minAvgNumberOfShards));
|
||||||
|
@ -454,7 +452,7 @@ public class BalanceConfigurationTests extends ElasticsearchTestCase {
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
}), ClusterInfoService.EMPTY);
|
}), ClusterInfoService.EMPTY);
|
||||||
MetaData.Builder metaDataBuilder = newMetaDataBuilder();
|
MetaData.Builder metaDataBuilder = MetaData.builder();
|
||||||
RoutingTable.Builder routingTableBuilder = routingTable();
|
RoutingTable.Builder routingTableBuilder = routingTable();
|
||||||
IndexMetaData.Builder indexMeta = newIndexMetaDataBuilder("test").numberOfShards(5).numberOfReplicas(1);
|
IndexMetaData.Builder indexMeta = newIndexMetaDataBuilder("test").numberOfShards(5).numberOfReplicas(1);
|
||||||
metaDataBuilder = metaDataBuilder.put(indexMeta);
|
metaDataBuilder = metaDataBuilder.put(indexMeta);
|
||||||
|
@ -465,7 +463,7 @@ public class BalanceConfigurationTests extends ElasticsearchTestCase {
|
||||||
RoutingTable routingTable = routingTableBuilder.build();
|
RoutingTable routingTable = routingTableBuilder.build();
|
||||||
DiscoveryNodes.Builder nodes = newNodesBuilder();
|
DiscoveryNodes.Builder nodes = newNodesBuilder();
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
DiscoveryNode node = newNode("node"+i);
|
DiscoveryNode node = newNode("node" + i);
|
||||||
nodes.put(node);
|
nodes.put(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,13 +31,11 @@ import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
public class ClusterRebalanceRoutingTests extends ElasticsearchTestCase {
|
public class ClusterRebalanceRoutingTests extends ElasticsearchTestCase {
|
||||||
|
@ -48,7 +46,7 @@ public class ClusterRebalanceRoutingTests extends ElasticsearchTestCase {
|
||||||
public void testAlways() {
|
public void testAlways() {
|
||||||
AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()).build());
|
AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()).build());
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(1))
|
||||||
.put(newIndexMetaDataBuilder("test2").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test2").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
@ -134,7 +132,7 @@ public class ClusterRebalanceRoutingTests extends ElasticsearchTestCase {
|
||||||
public void testClusterPrimariesActive1() {
|
public void testClusterPrimariesActive1() {
|
||||||
AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_PRIMARIES_ACTIVE.toString()).build());
|
AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_PRIMARIES_ACTIVE.toString()).build());
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(1))
|
||||||
.put(newIndexMetaDataBuilder("test2").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test2").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
@ -238,7 +236,7 @@ public class ClusterRebalanceRoutingTests extends ElasticsearchTestCase {
|
||||||
public void testClusterPrimariesActive2() {
|
public void testClusterPrimariesActive2() {
|
||||||
AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_PRIMARIES_ACTIVE.toString()).build());
|
AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_PRIMARIES_ACTIVE.toString()).build());
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(1))
|
||||||
.put(newIndexMetaDataBuilder("test2").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test2").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
@ -322,7 +320,7 @@ public class ClusterRebalanceRoutingTests extends ElasticsearchTestCase {
|
||||||
public void testClusterAllActive1() {
|
public void testClusterAllActive1() {
|
||||||
AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_ALL_ACTIVE.toString()).build());
|
AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_ALL_ACTIVE.toString()).build());
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(1))
|
||||||
.put(newIndexMetaDataBuilder("test2").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test2").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
@ -445,7 +443,7 @@ public class ClusterRebalanceRoutingTests extends ElasticsearchTestCase {
|
||||||
public void testClusterAllActive2() {
|
public void testClusterAllActive2() {
|
||||||
AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_ALL_ACTIVE.toString()).build());
|
AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_ALL_ACTIVE.toString()).build());
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(1))
|
||||||
.put(newIndexMetaDataBuilder("test2").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test2").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
@ -529,7 +527,7 @@ public class ClusterRebalanceRoutingTests extends ElasticsearchTestCase {
|
||||||
public void testClusterAllActive3() {
|
public void testClusterAllActive3() {
|
||||||
AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_ALL_ACTIVE.toString()).build());
|
AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.INDICES_ALL_ACTIVE.toString()).build());
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(1))
|
||||||
.put(newIndexMetaDataBuilder("test2").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test2").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -30,13 +30,11 @@ import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.nullValue;
|
import static org.hamcrest.Matchers.nullValue;
|
||||||
|
|
||||||
|
@ -53,7 +51,7 @@ public class ConcurrentRebalanceRoutingTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(5).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(5).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -31,13 +31,11 @@ import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,7 +52,7 @@ public class DeadNodesAllocationTests extends ElasticsearchTestCase {
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
logger.info("--> building initial routing table");
|
logger.info("--> building initial routing table");
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
RoutingTable routingTable = routingTable()
|
RoutingTable routingTable = routingTable()
|
||||||
|
@ -106,7 +104,7 @@ public class DeadNodesAllocationTests extends ElasticsearchTestCase {
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
logger.info("--> building initial routing table");
|
logger.info("--> building initial routing table");
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
RoutingTable routingTable = routingTable()
|
RoutingTable routingTable = routingTable()
|
||||||
|
@ -181,7 +179,7 @@ public class DeadNodesAllocationTests extends ElasticsearchTestCase {
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
logger.info("--> building initial routing table");
|
logger.info("--> building initial routing table");
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
RoutingTable routingTable = routingTable()
|
RoutingTable routingTable = routingTable()
|
||||||
|
|
|
@ -31,14 +31,12 @@ import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
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.allocation.RoutingAllocationTests.newNode;
|
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,7 +54,7 @@ public class DisableAllocationTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -85,7 +83,7 @@ public class DisableAllocationTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -116,7 +114,7 @@ public class DisableAllocationTests extends ElasticsearchTestCase {
|
||||||
AllocationService strategy = new AllocationService(settingsBuilder()
|
AllocationService strategy = new AllocationService(settingsBuilder()
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("disabled").settings(ImmutableSettings.builder().put(DisableAllocationDecider.INDEX_ROUTING_ALLOCATION_DISABLE_ALLOCATION, true).put(DisableAllocationDecider.INDEX_ROUTING_ALLOCATION_DISABLE_NEW_ALLOCATION, true)).numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("disabled").settings(ImmutableSettings.builder().put(DisableAllocationDecider.INDEX_ROUTING_ALLOCATION_DISABLE_ALLOCATION, true).put(DisableAllocationDecider.INDEX_ROUTING_ALLOCATION_DISABLE_NEW_ALLOCATION, true)).numberOfShards(1).numberOfReplicas(1))
|
||||||
.put(newIndexMetaDataBuilder("enabled").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("enabled").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -31,14 +31,12 @@ import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
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.allocation.RoutingAllocationTests.newNode;
|
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,7 +52,7 @@ public class ElectReplicaAsPrimaryDuringRelocationTests extends ElasticsearchTes
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(2).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(2).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -32,14 +32,12 @@ import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
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.allocation.RoutingAllocationTests.newNode;
|
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
public class FailedNodeRoutingTests extends ElasticsearchTestCase {
|
public class FailedNodeRoutingTests extends ElasticsearchTestCase {
|
||||||
|
@ -50,7 +48,7 @@ public class FailedNodeRoutingTests extends ElasticsearchTestCase {
|
||||||
public void simpleFailedNodeTest() {
|
public void simpleFailedNodeTest() {
|
||||||
AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()).build());
|
AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()).build());
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(1))
|
||||||
.put(newIndexMetaDataBuilder("test2").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test2").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
@ -110,7 +108,7 @@ public class FailedNodeRoutingTests extends ElasticsearchTestCase {
|
||||||
public void simpleFailedNodeTestNoReassign() {
|
public void simpleFailedNodeTestNoReassign() {
|
||||||
AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()).build());
|
AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()).build());
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(1))
|
||||||
.put(newIndexMetaDataBuilder("test2").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test2").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -34,13 +34,11 @@ import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.*;
|
import static org.hamcrest.Matchers.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,7 +56,7 @@ public class FailedShardsRoutingTests extends ElasticsearchTestCase {
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
logger.info("--> building initial routing table");
|
logger.info("--> building initial routing table");
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
RoutingTable routingTable = routingTable()
|
RoutingTable routingTable = routingTable()
|
||||||
|
@ -148,7 +146,7 @@ public class FailedShardsRoutingTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -229,7 +227,7 @@ public class FailedShardsRoutingTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -286,7 +284,7 @@ public class FailedShardsRoutingTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -343,7 +341,7 @@ public class FailedShardsRoutingTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(2).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(2).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -35,13 +35,11 @@ import java.util.List;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,7 +57,7 @@ public class FilterRoutingTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(2).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(2).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -103,7 +101,7 @@ public class FilterRoutingTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").settings(settingsBuilder()
|
.put(newIndexMetaDataBuilder("test").settings(settingsBuilder()
|
||||||
.put("index.number_of_shards", 2)
|
.put("index.number_of_shards", 2)
|
||||||
.put("index.number_of_replicas", 1)
|
.put("index.number_of_replicas", 1)
|
||||||
|
@ -146,7 +144,7 @@ public class FilterRoutingTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("--> switch between value2 and value4, shards should be relocating");
|
logger.info("--> switch between value2 and value4, shards should be relocating");
|
||||||
|
|
||||||
metaData = newMetaDataBuilder()
|
metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").settings(settingsBuilder()
|
.put(newIndexMetaDataBuilder("test").settings(settingsBuilder()
|
||||||
.put("index.number_of_shards", 2)
|
.put("index.number_of_shards", 2)
|
||||||
.put("index.number_of_replicas", 1)
|
.put("index.number_of_replicas", 1)
|
||||||
|
|
|
@ -32,13 +32,11 @@ import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.nullValue;
|
import static org.hamcrest.Matchers.nullValue;
|
||||||
|
|
||||||
|
@ -59,7 +57,7 @@ public class IndexBalanceTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder().put(newIndexMetaDataBuilder("test").numberOfShards(3).numberOfReplicas(1))
|
MetaData metaData = MetaData.builder().put(newIndexMetaDataBuilder("test").numberOfShards(3).numberOfReplicas(1))
|
||||||
.put(newIndexMetaDataBuilder("test1").numberOfShards(3).numberOfReplicas(1)).build();
|
.put(newIndexMetaDataBuilder("test1").numberOfShards(3).numberOfReplicas(1)).build();
|
||||||
|
|
||||||
RoutingTable routingTable = routingTable().addAsNew(metaData.index("test")).addAsNew(metaData.index("test1")).build();
|
RoutingTable routingTable = routingTable().addAsNew(metaData.index("test")).addAsNew(metaData.index("test1")).build();
|
||||||
|
@ -190,7 +188,7 @@ public class IndexBalanceTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder().put(newIndexMetaDataBuilder("test").numberOfShards(3).numberOfReplicas(1))
|
MetaData metaData = MetaData.builder().put(newIndexMetaDataBuilder("test").numberOfShards(3).numberOfReplicas(1))
|
||||||
.put(newIndexMetaDataBuilder("test1").numberOfShards(3).numberOfReplicas(1)).build();
|
.put(newIndexMetaDataBuilder("test1").numberOfShards(3).numberOfReplicas(1)).build();
|
||||||
|
|
||||||
RoutingTable routingTable = routingTable().addAsNew(metaData.index("test")).addAsNew(metaData.index("test1")).build();
|
RoutingTable routingTable = routingTable().addAsNew(metaData.index("test")).addAsNew(metaData.index("test1")).build();
|
||||||
|
@ -353,7 +351,7 @@ public class IndexBalanceTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder().put(newIndexMetaDataBuilder("test").numberOfShards(3).numberOfReplicas(1)).build();
|
MetaData metaData = MetaData.builder().put(newIndexMetaDataBuilder("test").numberOfShards(3).numberOfReplicas(1)).build();
|
||||||
|
|
||||||
RoutingTable routingTable = routingTable().addAsNew(metaData.index("test")).build();
|
RoutingTable routingTable = routingTable().addAsNew(metaData.index("test")).build();
|
||||||
|
|
||||||
|
@ -451,7 +449,7 @@ public class IndexBalanceTests extends ElasticsearchTestCase {
|
||||||
logger.info("Add new index 3 shards 1 replica");
|
logger.info("Add new index 3 shards 1 replica");
|
||||||
|
|
||||||
prevRoutingTable = routingTable;
|
prevRoutingTable = routingTable;
|
||||||
metaData = newMetaDataBuilder().metaData(metaData)
|
metaData = MetaData.builder(metaData)
|
||||||
.put(newIndexMetaDataBuilder("test1").settings(ImmutableSettings.settingsBuilder()
|
.put(newIndexMetaDataBuilder("test1").settings(ImmutableSettings.settingsBuilder()
|
||||||
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 3)
|
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 3)
|
||||||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1)
|
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1)
|
||||||
|
|
|
@ -29,7 +29,6 @@ import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||||
|
@ -53,7 +52,7 @@ public class PreferPrimaryAllocationTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("create several indices with no replicas, and wait till all are allocated");
|
logger.info("create several indices with no replicas, and wait till all are allocated");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test1").numberOfShards(10).numberOfReplicas(0))
|
.put(newIndexMetaDataBuilder("test1").numberOfShards(10).numberOfReplicas(0))
|
||||||
.put(newIndexMetaDataBuilder("test2").numberOfShards(10).numberOfReplicas(0))
|
.put(newIndexMetaDataBuilder("test2").numberOfShards(10).numberOfReplicas(0))
|
||||||
.build();
|
.build();
|
||||||
|
@ -77,7 +76,7 @@ public class PreferPrimaryAllocationTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("increasing the number of replicas to 1, and perform a reroute (to get the replicas allocation going)");
|
logger.info("increasing the number of replicas to 1, and perform a reroute (to get the replicas allocation going)");
|
||||||
routingTable = RoutingTable.builder().routingTable(routingTable).updateNumberOfReplicas(1).build();
|
routingTable = RoutingTable.builder().routingTable(routingTable).updateNumberOfReplicas(1).build();
|
||||||
metaData = MetaData.newMetaDataBuilder().metaData(clusterState.metaData()).updateNumberOfReplicas(1).build();
|
metaData = MetaData.builder(clusterState.metaData()).updateNumberOfReplicas(1).build();
|
||||||
clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).metaData(metaData).build();
|
clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).metaData(metaData).build();
|
||||||
|
|
||||||
routingTable = strategy.reroute(clusterState).routingTable();
|
routingTable = strategy.reroute(clusterState).routingTable();
|
||||||
|
@ -87,7 +86,7 @@ public class PreferPrimaryAllocationTests extends ElasticsearchTestCase {
|
||||||
assertThat(clusterState.routingNodes().shardsWithState(INITIALIZING).size(), equalTo(2));
|
assertThat(clusterState.routingNodes().shardsWithState(INITIALIZING).size(), equalTo(2));
|
||||||
|
|
||||||
logger.info("create a new index");
|
logger.info("create a new index");
|
||||||
metaData = newMetaDataBuilder().metaData(clusterState.metaData())
|
metaData = MetaData.builder(clusterState.metaData())
|
||||||
.put(newIndexMetaDataBuilder("new_index").numberOfShards(4).numberOfReplicas(0))
|
.put(newIndexMetaDataBuilder("new_index").numberOfShards(4).numberOfReplicas(0))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -30,14 +30,12 @@ import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
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.allocation.RoutingAllocationTests.newNode;
|
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.nullValue;
|
import static org.hamcrest.Matchers.nullValue;
|
||||||
|
|
||||||
|
@ -54,7 +52,7 @@ public class PrimaryElectionRoutingTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -105,7 +103,7 @@ public class PrimaryElectionRoutingTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(2).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(2).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -30,14 +30,12 @@ import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
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.allocation.RoutingAllocationTests.newNode;
|
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,7 +55,7 @@ public class PrimaryNotRelocatedWhileBeingRecoveredTests extends ElasticsearchTe
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(5).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(5).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,6 @@ import java.util.Random;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||||
|
@ -60,20 +59,20 @@ public class RandomAllocationDeciderTests extends ElasticsearchTestCase {
|
||||||
* already allocated on a node and balances the cluster to gain optimal
|
* already allocated on a node and balances the cluster to gain optimal
|
||||||
* balance.*/
|
* balance.*/
|
||||||
@Test
|
@Test
|
||||||
public void testRandomDecicions() {
|
public void testRandomDecisions() {
|
||||||
RandomAllocationDecider randomAllocationDecider = new RandomAllocationDecider(getRandom());
|
RandomAllocationDecider randomAllocationDecider = new RandomAllocationDecider(getRandom());
|
||||||
AllocationService strategy = new AllocationService(settingsBuilder().build(), new AllocationDeciders(ImmutableSettings.EMPTY,
|
AllocationService strategy = new AllocationService(settingsBuilder().build(), new AllocationDeciders(ImmutableSettings.EMPTY,
|
||||||
new HashSet<AllocationDecider>(Arrays.asList(new SameShardAllocationDecider(ImmutableSettings.EMPTY),
|
new HashSet<AllocationDecider>(Arrays.asList(new SameShardAllocationDecider(ImmutableSettings.EMPTY),
|
||||||
randomAllocationDecider))), new ShardsAllocators(), ClusterInfoService.EMPTY);
|
randomAllocationDecider))), new ShardsAllocators(), ClusterInfoService.EMPTY);
|
||||||
int indices = between(1, 20);
|
int indices = between(1, 20);
|
||||||
Builder metaBuilder = newMetaDataBuilder();
|
Builder metaBuilder = MetaData.builder();
|
||||||
int maxNumReplicas = 1;
|
int maxNumReplicas = 1;
|
||||||
int totalNumShards = 0;
|
int totalNumShards = 0;
|
||||||
for (int i = 0; i < indices; i++) {
|
for (int i = 0; i < indices; i++) {
|
||||||
int replicas = between(0, 6);
|
int replicas = between(0, 6);
|
||||||
maxNumReplicas = Math.max(maxNumReplicas, replicas+1);
|
maxNumReplicas = Math.max(maxNumReplicas, replicas + 1);
|
||||||
int numShards = between(1, 20);
|
int numShards = between(1, 20);
|
||||||
totalNumShards += numShards * (replicas+1);
|
totalNumShards += numShards * (replicas + 1);
|
||||||
metaBuilder.put(newIndexMetaDataBuilder("INDEX_" + i).numberOfShards(numShards).numberOfReplicas(replicas));
|
metaBuilder.put(newIndexMetaDataBuilder("INDEX_" + i).numberOfShards(numShards).numberOfReplicas(replicas));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -124,7 +123,7 @@ public class RandomAllocationDeciderTests extends ElasticsearchTestCase {
|
||||||
ClusterState.Builder stateBuilder = newClusterStateBuilder().state(clusterState);
|
ClusterState.Builder stateBuilder = newClusterStateBuilder().state(clusterState);
|
||||||
DiscoveryNodes.Builder newNodesBuilder = newNodesBuilder();
|
DiscoveryNodes.Builder newNodesBuilder = newNodesBuilder();
|
||||||
newNodesBuilder.putAll(clusterState.nodes());
|
newNodesBuilder.putAll(clusterState.nodes());
|
||||||
for (int j = 0; j < (maxNumReplicas-clusterState.nodes().size()); j++) {
|
for (int j = 0; j < (maxNumReplicas - clusterState.nodes().size()); j++) {
|
||||||
logger.info("adding node [{}]", nodeIdCounter);
|
logger.info("adding node [{}]", nodeIdCounter);
|
||||||
newNodesBuilder.put(newNode("NODE_" + (nodeIdCounter++)));
|
newNodesBuilder.put(newNode("NODE_" + (nodeIdCounter++)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,13 +31,11 @@ import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.nullValue;
|
import static org.hamcrest.Matchers.nullValue;
|
||||||
|
|
||||||
|
@ -58,7 +56,7 @@ public class RebalanceAfterActiveTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(5).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(5).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -30,13 +30,11 @@ import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.nullValue;
|
import static org.hamcrest.Matchers.nullValue;
|
||||||
|
|
||||||
|
@ -53,7 +51,7 @@ public class ReplicaAllocatedAfterPrimaryTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@ import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||||
|
@ -32,7 +31,7 @@ public class SameShardRoutingTests extends ElasticsearchTestCase {
|
||||||
public void sameHost() {
|
public void sameHost() {
|
||||||
AllocationService strategy = new AllocationService(settingsBuilder().put(SameShardAllocationDecider.SAME_HOST_SETTING, true).build());
|
AllocationService strategy = new AllocationService(settingsBuilder().put(SameShardAllocationDecider.SAME_HOST_SETTING, true).build());
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(2).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(2).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -31,13 +31,11 @@ import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
public class ShardVersioningTests extends ElasticsearchTestCase {
|
public class ShardVersioningTests extends ElasticsearchTestCase {
|
||||||
|
@ -48,7 +46,7 @@ public class ShardVersioningTests extends ElasticsearchTestCase {
|
||||||
public void simple() {
|
public void simple() {
|
||||||
AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()).build());
|
AllocationService strategy = new AllocationService(settingsBuilder().put("cluster.routing.allocation.allow_rebalance", ClusterRebalanceAllocationDecider.ClusterRebalanceType.ALWAYS.toString()).build());
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(1))
|
||||||
.put(newIndexMetaDataBuilder("test2").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test2").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -35,13 +35,11 @@ import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,7 +54,7 @@ public class ShardsLimitAllocationTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").settings(ImmutableSettings.settingsBuilder()
|
.put(newIndexMetaDataBuilder("test").settings(ImmutableSettings.settingsBuilder()
|
||||||
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 4)
|
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 4)
|
||||||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1)
|
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1)
|
||||||
|
@ -106,7 +104,7 @@ public class ShardsLimitAllocationTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").settings(ImmutableSettings.settingsBuilder()
|
.put(newIndexMetaDataBuilder("test").settings(ImmutableSettings.settingsBuilder()
|
||||||
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 5)
|
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 5)
|
||||||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
|
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
|
||||||
|
@ -131,7 +129,7 @@ public class ShardsLimitAllocationTests extends ElasticsearchTestCase {
|
||||||
assertThat(clusterState.readOnlyRoutingNodes().numberOfShardsOfType(STARTED), equalTo(5));
|
assertThat(clusterState.readOnlyRoutingNodes().numberOfShardsOfType(STARTED), equalTo(5));
|
||||||
|
|
||||||
logger.info("add another index with 5 shards");
|
logger.info("add another index with 5 shards");
|
||||||
metaData = newMetaDataBuilder().metaData(metaData)
|
metaData = MetaData.builder(metaData)
|
||||||
.put(newIndexMetaDataBuilder("test1").settings(ImmutableSettings.settingsBuilder()
|
.put(newIndexMetaDataBuilder("test1").settings(ImmutableSettings.settingsBuilder()
|
||||||
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 5)
|
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 5)
|
||||||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
|
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
|
||||||
|
@ -162,7 +160,7 @@ public class ShardsLimitAllocationTests extends ElasticsearchTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("update " + ShardsLimitAllocationDecider.INDEX_TOTAL_SHARDS_PER_NODE + " for test, see that things move");
|
logger.info("update " + ShardsLimitAllocationDecider.INDEX_TOTAL_SHARDS_PER_NODE + " for test, see that things move");
|
||||||
metaData = newMetaDataBuilder().metaData(metaData)
|
metaData = MetaData.builder(metaData)
|
||||||
.put(newIndexMetaDataBuilder("test").settings(ImmutableSettings.settingsBuilder()
|
.put(newIndexMetaDataBuilder("test").settings(ImmutableSettings.settingsBuilder()
|
||||||
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 5)
|
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 5)
|
||||||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
|
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)
|
||||||
|
|
|
@ -39,13 +39,11 @@ import static com.google.common.collect.Lists.newArrayList;
|
||||||
import static com.google.common.collect.Sets.newHashSet;
|
import static com.google.common.collect.Sets.newHashSet;
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.*;
|
import static org.hamcrest.Matchers.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,7 +59,7 @@ public class SingleShardNoReplicasRoutingTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(0))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(0))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -163,7 +161,7 @@ public class SingleShardNoReplicasRoutingTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(0))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(0))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -218,7 +216,7 @@ public class SingleShardNoReplicasRoutingTests extends ElasticsearchTestCase {
|
||||||
final int numberOfIndices = 50;
|
final int numberOfIndices = 50;
|
||||||
logger.info("Building initial routing table with " + numberOfIndices + " indices");
|
logger.info("Building initial routing table with " + numberOfIndices + " indices");
|
||||||
|
|
||||||
MetaData.Builder metaDataBuilder = newMetaDataBuilder();
|
MetaData.Builder metaDataBuilder = MetaData.builder();
|
||||||
for (int i = 0; i < numberOfIndices; i++) {
|
for (int i = 0; i < numberOfIndices; i++) {
|
||||||
metaDataBuilder.put(newIndexMetaDataBuilder("test" + i).numberOfShards(1).numberOfReplicas(0));
|
metaDataBuilder.put(newIndexMetaDataBuilder("test" + i).numberOfShards(1).numberOfReplicas(0));
|
||||||
}
|
}
|
||||||
|
@ -331,7 +329,7 @@ public class SingleShardNoReplicasRoutingTests extends ElasticsearchTestCase {
|
||||||
final int numberOfIndices = 10;
|
final int numberOfIndices = 10;
|
||||||
logger.info("Building initial routing table with " + numberOfIndices + " indices");
|
logger.info("Building initial routing table with " + numberOfIndices + " indices");
|
||||||
|
|
||||||
MetaData.Builder metaDataBuilder = newMetaDataBuilder();
|
MetaData.Builder metaDataBuilder = MetaData.builder();
|
||||||
for (int i = 0; i < numberOfIndices; i++) {
|
for (int i = 0; i < numberOfIndices; i++) {
|
||||||
metaDataBuilder.put(newIndexMetaDataBuilder("test" + i).numberOfShards(1).numberOfReplicas(0));
|
metaDataBuilder.put(newIndexMetaDataBuilder("test" + i).numberOfShards(1).numberOfReplicas(0));
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,13 +30,11 @@ import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
import static org.hamcrest.Matchers.nullValue;
|
import static org.hamcrest.Matchers.nullValue;
|
||||||
|
|
||||||
|
@ -53,7 +51,7 @@ public class SingleShardOneReplicaRoutingTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -30,13 +30,11 @@ import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.*;
|
import static org.hamcrest.Matchers.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,7 +58,7 @@ public class TenShardsOneReplicaRoutingTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(10).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(10).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -29,13 +29,11 @@ import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,7 +52,7 @@ public class ThrottlingAllocationTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(10).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(10).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -115,7 +113,7 @@ public class ThrottlingAllocationTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(5).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(5).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -11,13 +11,11 @@ import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.*;
|
import static org.hamcrest.Matchers.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,7 +31,7 @@ public class UpdateNumberOfReplicasTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
logger.info("Building initial routing table");
|
logger.info("Building initial routing table");
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -85,7 +83,7 @@ public class UpdateNumberOfReplicasTests extends ElasticsearchTestCase {
|
||||||
routingNodes = clusterState.routingNodes();
|
routingNodes = clusterState.routingNodes();
|
||||||
prevRoutingTable = routingTable;
|
prevRoutingTable = routingTable;
|
||||||
routingTable = RoutingTable.builder().routingTable(routingTable).updateNumberOfReplicas(2).build();
|
routingTable = RoutingTable.builder().routingTable(routingTable).updateNumberOfReplicas(2).build();
|
||||||
metaData = MetaData.newMetaDataBuilder().metaData(clusterState.metaData()).updateNumberOfReplicas(2).build();
|
metaData = MetaData.builder(clusterState.metaData()).updateNumberOfReplicas(2).build();
|
||||||
clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).metaData(metaData).build();
|
clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).metaData(metaData).build();
|
||||||
|
|
||||||
assertThat(clusterState.metaData().index("test").numberOfReplicas(), equalTo(2));
|
assertThat(clusterState.metaData().index("test").numberOfReplicas(), equalTo(2));
|
||||||
|
@ -137,7 +135,7 @@ public class UpdateNumberOfReplicasTests extends ElasticsearchTestCase {
|
||||||
routingNodes = clusterState.routingNodes();
|
routingNodes = clusterState.routingNodes();
|
||||||
prevRoutingTable = routingTable;
|
prevRoutingTable = routingTable;
|
||||||
routingTable = RoutingTable.builder().routingTable(routingTable).updateNumberOfReplicas(1).build();
|
routingTable = RoutingTable.builder().routingTable(routingTable).updateNumberOfReplicas(1).build();
|
||||||
metaData = MetaData.newMetaDataBuilder().metaData(clusterState.metaData()).updateNumberOfReplicas(1).build();
|
metaData = MetaData.builder(clusterState.metaData()).updateNumberOfReplicas(1).build();
|
||||||
clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).metaData(metaData).build();
|
clusterState = newClusterStateBuilder().state(clusterState).routingTable(routingTable).metaData(metaData).build();
|
||||||
|
|
||||||
assertThat(clusterState.metaData().index("test").numberOfReplicas(), equalTo(1));
|
assertThat(clusterState.metaData().index("test").numberOfReplicas(), equalTo(1));
|
||||||
|
|
|
@ -41,7 +41,6 @@ import java.util.Map;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
import static org.elasticsearch.cluster.routing.ShardRoutingState.*;
|
||||||
|
@ -88,7 +87,7 @@ public class DiskThresholdDeciderTests extends ElasticsearchTestCase {
|
||||||
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
|
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
|
||||||
.build(), deciders, new ShardsAllocators(), cis);
|
.build(), deciders, new ShardsAllocators(), cis);
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -277,7 +276,7 @@ public class DiskThresholdDeciderTests extends ElasticsearchTestCase {
|
||||||
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
|
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
|
||||||
.build(), deciders, new ShardsAllocators(), cis);
|
.build(), deciders, new ShardsAllocators(), cis);
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -463,7 +462,7 @@ public class DiskThresholdDeciderTests extends ElasticsearchTestCase {
|
||||||
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
|
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
|
||||||
.build(), deciders, new ShardsAllocators(), cis);
|
.build(), deciders, new ShardsAllocators(), cis);
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(0))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(0))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -525,7 +524,7 @@ public class DiskThresholdDeciderTests extends ElasticsearchTestCase {
|
||||||
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
|
.put("cluster.routing.allocation.cluster_concurrent_rebalance", -1)
|
||||||
.build(), deciders, new ShardsAllocators(), cis);
|
.build(), deciders, new ShardsAllocators(), cis);
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(0))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(0))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,7 @@ import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.equalTo;
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,7 +44,7 @@ public class ClusterSerializationTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testClusterStateSerialization() throws Exception {
|
public void testClusterStateSerialization() throws Exception {
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(10).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(10).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -69,7 +67,7 @@ public class ClusterSerializationTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRoutingTableSerialization() throws Exception {
|
public void testRoutingTableSerialization() throws Exception {
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(10).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(10).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -35,13 +35,11 @@ import org.junit.Test;
|
||||||
|
|
||||||
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
import static org.elasticsearch.cluster.ClusterState.newClusterStateBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
import static org.elasticsearch.cluster.metadata.IndexMetaData.newIndexMetaDataBuilder;
|
||||||
import static org.elasticsearch.cluster.metadata.MetaData.newMetaDataBuilder;
|
|
||||||
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
import static org.elasticsearch.cluster.node.DiscoveryNodes.newNodesBuilder;
|
||||||
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
|
||||||
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
|
||||||
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
import static org.elasticsearch.cluster.routing.allocation.RoutingAllocationTests.newNode;
|
||||||
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.*;
|
import static org.hamcrest.Matchers.*;
|
||||||
|
|
||||||
public class RoutingIteratorTests extends ElasticsearchTestCase {
|
public class RoutingIteratorTests extends ElasticsearchTestCase {
|
||||||
|
@ -87,7 +85,7 @@ public class RoutingIteratorTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIterator1() {
|
public void testIterator1() {
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(2))
|
.put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(2))
|
||||||
.build();
|
.build();
|
||||||
RoutingTable routingTable = routingTable()
|
RoutingTable routingTable = routingTable()
|
||||||
|
@ -121,7 +119,7 @@ public class RoutingIteratorTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIterator2() {
|
public void testIterator2() {
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(1))
|
||||||
.put(newIndexMetaDataBuilder("test2").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test2").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
@ -224,7 +222,7 @@ public class RoutingIteratorTests extends ElasticsearchTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRandomRouting() {
|
public void testRandomRouting() {
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test1").numberOfShards(1).numberOfReplicas(1))
|
||||||
.put(newIndexMetaDataBuilder("test2").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test2").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
@ -258,7 +256,7 @@ public class RoutingIteratorTests extends ElasticsearchTestCase {
|
||||||
.put("cluster.routing.allocation.awareness.attributes", "rack_id,zone")
|
.put("cluster.routing.allocation.awareness.attributes", "rack_id,zone")
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(1).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -307,7 +305,7 @@ public class RoutingIteratorTests extends ElasticsearchTestCase {
|
||||||
.put("cluster.routing.allocation.concurrent_recoveries", 10)
|
.put("cluster.routing.allocation.concurrent_recoveries", 10)
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
MetaData metaData = newMetaDataBuilder()
|
MetaData metaData = MetaData.builder()
|
||||||
.put(newIndexMetaDataBuilder("test").numberOfShards(5).numberOfReplicas(1))
|
.put(newIndexMetaDataBuilder("test").numberOfShards(5).numberOfReplicas(1))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue