Update Index usage to elasticsearchelastic/elasticsearch#16217
elasticsearchelastic/elasticsearch#16217 changed the Index class to also include index UUIDs . This commit adapts the code for it. Closes elastic/elasticsearch#1377 Original commit: elastic/x-pack-elasticsearch@87c909c15a
This commit is contained in:
parent
4012b4c7c6
commit
dfb9068e33
|
@ -8,6 +8,7 @@ package org.elasticsearch.messy.tests;
|
|||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.action.search.ShardSearchFailure;
|
||||
import org.elasticsearch.common.text.Text;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.script.groovy.GroovyPlugin;
|
||||
import org.elasticsearch.search.SearchShardTarget;
|
||||
|
@ -93,7 +94,7 @@ public class ScriptConditionSearchTests extends AbstractWatcherIntegrationTestCa
|
|||
ExecutableScriptCondition condition = new ExecutableScriptCondition(new ScriptCondition(Script.inline("ctx.payload.hits?.hits[0]?._score == 1.0").build()), logger, scriptService);
|
||||
InternalSearchHit hit = new InternalSearchHit(0, "1", new Text("type"), null);
|
||||
hit.score(1f);
|
||||
hit.shard(new SearchShardTarget("a", "a", 0));
|
||||
hit.shard(new SearchShardTarget("a", new Index("a", "testUUID"), 0));
|
||||
|
||||
InternalSearchResponse internalSearchResponse = new InternalSearchResponse(new InternalSearchHits(new InternalSearchHit[]{hit}, 1l, 1f), null, null, null, false, false);
|
||||
SearchResponse response = new SearchResponse(internalSearchResponse, "", 3, 3, 500l, new ShardSearchFailure[0]);
|
||||
|
|
|
@ -60,7 +60,7 @@ public class ShardsCollector extends AbstractCollector<ShardsCollector> {
|
|||
long timestamp = System.currentTimeMillis();
|
||||
|
||||
for (ShardRouting shard : shards) {
|
||||
if (match(shard.getIndex())) {
|
||||
if (match(shard.getIndexName())) {
|
||||
results.add(new ShardMarvelDoc(null, TYPE, id(stateUUID, shard), clusterUUID, timestamp, shard, stateUUID));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ public class ShardsCollectorTests extends AbstractCollectorTestCase {
|
|||
int[] shards = new int[nbIndices];
|
||||
for (MarvelDoc marvelDoc : results) {
|
||||
ShardRouting routing = ((ShardMarvelDoc) marvelDoc).getShardRouting();
|
||||
int index = Integer.parseInt(routing.index().substring(indexPrefix.length()));
|
||||
int index = Integer.parseInt(routing.getIndexName().substring(indexPrefix.length()));
|
||||
shards[index]++;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,11 +35,11 @@ public class IndexRecoveryRendererTests extends ESTestCase {
|
|||
List<RecoveryState> shards = new ArrayList<>();
|
||||
|
||||
// Shard 0
|
||||
RecoveryState shard0 = new RecoveryState(new ShardId(indexName, 0), true, RecoveryState.Type.RELOCATION, source, target);
|
||||
RecoveryState shard0 = new RecoveryState(new ShardId(indexName, "testUUID", 0), true, RecoveryState.Type.RELOCATION, source, target);
|
||||
shards.add(shard0);
|
||||
|
||||
// Shard 1
|
||||
RecoveryState shard1 = new RecoveryState(new ShardId(indexName, 1), true, RecoveryState.Type.STORE, source, target);
|
||||
RecoveryState shard1 = new RecoveryState(new ShardId(indexName, "testUUID", 1), true, RecoveryState.Type.STORE, source, target);
|
||||
shards.add(shard1);
|
||||
|
||||
Map<String, List<RecoveryState>> shardResponses = new HashMap<>(1);
|
||||
|
|
|
@ -52,23 +52,23 @@ public final class OptOutQueryCache extends AbstractIndexComponent implements Qu
|
|||
}
|
||||
|
||||
// At this level only IndicesRequest
|
||||
final String index;
|
||||
final String indexName;
|
||||
if (context.getRequest() instanceof ShardSearchRequest) {
|
||||
index = ((ShardSearchRequest) context.getRequest()).index();
|
||||
indexName = ((ShardSearchRequest) context.getRequest()).index();
|
||||
} else if (context.getRequest() instanceof BroadcastShardRequest) {
|
||||
index = ((BroadcastShardRequest) context.getRequest()).shardId().getIndex();
|
||||
indexName = ((BroadcastShardRequest) context.getRequest()).shardId().getIndexName();
|
||||
} else {
|
||||
return weight;
|
||||
}
|
||||
|
||||
IndicesAccessControl.IndexAccessControl indexAccessControl = indicesAccessControl.getIndexPermissions(index);
|
||||
IndicesAccessControl.IndexAccessControl indexAccessControl = indicesAccessControl.getIndexPermissions(indexName);
|
||||
if (indexAccessControl != null && indexAccessControl.getFields() != null) {
|
||||
logger.debug("opting out of the query cache. request for index [{}] has field level security enabled", index);
|
||||
logger.debug("opting out of the query cache. request for index [{}] has field level security enabled", indexName);
|
||||
// If in the future there is a Query#extractFields() then we can be smart on when to skip the query cache.
|
||||
// (only cache if all fields in the query also are defined in the role)
|
||||
return weight;
|
||||
} else {
|
||||
logger.trace("not opting out of the query cache. request for index [{}] has field level security disabled", index);
|
||||
logger.trace("not opting out of the query cache. request for index [{}] has field level security disabled", indexName);
|
||||
return indicesQueryCache.doCache(weight, policy);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ public class ShieldIndexSearcherWrapper extends IndexSearcherWrapper {
|
|||
throw new IllegalStateException(LoggerMessageFormat.format("couldn't extract shardId from reader [{}]", reader));
|
||||
}
|
||||
|
||||
IndicesAccessControl.IndexAccessControl permissions = indicesAccessControl.getIndexPermissions(shardId.getIndex());
|
||||
IndicesAccessControl.IndexAccessControl permissions = indicesAccessControl.getIndexPermissions(shardId.getIndexName());
|
||||
// No permissions have been defined for an index, so don't intercept the index reader for access control
|
||||
if (permissions == null) {
|
||||
return reader;
|
||||
|
|
|
@ -15,7 +15,6 @@ import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
|||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.common.regex.Regex;
|
||||
import org.elasticsearch.common.util.set.Sets;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.IndexNotFoundException;
|
||||
import org.elasticsearch.shield.User;
|
||||
import org.elasticsearch.shield.authz.AuthorizationService;
|
||||
|
@ -142,8 +141,8 @@ public class DefaultIndicesAndAliasesResolver implements IndicesAndAliasesResolv
|
|||
//to make sure that the operation is executed on the aliases that we authorized it to execute on.
|
||||
//If we can't replace because we got an empty set, we can only throw exception.
|
||||
if (finalAliases.isEmpty()) {
|
||||
Index index = matchAllAliases ? new Index(MetaData.ALL) : new Index(Arrays.toString(aliases));
|
||||
throw new IndexNotFoundException(index.getName());
|
||||
String indexName = matchAllAliases ? MetaData.ALL : Arrays.toString(aliases);
|
||||
throw new IndexNotFoundException(indexName);
|
||||
}
|
||||
return finalAliases;
|
||||
}
|
||||
|
@ -231,8 +230,8 @@ public class DefaultIndicesAndAliasesResolver implements IndicesAndAliasesResolv
|
|||
//If we can't replace because we got an empty set, we can only throw exception.
|
||||
//Downside of this is that a single item exception is going to make fail the composite request that holds it as a whole.
|
||||
if (resolvedIndices == null || resolvedIndices.isEmpty()) {
|
||||
Index index = IndexNameExpressionResolver.isAllIndices(indicesList(originalIndices)) ? new Index(MetaData.ALL) : new Index(Arrays.toString(originalIndices));
|
||||
throw new IndexNotFoundException(index.getName());
|
||||
String indexName = IndexNameExpressionResolver.isAllIndices(indicesList(originalIndices)) ? MetaData.ALL : Arrays.toString(originalIndices);
|
||||
throw new IndexNotFoundException(indexName);
|
||||
}
|
||||
return resolvedIndices;
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ public interface IndicesPermission extends Permission, Iterable<IndicesPermissio
|
|||
AliasOrIndex aliasOrIndex = allAliasesAndIndices.get(indexOrAlias);
|
||||
if (aliasOrIndex != null) {
|
||||
for (IndexMetaData indexMetaData : aliasOrIndex.getIndices()) {
|
||||
concreteIndices.add(indexMetaData.getIndex());
|
||||
concreteIndices.add(indexMetaData.getIndex().getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.apache.lucene.util.Bits;
|
|||
import org.apache.lucene.util.IOUtils;
|
||||
import org.apache.lucene.util.TestUtil;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.IndexSettings;
|
||||
import org.elasticsearch.index.cache.bitset.BitsetFilterCache;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
|
@ -48,7 +47,7 @@ public class DocumentSubsetReaderTests extends ESTestCase {
|
|||
@Before
|
||||
public void before() {
|
||||
directory = newDirectory();
|
||||
IndexSettings settings = IndexSettingsModule.newIndexSettings(new Index("_index"), Settings.EMPTY);
|
||||
IndexSettings settings = IndexSettingsModule.newIndexSettings("_index", Settings.EMPTY);
|
||||
bitsetFilterCache = new BitsetFilterCache(settings, new IndicesWarmer(settings.getSettings(), null), new BitsetFilterCache.Listener() {
|
||||
@Override
|
||||
public void onCache(ShardId shardId, Accountable accountable) {
|
||||
|
@ -163,7 +162,7 @@ public class DocumentSubsetReaderTests extends ESTestCase {
|
|||
IndexWriterConfig iwc = new IndexWriterConfig(null);
|
||||
IndexWriter iw = new IndexWriter(dir, iwc);
|
||||
iw.close();
|
||||
IndexSettings settings = IndexSettingsModule.newIndexSettings(new Index("_index"), Settings.EMPTY);
|
||||
IndexSettings settings = IndexSettingsModule.newIndexSettings("_index", Settings.EMPTY);
|
||||
BitsetFilterCache bitsetFilterCache = new BitsetFilterCache(settings, new IndicesWarmer(settings.getSettings(), null), new BitsetFilterCache.Listener() {
|
||||
@Override
|
||||
public void onCache(ShardId shardId, Accountable accountable) {
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.elasticsearch.common.bytes.BytesReference;
|
|||
import org.elasticsearch.common.lucene.index.ElasticsearchDirectoryReader;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.IndexSettings;
|
||||
import org.elasticsearch.index.cache.bitset.BitsetFilterCache;
|
||||
import org.elasticsearch.index.mapper.MapperService;
|
||||
|
@ -33,7 +32,6 @@ import org.elasticsearch.index.query.ParsedQuery;
|
|||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.indices.IndicesWarmer;
|
||||
import org.elasticsearch.shield.authz.InternalAuthorizationService;
|
||||
import org.elasticsearch.shield.license.ShieldLicenseState;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.IndexSettingsModule;
|
||||
|
@ -55,7 +53,7 @@ import static org.mockito.Mockito.when;
|
|||
public class ShieldIndexSearcherWrapperIntegrationTests extends ESTestCase {
|
||||
|
||||
public void testDLS() throws Exception {
|
||||
ShardId shardId = new ShardId("_index", 0);
|
||||
ShardId shardId = new ShardId("_index", "_na_", 0);
|
||||
MapperService mapperService = mock(MapperService.class);
|
||||
when(mapperService.docMappers(anyBoolean())).thenReturn(Collections.emptyList());
|
||||
when(mapperService.simpleMatchToIndexNames(anyString())).then(new Answer<Collection<String>>() {
|
||||
|
@ -67,9 +65,9 @@ public class ShieldIndexSearcherWrapperIntegrationTests extends ESTestCase {
|
|||
|
||||
ThreadContext threadContext = new ThreadContext(Settings.EMPTY);
|
||||
IndicesAccessControl.IndexAccessControl indexAccessControl = new IndicesAccessControl.IndexAccessControl(true, null, singleton(new BytesArray("{}")));
|
||||
IndexSettings indexSettings = IndexSettingsModule.newIndexSettings(shardId.index(), Settings.EMPTY);
|
||||
IndexSettings indexSettings = IndexSettingsModule.newIndexSettings(shardId.getIndex(), Settings.EMPTY);
|
||||
QueryShardContext queryShardContext = mock(QueryShardContext.class);
|
||||
IndexSettings settings = IndexSettingsModule.newIndexSettings(new Index("_index"), Settings.EMPTY);
|
||||
IndexSettings settings = IndexSettingsModule.newIndexSettings("_index", Settings.EMPTY);
|
||||
BitsetFilterCache bitsetFilterCache = new BitsetFilterCache(settings, new IndicesWarmer(settings.getSettings(), null), new BitsetFilterCache.Listener() {
|
||||
@Override
|
||||
public void onCache(ShardId shardId, Accountable accountable) {
|
||||
|
|
|
@ -76,7 +76,7 @@ public class ShieldIndexSearcherWrapperUnitTests extends ESTestCase {
|
|||
|
||||
@Before
|
||||
public void before() throws Exception {
|
||||
Index index = new Index("_index");
|
||||
Index index = new Index("_index", "testUUID");
|
||||
indexSettings = IndexSettingsModule.newIndexSettings(index, Settings.EMPTY);
|
||||
AnalysisService analysisService = new AnalysisService(indexSettings, Collections.emptyMap(), Collections.emptyMap(),
|
||||
Collections.emptyMap(), Collections.emptyMap());
|
||||
|
@ -142,7 +142,6 @@ public class ShieldIndexSearcherWrapperUnitTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testWrapSearcherWhenFeatureDisabled() throws Exception {
|
||||
ShardId shardId = new ShardId("_index", 0);
|
||||
shieldIndexSearcherWrapper = new ShieldIndexSearcherWrapper(indexSettings, null, mapperService, null, threadContext, licenseState);
|
||||
IndexSearcher indexSearcher = new IndexSearcher(esIn);
|
||||
IndexSearcher result = shieldIndexSearcherWrapper.wrap(indexSearcher);
|
||||
|
@ -241,8 +240,7 @@ public class ShieldIndexSearcherWrapperUnitTests extends ESTestCase {
|
|||
}
|
||||
|
||||
public void testDelegateSimilarity() throws Exception {
|
||||
ShardId shardId = new ShardId("_index", 0);
|
||||
IndexSettings settings = IndexSettingsModule.newIndexSettings(new Index("_index"), Settings.EMPTY);
|
||||
IndexSettings settings = IndexSettingsModule.newIndexSettings("_index", Settings.EMPTY);
|
||||
BitsetFilterCache bitsetFilterCache = new BitsetFilterCache(settings, new IndicesWarmer(settings.getSettings(), null), new BitsetFilterCache.Listener() {
|
||||
@Override
|
||||
public void onCache(ShardId shardId, Accountable accountable) {
|
||||
|
|
|
@ -8,6 +8,7 @@ package org.elasticsearch.watcher.condition.compare;
|
|||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.action.search.ShardSearchFailure;
|
||||
import org.elasticsearch.common.text.Text;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.search.SearchShardTarget;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
||||
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
|
||||
|
@ -81,7 +82,7 @@ public class CompareConditionSearchTests extends AbstractWatcherIntegrationTestC
|
|||
ExecutableCompareCondition condition = new ExecutableCompareCondition(new CompareCondition("ctx.payload.hits.hits.0._score", CompareCondition.Op.EQ, 1), logger, SystemClock.INSTANCE);
|
||||
InternalSearchHit hit = new InternalSearchHit(0, "1", new Text("type"), null);
|
||||
hit.score(1f);
|
||||
hit.shard(new SearchShardTarget("a", "a", 0));
|
||||
hit.shard(new SearchShardTarget("a", new Index("a", "indexUUID"), 0));
|
||||
|
||||
InternalSearchResponse internalSearchResponse = new InternalSearchResponse(new InternalSearchHits(new InternalSearchHit[]{hit}, 1l, 1f), null, null, null, false, false);
|
||||
SearchResponse response = new SearchResponse(internalSearchResponse, "", 3, 3, 500l, new ShardSearchFailure[0]);
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.apache.lucene.util.LuceneTestCase.AwaitsFix;
|
|||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.action.search.ShardSearchFailure;
|
||||
import org.elasticsearch.common.text.Text;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.search.SearchShardTarget;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilders;
|
||||
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
|
||||
|
@ -83,7 +84,7 @@ public class ScriptConditionSearchTests extends AbstractWatcherIntegrationTestCa
|
|||
ExecutableScriptCondition condition = new ExecutableScriptCondition(new ScriptCondition(Script.inline("ctx.payload.hits?.hits[0]?._score == 1.0").build()), logger, scriptService);
|
||||
InternalSearchHit hit = new InternalSearchHit(0, "1", new Text("type"), null);
|
||||
hit.score(1f);
|
||||
hit.shard(new SearchShardTarget("a", "a", 0));
|
||||
hit.shard(new SearchShardTarget("a", new Index("a", "testUUID"), 0));
|
||||
|
||||
InternalSearchResponse internalSearchResponse = new InternalSearchResponse(new InternalSearchHits(new InternalSearchHit[]{hit}, 1l, 1f), null, null, null, false, false);
|
||||
SearchResponse response = new SearchResponse(internalSearchResponse, "", 3, 3, 500l, new ShardSearchFailure[0]);
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.common.bytes.BytesReference;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.text.Text;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.search.SearchShardTarget;
|
||||
import org.elasticsearch.search.internal.InternalSearchHit;
|
||||
|
@ -83,15 +84,15 @@ public class TriggeredWatchStoreTests extends ESTestCase {
|
|||
RoutingTable.Builder routingTableBuilder = RoutingTable.builder();
|
||||
MetaData.Builder metaDateBuilder = MetaData.builder();
|
||||
|
||||
String indexName = TriggeredWatchStore.INDEX_NAME;
|
||||
int numShards = 2 + randomInt(2);
|
||||
int numStartedShards = 1;
|
||||
Settings settings = settings(Version.CURRENT)
|
||||
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, numShards)
|
||||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1)
|
||||
.build();
|
||||
metaDateBuilder.put(IndexMetaData.builder(indexName).settings(settings).numberOfShards(numShards).numberOfReplicas(1));
|
||||
IndexRoutingTable.Builder indexRoutingTableBuilder = IndexRoutingTable.builder(indexName);
|
||||
metaDateBuilder.put(IndexMetaData.builder(TriggeredWatchStore.INDEX_NAME).settings(settings).numberOfShards(numShards).numberOfReplicas(1));
|
||||
final Index index = metaDateBuilder.get(TriggeredWatchStore.INDEX_NAME).getIndex();
|
||||
IndexRoutingTable.Builder indexRoutingTableBuilder = IndexRoutingTable.builder(index);
|
||||
for (int i = 0; i < numShards; i++) {
|
||||
ShardRoutingState state;
|
||||
if (numStartedShards-- > 0) {
|
||||
|
@ -99,8 +100,8 @@ public class TriggeredWatchStoreTests extends ESTestCase {
|
|||
} else {
|
||||
state = ShardRoutingState.UNASSIGNED;
|
||||
}
|
||||
indexRoutingTableBuilder.addIndexShard(new IndexShardRoutingTable.Builder(new ShardId(indexName, 0))
|
||||
.addShard(TestShardRouting.newShardRouting(indexName, 0, "_node_id", null, null, true, state, 1, new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, "")))
|
||||
indexRoutingTableBuilder.addIndexShard(new IndexShardRoutingTable.Builder(new ShardId(index, 0))
|
||||
.addShard(TestShardRouting.newShardRouting(index, 0, "_node_id", null, null, true, state, 1, new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, "")))
|
||||
.build());
|
||||
indexRoutingTableBuilder.addReplica();
|
||||
}
|
||||
|
@ -126,15 +127,15 @@ public class TriggeredWatchStoreTests extends ESTestCase {
|
|||
|
||||
RoutingTable.Builder routingTableBuilder = RoutingTable.builder();
|
||||
MetaData.Builder metaDateBuilder = MetaData.builder();
|
||||
String indexName = TriggeredWatchStore.INDEX_NAME;
|
||||
Settings settings = settings(Version.CURRENT)
|
||||
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
|
||||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1)
|
||||
.build();
|
||||
metaDateBuilder.put(IndexMetaData.builder(indexName).settings(settings).numberOfShards(1).numberOfReplicas(1));
|
||||
IndexRoutingTable.Builder indexRoutingTableBuilder = IndexRoutingTable.builder(indexName);
|
||||
indexRoutingTableBuilder.addIndexShard(new IndexShardRoutingTable.Builder(new ShardId(indexName, 0))
|
||||
.addShard(TestShardRouting.newShardRouting(indexName, 0, "_node_id", null, true, ShardRoutingState.STARTED, 1))
|
||||
metaDateBuilder.put(IndexMetaData.builder(TriggeredWatchStore.INDEX_NAME).settings(settings).numberOfShards(1).numberOfReplicas(1));
|
||||
final Index index = metaDateBuilder.get(TriggeredWatchStore.INDEX_NAME).getIndex();
|
||||
IndexRoutingTable.Builder indexRoutingTableBuilder = IndexRoutingTable.builder(index);
|
||||
indexRoutingTableBuilder.addIndexShard(new IndexShardRoutingTable.Builder(new ShardId(index, 0))
|
||||
.addShard(TestShardRouting.newShardRouting(index, 0, "_node_id", null, true, ShardRoutingState.STARTED, 1))
|
||||
.build());
|
||||
indexRoutingTableBuilder.addReplica();
|
||||
routingTableBuilder.add(indexRoutingTableBuilder.build());
|
||||
|
@ -160,15 +161,15 @@ public class TriggeredWatchStoreTests extends ESTestCase {
|
|||
|
||||
RoutingTable.Builder routingTableBuilder = RoutingTable.builder();
|
||||
MetaData.Builder metaDateBuilder = MetaData.builder();
|
||||
String indexName = TriggeredWatchStore.INDEX_NAME;
|
||||
Settings settings = settings(Version.CURRENT)
|
||||
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
|
||||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1)
|
||||
.build();
|
||||
metaDateBuilder.put(IndexMetaData.builder(indexName).settings(settings).numberOfShards(1).numberOfReplicas(1));
|
||||
IndexRoutingTable.Builder indexRoutingTableBuilder = IndexRoutingTable.builder(indexName);
|
||||
indexRoutingTableBuilder.addIndexShard(new IndexShardRoutingTable.Builder(new ShardId(indexName, 0))
|
||||
.addShard(TestShardRouting.newShardRouting(indexName, 0, "_node_name", null, true, ShardRoutingState.STARTED, 1))
|
||||
metaDateBuilder.put(IndexMetaData.builder(TriggeredWatchStore.INDEX_NAME).settings(settings).numberOfShards(1).numberOfReplicas(1));
|
||||
final Index index = metaDateBuilder.get(TriggeredWatchStore.INDEX_NAME).getIndex();
|
||||
IndexRoutingTable.Builder indexRoutingTableBuilder = IndexRoutingTable.builder(index);
|
||||
indexRoutingTableBuilder.addIndexShard(new IndexShardRoutingTable.Builder(new ShardId(index, 0))
|
||||
.addShard(TestShardRouting.newShardRouting(index, 0, "_node_name", null, true, ShardRoutingState.STARTED, 1))
|
||||
.build());
|
||||
indexRoutingTableBuilder.addReplica();
|
||||
routingTableBuilder.add(indexRoutingTableBuilder.build());
|
||||
|
@ -203,15 +204,15 @@ public class TriggeredWatchStoreTests extends ESTestCase {
|
|||
|
||||
RoutingTable.Builder routingTableBuilder = RoutingTable.builder();
|
||||
MetaData.Builder metaDateBuilder = MetaData.builder();
|
||||
String indexName = TriggeredWatchStore.INDEX_NAME;
|
||||
Settings settings = settings(Version.CURRENT)
|
||||
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
|
||||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1)
|
||||
.build();
|
||||
metaDateBuilder.put(IndexMetaData.builder(indexName).settings(settings).numberOfShards(1).numberOfReplicas(1));
|
||||
IndexRoutingTable.Builder indexRoutingTableBuilder = IndexRoutingTable.builder(indexName);
|
||||
indexRoutingTableBuilder.addIndexShard(new IndexShardRoutingTable.Builder(new ShardId(indexName, 0))
|
||||
.addShard(TestShardRouting.newShardRouting(indexName, 0, "_node_name", null, true, ShardRoutingState.STARTED, 1))
|
||||
metaDateBuilder.put(IndexMetaData.builder(TriggeredWatchStore.INDEX_NAME).settings(settings).numberOfShards(1).numberOfReplicas(1));
|
||||
final Index index = metaDateBuilder.get(TriggeredWatchStore.INDEX_NAME).getIndex();
|
||||
IndexRoutingTable.Builder indexRoutingTableBuilder = IndexRoutingTable.builder(index);
|
||||
indexRoutingTableBuilder.addIndexShard(new IndexShardRoutingTable.Builder(new ShardId(index, 0))
|
||||
.addShard(TestShardRouting.newShardRouting(index, 0, "_node_name", null, true, ShardRoutingState.STARTED, 1))
|
||||
.build());
|
||||
indexRoutingTableBuilder.addReplica();
|
||||
routingTableBuilder.add(indexRoutingTableBuilder.build());
|
||||
|
@ -245,15 +246,15 @@ public class TriggeredWatchStoreTests extends ESTestCase {
|
|||
|
||||
RoutingTable.Builder routingTableBuilder = RoutingTable.builder();
|
||||
MetaData.Builder metaDateBuilder = MetaData.builder();
|
||||
String indexName = TriggeredWatchStore.INDEX_NAME;
|
||||
Settings settings = settings(Version.CURRENT)
|
||||
.put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1)
|
||||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1)
|
||||
.build();
|
||||
metaDateBuilder.put(IndexMetaData.builder(indexName).settings(settings).numberOfShards(1).numberOfReplicas(1));
|
||||
IndexRoutingTable.Builder indexRoutingTableBuilder = IndexRoutingTable.builder(indexName);
|
||||
indexRoutingTableBuilder.addIndexShard(new IndexShardRoutingTable.Builder(new ShardId(indexName, 0))
|
||||
.addShard(TestShardRouting.newShardRouting(indexName, 0, "_node_id", null, true, ShardRoutingState.STARTED, 1))
|
||||
metaDateBuilder.put(IndexMetaData.builder(TriggeredWatchStore.INDEX_NAME).settings(settings).numberOfShards(1).numberOfReplicas(1));
|
||||
final Index index = metaDateBuilder.get(TriggeredWatchStore.INDEX_NAME).getIndex();
|
||||
IndexRoutingTable.Builder indexRoutingTableBuilder = IndexRoutingTable.builder(index);
|
||||
indexRoutingTableBuilder.addIndexShard(new IndexShardRoutingTable.Builder(new ShardId(index, 0))
|
||||
.addShard(TestShardRouting.newShardRouting(index, 0, "_node_id", null, true, ShardRoutingState.STARTED, 1))
|
||||
.build());
|
||||
indexRoutingTableBuilder.addReplica();
|
||||
routingTableBuilder.add(indexRoutingTableBuilder.build());
|
||||
|
@ -269,7 +270,7 @@ public class TriggeredWatchStoreTests extends ESTestCase {
|
|||
when(searchResponse1.getTotalShards()).thenReturn(1);
|
||||
InternalSearchHit hit = new InternalSearchHit(0, "_id", new Text("_type"), null);
|
||||
hit.version(1l);
|
||||
hit.shard(new SearchShardTarget("_node_id", indexName, 0));
|
||||
hit.shard(new SearchShardTarget("_node_id", index, 0));
|
||||
hit.sourceRef(new BytesArray("{}"));
|
||||
InternalSearchHits hits = new InternalSearchHits(new InternalSearchHit[]{hit}, 1, 1.0f);
|
||||
when(searchResponse1.getHits()).thenReturn(hits);
|
||||
|
@ -279,7 +280,7 @@ public class TriggeredWatchStoreTests extends ESTestCase {
|
|||
// First return a scroll response with a single hit and then with no hits
|
||||
hit = new InternalSearchHit(0, "_id", new Text("_type"), null);
|
||||
hit.version(1l);
|
||||
hit.shard(new SearchShardTarget("_node_id", indexName, 0));
|
||||
hit.shard(new SearchShardTarget("_node_id", index, 0));
|
||||
hit.sourceRef(new BytesArray("{}"));
|
||||
hits = new InternalSearchHits(new InternalSearchHit[]{hit}, 1, 1.0f);
|
||||
SearchResponse searchResponse2 = new SearchResponse(new InternalSearchResponse(hits, null, null, null, false, null), "_scrollId", 1, 1, 1, null);
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.common.bytes.BytesReference;
|
|||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.text.Text;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
import org.elasticsearch.search.SearchHitField;
|
||||
import org.elasticsearch.search.internal.InternalSearchHit;
|
||||
|
@ -86,8 +87,9 @@ public class WatchStoreTests extends ESTestCase {
|
|||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1)
|
||||
.build();
|
||||
metaDateBuilder.put(IndexMetaData.builder(WatchStore.INDEX).settings(settings).numberOfShards(1).numberOfReplicas(1));
|
||||
IndexRoutingTable.Builder indexRoutingTableBuilder = IndexRoutingTable.builder(WatchStore.INDEX);
|
||||
indexRoutingTableBuilder.addIndexShard(new IndexShardRoutingTable.Builder(new ShardId(WatchStore.INDEX, 0))
|
||||
final Index index = metaDateBuilder.get(WatchStore.INDEX).getIndex();
|
||||
IndexRoutingTable.Builder indexRoutingTableBuilder = IndexRoutingTable.builder(index);
|
||||
indexRoutingTableBuilder.addIndexShard(new IndexShardRoutingTable.Builder(new ShardId(index, 0))
|
||||
.addShard(TestShardRouting.newShardRouting(WatchStore.INDEX, 0, "_node_id", null, null, true, ShardRoutingState.UNASSIGNED, 1, new UnassignedInfo(UnassignedInfo.Reason.INDEX_CREATED, "")))
|
||||
.build());
|
||||
indexRoutingTableBuilder.addReplica();
|
||||
|
@ -109,8 +111,9 @@ public class WatchStoreTests extends ESTestCase {
|
|||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1)
|
||||
.build();
|
||||
metaDateBuilder.put(IndexMetaData.builder(WatchStore.INDEX).settings(settings).numberOfShards(1).numberOfReplicas(1));
|
||||
IndexRoutingTable.Builder indexRoutingTableBuilder = IndexRoutingTable.builder(WatchStore.INDEX);
|
||||
indexRoutingTableBuilder.addIndexShard(new IndexShardRoutingTable.Builder(new ShardId(WatchStore.INDEX, 0))
|
||||
final Index index = metaDateBuilder.get(WatchStore.INDEX).getIndex();
|
||||
IndexRoutingTable.Builder indexRoutingTableBuilder = IndexRoutingTable.builder(index);
|
||||
indexRoutingTableBuilder.addIndexShard(new IndexShardRoutingTable.Builder(new ShardId(index, 0))
|
||||
.addShard(TestShardRouting.newShardRouting(WatchStore.INDEX, 0, "_node_id", null, true, ShardRoutingState.STARTED, 1))
|
||||
.build());
|
||||
indexRoutingTableBuilder.addReplica();
|
||||
|
@ -143,8 +146,9 @@ public class WatchStoreTests extends ESTestCase {
|
|||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1)
|
||||
.build();
|
||||
metaDateBuilder.put(IndexMetaData.builder(WatchStore.INDEX).settings(settings).numberOfShards(1).numberOfReplicas(1));
|
||||
IndexRoutingTable.Builder indexRoutingTableBuilder = IndexRoutingTable.builder(WatchStore.INDEX);
|
||||
indexRoutingTableBuilder.addIndexShard(new IndexShardRoutingTable.Builder(new ShardId(WatchStore.INDEX, 0))
|
||||
final Index index = metaDateBuilder.get(WatchStore.INDEX).getIndex();
|
||||
IndexRoutingTable.Builder indexRoutingTableBuilder = IndexRoutingTable.builder(index);
|
||||
indexRoutingTableBuilder.addIndexShard(new IndexShardRoutingTable.Builder(new ShardId(index, 0))
|
||||
.addShard(TestShardRouting.newShardRouting(WatchStore.INDEX, 0, "_node_id", null, true, ShardRoutingState.STARTED, 1))
|
||||
.build());
|
||||
indexRoutingTableBuilder.addReplica();
|
||||
|
@ -181,8 +185,9 @@ public class WatchStoreTests extends ESTestCase {
|
|||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1)
|
||||
.build();
|
||||
metaDateBuilder.put(IndexMetaData.builder(WatchStore.INDEX).settings(settings).numberOfShards(1).numberOfReplicas(1));
|
||||
IndexRoutingTable.Builder indexRoutingTableBuilder = IndexRoutingTable.builder(WatchStore.INDEX);
|
||||
indexRoutingTableBuilder.addIndexShard(new IndexShardRoutingTable.Builder(new ShardId(WatchStore.INDEX, 0))
|
||||
final Index index = metaDateBuilder.get(WatchStore.INDEX).getIndex();
|
||||
IndexRoutingTable.Builder indexRoutingTableBuilder = IndexRoutingTable.builder(index);
|
||||
indexRoutingTableBuilder.addIndexShard(new IndexShardRoutingTable.Builder(new ShardId(index, 0))
|
||||
.addShard(TestShardRouting.newShardRouting(WatchStore.INDEX, 0, "_node_id", null, true, ShardRoutingState.STARTED, 1))
|
||||
.build());
|
||||
indexRoutingTableBuilder.addReplica();
|
||||
|
@ -217,8 +222,9 @@ public class WatchStoreTests extends ESTestCase {
|
|||
.put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 1)
|
||||
.build();
|
||||
metaDateBuilder.put(IndexMetaData.builder(WatchStore.INDEX).settings(settings).numberOfShards(1).numberOfReplicas(1));
|
||||
IndexRoutingTable.Builder indexRoutingTableBuilder = IndexRoutingTable.builder(WatchStore.INDEX);
|
||||
indexRoutingTableBuilder.addIndexShard(new IndexShardRoutingTable.Builder(new ShardId(WatchStore.INDEX, 0))
|
||||
final Index index = metaDateBuilder.get(WatchStore.INDEX).getIndex();
|
||||
IndexRoutingTable.Builder indexRoutingTableBuilder = IndexRoutingTable.builder(index);
|
||||
indexRoutingTableBuilder.addIndexShard(new IndexShardRoutingTable.Builder(new ShardId(index, 0))
|
||||
.addShard(TestShardRouting.newShardRouting(WatchStore.INDEX, 0, "_node_id", null, true, ShardRoutingState.STARTED, 1))
|
||||
.build());
|
||||
indexRoutingTableBuilder.addReplica();
|
||||
|
|
Loading…
Reference in New Issue