Skip to content

Commit cffb69d

Browse files
committed
use indexsettings
1 parent e14bb7e commit cffb69d

File tree

8 files changed

+15
-35
lines changed

8 files changed

+15
-35
lines changed

server/src/internalClusterTest/java/org/elasticsearch/index/shard/IndexShardIT.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,8 +652,7 @@ public static final IndexShard newIndexShard(
652652
Arrays.asList(listeners),
653653
() -> {},
654654
RetentionLeaseSyncer.EMPTY,
655-
cbs,
656-
false);
655+
cbs);
657656
}
658657

659658
private static ShardRouting getInitializingShardRouting(ShardRouting existingShardRouting) {

server/src/main/java/org/elasticsearch/index/IndexModule.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ public final class IndexModule {
141141
private final AtomicBoolean frozen = new AtomicBoolean(false);
142142
private final BooleanSupplier allowExpensiveQueries;
143143
private final Map<String, IndexStorePlugin.RecoveryStateFactory> recoveryStateFactories;
144-
private final boolean isSystem;
145144

146145
/**
147146
* Construct the index module for the index with the specified index settings. The index module contains extension points for plugins
@@ -159,8 +158,7 @@ public IndexModule(
159158
final Map<String, IndexStorePlugin.DirectoryFactory> directoryFactories,
160159
final BooleanSupplier allowExpensiveQueries,
161160
final IndexNameExpressionResolver expressionResolver,
162-
final Map<String, IndexStorePlugin.RecoveryStateFactory> recoveryStateFactories,
163-
final boolean isSystem) {
161+
final Map<String, IndexStorePlugin.RecoveryStateFactory> recoveryStateFactories) {
164162
this.indexSettings = indexSettings;
165163
this.analysisRegistry = analysisRegistry;
166164
this.engineFactory = Objects.requireNonNull(engineFactory);
@@ -170,7 +168,6 @@ public IndexModule(
170168
this.allowExpensiveQueries = allowExpensiveQueries;
171169
this.expressionResolver = expressionResolver;
172170
this.recoveryStateFactories = recoveryStateFactories;
173-
this.isSystem = isSystem;
174171
}
175172

176173
/**
@@ -445,7 +442,7 @@ public IndexService newIndexService(IndexService.IndexCreationContext indexCreat
445442
engineFactory, circuitBreakerService, bigArrays, threadPool, scriptService, clusterService, client, queryCache,
446443
directoryFactory, eventListener, readerWrapperFactory, mapperRegistry, indicesFieldDataCache, searchOperationListeners,
447444
indexOperationListeners, namedWriteableRegistry, idFieldDataEnabled, allowExpensiveQueries, expressionResolver,
448-
valuesSourceRegistry, recoveryStateFactory, isSystem);
445+
valuesSourceRegistry, recoveryStateFactory);
449446
success = true;
450447
return indexService;
451448
} finally {

server/src/main/java/org/elasticsearch/index/IndexService.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ public class IndexService extends AbstractIndexComponent implements IndicesClust
150150
private final IndexNameExpressionResolver expressionResolver;
151151
private final Supplier<Sort> indexSortSupplier;
152152
private final ValuesSourceRegistry valuesSourceRegistry;
153-
private final boolean isSystem;
154153

155154
public IndexService(
156155
IndexSettings indexSettings,
@@ -179,8 +178,7 @@ public IndexService(
179178
BooleanSupplier allowExpensiveQueries,
180179
IndexNameExpressionResolver expressionResolver,
181180
ValuesSourceRegistry valuesSourceRegistry,
182-
IndexStorePlugin.RecoveryStateFactory recoveryStateFactory,
183-
boolean isSystem) {
181+
IndexStorePlugin.RecoveryStateFactory recoveryStateFactory) {
184182
super(indexSettings);
185183
this.allowExpensiveQueries = allowExpensiveQueries;
186184
this.indexSettings = indexSettings;
@@ -240,7 +238,6 @@ public IndexService(
240238
this.trimTranslogTask = new AsyncTrimTranslogTask(this);
241239
this.globalCheckpointTask = new AsyncGlobalCheckpointTask(this);
242240
this.retentionLeaseSyncTask = new AsyncRetentionLeaseSyncTask(this);
243-
this.isSystem = isSystem;
244241
updateFsyncTaskIfNecessary();
245242
}
246243

@@ -482,8 +479,7 @@ public synchronized IndexShard createShard(
482479
indexingOperationListeners,
483480
() -> globalCheckpointSyncer.accept(shardId),
484481
retentionLeaseSyncer,
485-
circuitBreakerService,
486-
isSystem);
482+
circuitBreakerService);
487483
eventListener.indexShardStateChanged(indexShard, null, indexShard.state(), "shard created");
488484
eventListener.afterIndexShardCreated(indexShard);
489485
shards = Maps.copyMapWithAddedEntry(shards, shardId.id(), indexShard);

server/src/main/java/org/elasticsearch/index/shard/IndexShard.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ Runnable getGlobalCheckpointSyncer() {
275275
private final AtomicLong lastSearcherAccess = new AtomicLong();
276276
private final AtomicReference<Translog.Location> pendingRefreshLocation = new AtomicReference<>();
277277
private final RefreshPendingLocationListener refreshPendingLocationListener;
278-
private final boolean isSystem;
279278
private volatile boolean useRetentionLeasesInPeerRecovery;
280279

281280
public IndexShard(
@@ -297,8 +296,7 @@ public IndexShard(
297296
final List<IndexingOperationListener> listeners,
298297
final Runnable globalCheckpointSyncer,
299298
final RetentionLeaseSyncer retentionLeaseSyncer,
300-
final CircuitBreakerService circuitBreakerService,
301-
final boolean isSystem) throws IOException {
299+
final CircuitBreakerService circuitBreakerService) throws IOException {
302300
super(shardRouting.shardId(), indexSettings);
303301
assert shardRouting.initializing();
304302
this.shardRouting = shardRouting;
@@ -379,7 +377,6 @@ public boolean shouldCache(Query query) {
379377
persistMetadata(path, indexSettings, shardRouting, null, logger);
380378
this.useRetentionLeasesInPeerRecovery = replicationTracker.hasAllPeerRecoveryRetentionLeases();
381379
this.refreshPendingLocationListener = new RefreshPendingLocationListener();
382-
this.isSystem = isSystem;
383380
}
384381

385382
public ThreadPool getThreadPool() {
@@ -430,7 +427,7 @@ public ShardFieldData fieldData() {
430427
}
431428

432429
public boolean isSystem() {
433-
return isSystem;
430+
return indexSettings.getIndexMetadata().isSystem();
434431
}
435432

436433
/**

server/src/main/java/org/elasticsearch/indices/IndicesService.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -643,8 +643,7 @@ private synchronized IndexService createIndexService(IndexService.IndexCreationC
643643
indexCreationContext);
644644

645645
final IndexModule indexModule = new IndexModule(idxSettings, analysisRegistry, getEngineFactory(idxSettings),
646-
directoryFactories, () -> allowExpensiveQueries, indexNameExpressionResolver, recoveryStateFactories,
647-
isSystemIndex(indexMetadata));
646+
directoryFactories, () -> allowExpensiveQueries, indexNameExpressionResolver, recoveryStateFactories);
648647
for (IndexingOperationListener operationListener : indexingOperationListeners) {
649648
indexModule.addIndexOperationListener(operationListener);
650649
}
@@ -672,10 +671,6 @@ private synchronized IndexService createIndexService(IndexService.IndexCreationC
672671
);
673672
}
674673

675-
private boolean isSystemIndex(IndexMetadata indexMetadata) {
676-
return indexMetadata.isSystem();
677-
}
678-
679674
private EngineFactory getEngineFactory(final IndexSettings idxSettings) {
680675
final IndexMetadata indexMetadata = idxSettings.getIndexMetadata();
681676
if (indexMetadata != null && indexMetadata.getState() == IndexMetadata.State.CLOSE) {
@@ -719,8 +714,7 @@ private EngineFactory getEngineFactory(final IndexSettings idxSettings) {
719714
public synchronized MapperService createIndexMapperService(IndexMetadata indexMetadata) throws IOException {
720715
final IndexSettings idxSettings = new IndexSettings(indexMetadata, this.settings, indexScopedSettings);
721716
final IndexModule indexModule = new IndexModule(idxSettings, analysisRegistry, getEngineFactory(idxSettings),
722-
directoryFactories, () -> allowExpensiveQueries, indexNameExpressionResolver, recoveryStateFactories,
723-
isSystemIndex(indexMetadata));
717+
directoryFactories, () -> allowExpensiveQueries, indexNameExpressionResolver, recoveryStateFactories);
724718
pluginsService.onIndexModule(indexModule);
725719
return indexModule.newIndexMapperService(xContentRegistry, mapperRegistry, scriptService);
726720
}

server/src/test/java/org/elasticsearch/index/IndexModuleTests.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,7 @@ public void testWrapperIsBound() throws IOException {
181181
Collections.emptyMap(),
182182
() -> true,
183183
new IndexNameExpressionResolver(),
184-
Collections.emptyMap(),
185-
randomBoolean());
184+
Collections.emptyMap());
186185
module.setReaderWrapper(s -> new Wrapper());
187186

188187
IndexService indexService = newIndexService(module);
@@ -203,7 +202,7 @@ public void testRegisterIndexStore() throws IOException {
203202
final Map<String, IndexStorePlugin.DirectoryFactory> indexStoreFactories = singletonMap(
204203
"foo_store", new FooFunction());
205204
final IndexModule module = new IndexModule(indexSettings, emptyAnalysisRegistry, new InternalEngineFactory(), indexStoreFactories,
206-
() -> true, new IndexNameExpressionResolver(), Collections.emptyMap(), randomBoolean());
205+
() -> true, new IndexNameExpressionResolver(), Collections.emptyMap());
207206

208207
final IndexService indexService = newIndexService(module);
209208
assertThat(indexService.getDirectoryFactory(), instanceOf(FooFunction.class));
@@ -519,8 +518,7 @@ public void testRegisterCustomRecoveryStateFactory() throws IOException {
519518
Collections.emptyMap(),
520519
() -> true,
521520
new IndexNameExpressionResolver(),
522-
recoveryStateFactories,
523-
randomBoolean());
521+
recoveryStateFactories);
524522

525523
final IndexService indexService = newIndexService(module);
526524

@@ -540,7 +538,7 @@ private ShardRouting createInitializedShardRouting() {
540538

541539
private static IndexModule createIndexModule(IndexSettings indexSettings, AnalysisRegistry emptyAnalysisRegistry) {
542540
return new IndexModule(indexSettings, emptyAnalysisRegistry, new InternalEngineFactory(), Collections.emptyMap(), () -> true,
543-
new IndexNameExpressionResolver(), Collections.emptyMap(), randomBoolean());
541+
new IndexNameExpressionResolver(), Collections.emptyMap());
544542
}
545543

546544
class CustomQueryCache implements QueryCache {

test/framework/src/main/java/org/elasticsearch/index/shard/IndexShardTestCase.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,7 @@ protected IndexShard newShard(ShardRouting routing, ShardPath shardPath, IndexMe
398398
Arrays.asList(listeners),
399399
globalCheckpointSyncer,
400400
retentionLeaseSyncer,
401-
breakerService,
402-
randomBoolean());
401+
breakerService);
403402
indexShard.addShardFailureCallback(DEFAULT_SHARD_FAILURE_HANDLER);
404403
success = true;
405404
} finally {

x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void testWatcherDisabledTests() throws Exception {
7676
AnalysisRegistry registry = new AnalysisRegistry(TestEnvironment.newEnvironment(settings), emptyMap(), emptyMap(), emptyMap(),
7777
emptyMap(), emptyMap(), emptyMap(), emptyMap(), emptyMap(), emptyMap());
7878
IndexModule indexModule = new IndexModule(indexSettings, registry, new InternalEngineFactory(), Collections.emptyMap(),
79-
() -> true, new IndexNameExpressionResolver(), Collections.emptyMap(), randomBoolean());
79+
() -> true, new IndexNameExpressionResolver(), Collections.emptyMap());
8080
// this will trip an assertion if the watcher indexing operation listener is null (which it is) but we try to add it
8181
watcher.onIndexModule(indexModule);
8282

0 commit comments

Comments
 (0)