|
73 | 73 | import org.elasticsearch.action.index.IndexRequest; |
74 | 74 | import org.elasticsearch.action.support.TransportActions; |
75 | 75 | import org.elasticsearch.cluster.metadata.IndexMetaData; |
| 76 | +import org.elasticsearch.cluster.routing.AllocationId; |
76 | 77 | import org.elasticsearch.cluster.routing.IndexShardRoutingTable; |
77 | 78 | import org.elasticsearch.cluster.routing.ShardRouting; |
78 | 79 | import org.elasticsearch.cluster.routing.ShardRoutingState; |
79 | 80 | import org.elasticsearch.cluster.routing.TestShardRouting; |
80 | 81 | import org.elasticsearch.common.Nullable; |
81 | 82 | import org.elasticsearch.common.Randomness; |
82 | 83 | import org.elasticsearch.common.Strings; |
| 84 | +import org.elasticsearch.common.UUIDs; |
83 | 85 | import org.elasticsearch.common.bytes.BytesArray; |
84 | 86 | import org.elasticsearch.common.bytes.BytesReference; |
85 | 87 | import org.elasticsearch.common.collect.Tuple; |
|
198 | 200 | public class InternalEngineTests extends ESTestCase { |
199 | 201 |
|
200 | 202 | protected final ShardId shardId = new ShardId(new Index("index", "_na_"), 0); |
| 203 | + protected final AllocationId allocationId = AllocationId.newInitializing(); |
201 | 204 | private static final IndexSettings INDEX_SETTINGS = IndexSettingsModule.newIndexSettings("index", Settings.EMPTY); |
202 | 205 |
|
203 | 206 | protected ThreadPool threadPool; |
@@ -264,11 +267,11 @@ public EngineConfig copy(EngineConfig config, EngineConfig.OpenMode openMode) { |
264 | 267 | } |
265 | 268 |
|
266 | 269 | public EngineConfig copy(EngineConfig config, EngineConfig.OpenMode openMode, Analyzer analyzer) { |
267 | | - return new EngineConfig(openMode, config.getShardId(), config.getThreadPool(), config.getIndexSettings(), config.getWarmer(), |
268 | | - config.getStore(), config.getMergePolicy(), analyzer, config.getSimilarity(), |
269 | | - new CodecService(null, logger), config.getEventListener(), config.getQueryCache(), |
270 | | - config.getQueryCachingPolicy(), config.getTranslogConfig(), |
271 | | - config.getFlushMergesAfter(), config.getRefreshListeners(), config.getIndexSort(), config.getTranslogRecoveryRunner()); |
| 270 | + return new EngineConfig(openMode, config.getShardId(), config.getAllocationId(), config.getThreadPool(), config.getIndexSettings(), |
| 271 | + config.getWarmer(), config.getStore(), config.getMergePolicy(), analyzer, config.getSimilarity(), |
| 272 | + new CodecService(null, logger), config.getEventListener(), config.getQueryCache(), config.getQueryCachingPolicy(), |
| 273 | + config.getTranslogConfig(), config.getFlushMergesAfter(), config.getRefreshListeners(), config.getIndexSort(), |
| 274 | + config.getTranslogRecoveryRunner()); |
272 | 275 | } |
273 | 276 |
|
274 | 277 | @Override |
@@ -447,7 +450,7 @@ public void onFailedEngine(String reason, @Nullable Exception e) { |
447 | 450 | indexSettings.getSettings())); |
448 | 451 | final List<ReferenceManager.RefreshListener> refreshListenerList = |
449 | 452 | refreshListener == null ? emptyList() : Collections.singletonList(refreshListener); |
450 | | - EngineConfig config = new EngineConfig(openMode, shardId, threadPool, indexSettings, null, store, |
| 453 | + EngineConfig config = new EngineConfig(openMode, shardId, allocationId.getId(), threadPool, indexSettings, null, store, |
451 | 454 | mergePolicy, iwc.getAnalyzer(), iwc.getSimilarity(), new CodecService(null, logger), listener, |
452 | 455 | IndexSearcher.getDefaultQueryCache(), IndexSearcher.getDefaultQueryCachingPolicy(), translogConfig, |
453 | 456 | TimeValue.timeValueMinutes(5), refreshListenerList, indexSort, handler); |
@@ -728,6 +731,7 @@ public void testCommitStats() throws IOException { |
728 | 731 | Store store = createStore(); |
729 | 732 | InternalEngine engine = createEngine(store, createTempDir(), (config) -> new SequenceNumbersService( |
730 | 733 | config.getShardId(), |
| 734 | + config.getAllocationId(), |
731 | 735 | config.getIndexSettings(), |
732 | 736 | maxSeqNo.get(), |
733 | 737 | localCheckpoint.get(), |
@@ -901,6 +905,7 @@ public void testTranslogRecoveryWithMultipleGenerations() throws IOException { |
901 | 905 | initialEngine = createEngine(store, createTempDir(), (config) -> |
902 | 906 | new SequenceNumbersService( |
903 | 907 | config.getShardId(), |
| 908 | + config.getAllocationId(), |
904 | 909 | config.getIndexSettings(), |
905 | 910 | SequenceNumbers.NO_OPS_PERFORMED, |
906 | 911 | SequenceNumbers.NO_OPS_PERFORMED, |
@@ -2028,7 +2033,7 @@ public void testSeqNoAndCheckpoints() throws IOException { |
2028 | 2033 |
|
2029 | 2034 | try { |
2030 | 2035 | initialEngine = engine; |
2031 | | - final ShardRouting primary = TestShardRouting.newShardRouting(shardId, "node1", true, ShardRoutingState.STARTED); |
| 2036 | + final ShardRouting primary = TestShardRouting.newShardRouting("test", shardId.id(), "node1", null, true, ShardRoutingState.STARTED, allocationId); |
2032 | 2037 | final ShardRouting replica = TestShardRouting.newShardRouting(shardId, "node2", false, ShardRoutingState.STARTED); |
2033 | 2038 | initialEngine.seqNoService().updateAllocationIdsFromMaster(1L, new HashSet<>(Arrays.asList(primary.allocationId().getId(), |
2034 | 2039 | replica.allocationId().getId())), |
@@ -2788,12 +2793,11 @@ public void testRecoverFromForeignTranslog() throws IOException { |
2788 | 2793 | TranslogConfig translogConfig = new TranslogConfig(shardId, translog.location(), config.getIndexSettings(), |
2789 | 2794 | BigArrays.NON_RECYCLING_INSTANCE); |
2790 | 2795 |
|
2791 | | - EngineConfig brokenConfig = new EngineConfig(EngineConfig.OpenMode.OPEN_INDEX_AND_TRANSLOG, shardId, threadPool, |
2792 | | - config.getIndexSettings(), null, store, newMergePolicy(), config.getAnalyzer(), |
2793 | | - config.getSimilarity(), new CodecService(null, logger), config.getEventListener(), |
2794 | | - IndexSearcher.getDefaultQueryCache(), IndexSearcher.getDefaultQueryCachingPolicy(), translogConfig, |
2795 | | - TimeValue.timeValueMinutes(5), config.getRefreshListeners(), null, |
2796 | | - config.getTranslogRecoveryRunner()); |
| 2796 | + EngineConfig brokenConfig = new EngineConfig(EngineConfig.OpenMode.OPEN_INDEX_AND_TRANSLOG, shardId, allocationId.getId(), |
| 2797 | + threadPool, config.getIndexSettings(), null, store, newMergePolicy(), config.getAnalyzer(), config.getSimilarity(), |
| 2798 | + new CodecService(null, logger), config.getEventListener(), IndexSearcher.getDefaultQueryCache(), |
| 2799 | + IndexSearcher.getDefaultQueryCachingPolicy(), translogConfig, TimeValue.timeValueMinutes(5), config.getRefreshListeners(), |
| 2800 | + null, config.getTranslogRecoveryRunner()); |
2797 | 2801 |
|
2798 | 2802 | try { |
2799 | 2803 | InternalEngine internalEngine = new InternalEngine(brokenConfig); |
@@ -3628,6 +3632,7 @@ private SequenceNumbersService getStallingSeqNoService( |
3628 | 3632 | final AtomicLong expectedLocalCheckpoint) { |
3629 | 3633 | return new SequenceNumbersService( |
3630 | 3634 | shardId, |
| 3635 | + allocationId.getId(), |
3631 | 3636 | defaultSettings, |
3632 | 3637 | SequenceNumbers.NO_OPS_PERFORMED, |
3633 | 3638 | SequenceNumbers.NO_OPS_PERFORMED, |
@@ -3839,7 +3844,7 @@ public void testNoOps() throws IOException { |
3839 | 3844 | final int globalCheckpoint = randomIntBetween(0, localCheckpoint); |
3840 | 3845 | try { |
3841 | 3846 | final SequenceNumbersService seqNoService = |
3842 | | - new SequenceNumbersService(shardId, defaultSettings, maxSeqNo, localCheckpoint, globalCheckpoint) { |
| 3847 | + new SequenceNumbersService(shardId, allocationId.getId(), defaultSettings, maxSeqNo, localCheckpoint, globalCheckpoint) { |
3843 | 3848 | @Override |
3844 | 3849 | public long generateSeqNo() { |
3845 | 3850 | throw new UnsupportedOperationException(); |
@@ -3986,6 +3991,7 @@ public void testRestoreLocalCheckpointFromTranslog() throws IOException { |
3986 | 3991 | final SequenceNumbersService seqNoService = |
3987 | 3992 | new SequenceNumbersService( |
3988 | 3993 | shardId, |
| 3994 | + allocationId.getId(), |
3989 | 3995 | defaultSettings, |
3990 | 3996 | SequenceNumbers.NO_OPS_PERFORMED, |
3991 | 3997 | SequenceNumbers.NO_OPS_PERFORMED, |
|
0 commit comments