|
19 | 19 |
|
20 | 20 | package org.elasticsearch.test; |
21 | 21 |
|
22 | | -import com.carrotsearch.hppc.ObjectLongMap; |
23 | | -import com.carrotsearch.hppc.cursors.IntObjectCursor; |
24 | | -import com.carrotsearch.hppc.cursors.ObjectObjectCursor; |
25 | 22 | import com.carrotsearch.randomizedtesting.RandomizedContext; |
26 | 23 | import com.carrotsearch.randomizedtesting.annotations.TestGroup; |
27 | 24 | import com.carrotsearch.randomizedtesting.generators.RandomNumbers; |
28 | 25 | import com.carrotsearch.randomizedtesting.generators.RandomPicks; |
29 | 26 | import org.apache.http.HttpHost; |
30 | 27 | import org.apache.lucene.search.Sort; |
31 | | -import org.apache.lucene.store.AlreadyClosedException; |
32 | 28 | import org.apache.lucene.util.LuceneTestCase; |
33 | 29 | import org.elasticsearch.ElasticsearchException; |
34 | 30 | import org.elasticsearch.ExceptionsHelper; |
|
78 | 74 | import org.elasticsearch.cluster.metadata.MappingMetaData; |
79 | 75 | import org.elasticsearch.cluster.metadata.MetaData; |
80 | 76 | import org.elasticsearch.cluster.metadata.RepositoriesMetaData; |
81 | | -import org.elasticsearch.cluster.node.DiscoveryNode; |
82 | 77 | import org.elasticsearch.cluster.routing.IndexRoutingTable; |
83 | 78 | import org.elasticsearch.cluster.routing.IndexShardRoutingTable; |
84 | 79 | import org.elasticsearch.cluster.routing.ShardRouting; |
|
125 | 120 | import org.elasticsearch.index.MergeSchedulerConfig; |
126 | 121 | import org.elasticsearch.index.MockEngineFactoryPlugin; |
127 | 122 | import org.elasticsearch.index.codec.CodecService; |
128 | | -import org.elasticsearch.index.engine.DocIdSeqNoAndTerm; |
129 | 123 | import org.elasticsearch.index.engine.Segment; |
130 | 124 | import org.elasticsearch.index.mapper.MappedFieldType; |
131 | 125 | import org.elasticsearch.index.mapper.MapperService; |
132 | 126 | import org.elasticsearch.index.mapper.MockFieldFilterPlugin; |
133 | | -import org.elasticsearch.index.seqno.SeqNoStats; |
134 | | -import org.elasticsearch.index.seqno.SequenceNumbers; |
135 | | -import org.elasticsearch.index.shard.IndexShard; |
136 | | -import org.elasticsearch.index.shard.IndexShardTestCase; |
137 | 127 | import org.elasticsearch.index.translog.Translog; |
138 | 128 | import org.elasticsearch.indices.IndicesQueryCache; |
139 | 129 | import org.elasticsearch.indices.IndicesRequestCache; |
|
197 | 187 | import java.util.concurrent.TimeUnit; |
198 | 188 | import java.util.concurrent.atomic.AtomicInteger; |
199 | 189 | import java.util.concurrent.atomic.AtomicLong; |
200 | | -import java.util.function.BiFunction; |
201 | 190 | import java.util.function.BooleanSupplier; |
202 | 191 | import java.util.function.Function; |
203 | 192 | import java.util.stream.Collectors; |
|
221 | 210 | import static org.hamcrest.Matchers.equalTo; |
222 | 211 | import static org.hamcrest.Matchers.is; |
223 | 212 | import static org.hamcrest.Matchers.lessThanOrEqualTo; |
224 | | -import static org.hamcrest.Matchers.not; |
225 | 213 | import static org.hamcrest.Matchers.notNullValue; |
226 | 214 | import static org.hamcrest.Matchers.startsWith; |
227 | 215 |
|
@@ -2359,108 +2347,6 @@ public static Index resolveIndex(String index) { |
2359 | 2347 | return new Index(index, uuid); |
2360 | 2348 | } |
2361 | 2349 |
|
2362 | | - protected void assertSeqNos() throws Exception { |
2363 | | - final BiFunction<ClusterState, ShardRouting, IndexShard> getInstanceShardInstance = (clusterState, shardRouting) -> { |
2364 | | - if (shardRouting.assignedToNode() == false) { |
2365 | | - return null; |
2366 | | - } |
2367 | | - final DiscoveryNode assignedNode = clusterState.nodes().get(shardRouting.currentNodeId()); |
2368 | | - if (assignedNode == null) { |
2369 | | - return null; |
2370 | | - } |
2371 | | - return internalCluster().getInstance(IndicesService.class, assignedNode.getName()).getShardOrNull(shardRouting.shardId()); |
2372 | | - }; |
2373 | | - assertBusy(() -> { |
2374 | | - final ClusterState state = clusterService().state(); |
2375 | | - for (ObjectObjectCursor<String, IndexRoutingTable> indexRoutingTable : state.routingTable().indicesRouting()) { |
2376 | | - for (IntObjectCursor<IndexShardRoutingTable> indexShardRoutingTable : indexRoutingTable.value.shards()) { |
2377 | | - ShardRouting primaryShardRouting = indexShardRoutingTable.value.primaryShard(); |
2378 | | - if (primaryShardRouting == null) { |
2379 | | - continue; |
2380 | | - } |
2381 | | - final IndexShard primaryShard = getInstanceShardInstance.apply(state, primaryShardRouting); |
2382 | | - if (primaryShard == null) { |
2383 | | - continue; //just ignore - shard movement |
2384 | | - } |
2385 | | - final SeqNoStats primarySeqNoStats; |
2386 | | - final ObjectLongMap<String> syncGlobalCheckpoints; |
2387 | | - try { |
2388 | | - primarySeqNoStats = primaryShard.seqNoStats(); |
2389 | | - syncGlobalCheckpoints = primaryShard.getInSyncGlobalCheckpoints(); |
2390 | | - } catch (AlreadyClosedException ex) { |
2391 | | - continue; // shard is closed - just ignore |
2392 | | - } |
2393 | | - assertThat(primaryShardRouting + " should have set the global checkpoint", |
2394 | | - primarySeqNoStats.getGlobalCheckpoint(), not(equalTo(SequenceNumbers.UNASSIGNED_SEQ_NO))); |
2395 | | - for (ShardRouting replicaShardRouting : indexShardRoutingTable.value.replicaShards()) { |
2396 | | - final IndexShard replicaShard = getInstanceShardInstance.apply(state, replicaShardRouting); |
2397 | | - if (replicaShard == null) { |
2398 | | - continue; //just ignore - shard movement |
2399 | | - } |
2400 | | - final SeqNoStats seqNoStats; |
2401 | | - try { |
2402 | | - seqNoStats = replicaShard.seqNoStats(); |
2403 | | - } catch (AlreadyClosedException e) { |
2404 | | - continue; // shard is closed - just ignore |
2405 | | - } |
2406 | | - assertThat(replicaShardRouting + " local checkpoint mismatch", |
2407 | | - seqNoStats.getLocalCheckpoint(), equalTo(primarySeqNoStats.getLocalCheckpoint())); |
2408 | | - assertThat(replicaShardRouting + " global checkpoint mismatch", |
2409 | | - seqNoStats.getGlobalCheckpoint(), equalTo(primarySeqNoStats.getGlobalCheckpoint())); |
2410 | | - assertThat(replicaShardRouting + " max seq no mismatch", |
2411 | | - seqNoStats.getMaxSeqNo(), equalTo(primarySeqNoStats.getMaxSeqNo())); |
2412 | | - // the local knowledge on the primary of the global checkpoint equals the global checkpoint on the shard |
2413 | | - assertThat(replicaShardRouting + " global checkpoint syncs mismatch", seqNoStats.getGlobalCheckpoint(), |
2414 | | - equalTo(syncGlobalCheckpoints.get(replicaShardRouting.allocationId().getId()))); |
2415 | | - } |
2416 | | - } |
2417 | | - } |
2418 | | - }); |
2419 | | - } |
2420 | | - |
2421 | | - /** |
2422 | | - * Asserts that all shards with the same shardId should have document Ids. |
2423 | | - */ |
2424 | | - public void assertSameDocIdsOnShards() throws Exception { |
2425 | | - assertBusy(() -> { |
2426 | | - ClusterState state = client().admin().cluster().prepareState().get().getState(); |
2427 | | - for (ObjectObjectCursor<String, IndexRoutingTable> indexRoutingTable : state.routingTable().indicesRouting()) { |
2428 | | - for (IntObjectCursor<IndexShardRoutingTable> indexShardRoutingTable : indexRoutingTable.value.shards()) { |
2429 | | - ShardRouting primaryShardRouting = indexShardRoutingTable.value.primaryShard(); |
2430 | | - if (primaryShardRouting == null || primaryShardRouting.assignedToNode() == false) { |
2431 | | - continue; |
2432 | | - } |
2433 | | - DiscoveryNode primaryNode = state.nodes().get(primaryShardRouting.currentNodeId()); |
2434 | | - IndexShard primaryShard = internalCluster().getInstance(IndicesService.class, primaryNode.getName()) |
2435 | | - .indexServiceSafe(primaryShardRouting.index()).getShard(primaryShardRouting.id()); |
2436 | | - final List<DocIdSeqNoAndTerm> docsOnPrimary; |
2437 | | - try { |
2438 | | - docsOnPrimary = IndexShardTestCase.getDocIdAndSeqNos(primaryShard); |
2439 | | - } catch (AlreadyClosedException ex) { |
2440 | | - continue; |
2441 | | - } |
2442 | | - for (ShardRouting replicaShardRouting : indexShardRoutingTable.value.replicaShards()) { |
2443 | | - if (replicaShardRouting.assignedToNode() == false) { |
2444 | | - continue; |
2445 | | - } |
2446 | | - DiscoveryNode replicaNode = state.nodes().get(replicaShardRouting.currentNodeId()); |
2447 | | - IndexShard replicaShard = internalCluster().getInstance(IndicesService.class, replicaNode.getName()) |
2448 | | - .indexServiceSafe(replicaShardRouting.index()).getShard(replicaShardRouting.id()); |
2449 | | - final List<DocIdSeqNoAndTerm> docsOnReplica; |
2450 | | - try { |
2451 | | - docsOnReplica = IndexShardTestCase.getDocIdAndSeqNos(replicaShard); |
2452 | | - } catch (AlreadyClosedException ex) { |
2453 | | - continue; |
2454 | | - } |
2455 | | - assertThat("out of sync shards: primary=[" + primaryShardRouting + "] num_docs_on_primary=[" + docsOnPrimary.size() |
2456 | | - + "] vs replica=[" + replicaShardRouting + "] num_docs_on_replica=[" + docsOnReplica.size() + "]", |
2457 | | - docsOnReplica, equalTo(docsOnPrimary)); |
2458 | | - } |
2459 | | - } |
2460 | | - } |
2461 | | - }); |
2462 | | - } |
2463 | | - |
2464 | 2350 | public static boolean inFipsJvm() { |
2465 | 2351 | return Security.getProviders()[0].getName().toLowerCase(Locale.ROOT).contains("fips"); |
2466 | 2352 | } |
|
0 commit comments