Skip to content

Commit

Permalink
use indexsettings
Browse files Browse the repository at this point in the history
  • Loading branch information
jaymode committed Jul 30, 2020
1 parent e14bb7e commit cffb69d
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -652,8 +652,7 @@ public static final IndexShard newIndexShard(
Arrays.asList(listeners),
() -> {},
RetentionLeaseSyncer.EMPTY,
cbs,
false);
cbs);
}

private static ShardRouting getInitializingShardRouting(ShardRouting existingShardRouting) {
Expand Down
7 changes: 2 additions & 5 deletions server/src/main/java/org/elasticsearch/index/IndexModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ public final class IndexModule {
private final AtomicBoolean frozen = new AtomicBoolean(false);
private final BooleanSupplier allowExpensiveQueries;
private final Map<String, IndexStorePlugin.RecoveryStateFactory> recoveryStateFactories;
private final boolean isSystem;

/**
* Construct the index module for the index with the specified index settings. The index module contains extension points for plugins
Expand All @@ -159,8 +158,7 @@ public IndexModule(
final Map<String, IndexStorePlugin.DirectoryFactory> directoryFactories,
final BooleanSupplier allowExpensiveQueries,
final IndexNameExpressionResolver expressionResolver,
final Map<String, IndexStorePlugin.RecoveryStateFactory> recoveryStateFactories,
final boolean isSystem) {
final Map<String, IndexStorePlugin.RecoveryStateFactory> recoveryStateFactories) {
this.indexSettings = indexSettings;
this.analysisRegistry = analysisRegistry;
this.engineFactory = Objects.requireNonNull(engineFactory);
Expand All @@ -170,7 +168,6 @@ public IndexModule(
this.allowExpensiveQueries = allowExpensiveQueries;
this.expressionResolver = expressionResolver;
this.recoveryStateFactories = recoveryStateFactories;
this.isSystem = isSystem;
}

/**
Expand Down Expand Up @@ -445,7 +442,7 @@ public IndexService newIndexService(IndexService.IndexCreationContext indexCreat
engineFactory, circuitBreakerService, bigArrays, threadPool, scriptService, clusterService, client, queryCache,
directoryFactory, eventListener, readerWrapperFactory, mapperRegistry, indicesFieldDataCache, searchOperationListeners,
indexOperationListeners, namedWriteableRegistry, idFieldDataEnabled, allowExpensiveQueries, expressionResolver,
valuesSourceRegistry, recoveryStateFactory, isSystem);
valuesSourceRegistry, recoveryStateFactory);
success = true;
return indexService;
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ public class IndexService extends AbstractIndexComponent implements IndicesClust
private final IndexNameExpressionResolver expressionResolver;
private final Supplier<Sort> indexSortSupplier;
private final ValuesSourceRegistry valuesSourceRegistry;
private final boolean isSystem;

public IndexService(
IndexSettings indexSettings,
Expand Down Expand Up @@ -179,8 +178,7 @@ public IndexService(
BooleanSupplier allowExpensiveQueries,
IndexNameExpressionResolver expressionResolver,
ValuesSourceRegistry valuesSourceRegistry,
IndexStorePlugin.RecoveryStateFactory recoveryStateFactory,
boolean isSystem) {
IndexStorePlugin.RecoveryStateFactory recoveryStateFactory) {
super(indexSettings);
this.allowExpensiveQueries = allowExpensiveQueries;
this.indexSettings = indexSettings;
Expand Down Expand Up @@ -240,7 +238,6 @@ public IndexService(
this.trimTranslogTask = new AsyncTrimTranslogTask(this);
this.globalCheckpointTask = new AsyncGlobalCheckpointTask(this);
this.retentionLeaseSyncTask = new AsyncRetentionLeaseSyncTask(this);
this.isSystem = isSystem;
updateFsyncTaskIfNecessary();
}

Expand Down Expand Up @@ -482,8 +479,7 @@ public synchronized IndexShard createShard(
indexingOperationListeners,
() -> globalCheckpointSyncer.accept(shardId),
retentionLeaseSyncer,
circuitBreakerService,
isSystem);
circuitBreakerService);
eventListener.indexShardStateChanged(indexShard, null, indexShard.state(), "shard created");
eventListener.afterIndexShardCreated(indexShard);
shards = Maps.copyMapWithAddedEntry(shards, shardId.id(), indexShard);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ Runnable getGlobalCheckpointSyncer() {
private final AtomicLong lastSearcherAccess = new AtomicLong();
private final AtomicReference<Translog.Location> pendingRefreshLocation = new AtomicReference<>();
private final RefreshPendingLocationListener refreshPendingLocationListener;
private final boolean isSystem;
private volatile boolean useRetentionLeasesInPeerRecovery;

public IndexShard(
Expand All @@ -297,8 +296,7 @@ public IndexShard(
final List<IndexingOperationListener> listeners,
final Runnable globalCheckpointSyncer,
final RetentionLeaseSyncer retentionLeaseSyncer,
final CircuitBreakerService circuitBreakerService,
final boolean isSystem) throws IOException {
final CircuitBreakerService circuitBreakerService) throws IOException {
super(shardRouting.shardId(), indexSettings);
assert shardRouting.initializing();
this.shardRouting = shardRouting;
Expand Down Expand Up @@ -379,7 +377,6 @@ public boolean shouldCache(Query query) {
persistMetadata(path, indexSettings, shardRouting, null, logger);
this.useRetentionLeasesInPeerRecovery = replicationTracker.hasAllPeerRecoveryRetentionLeases();
this.refreshPendingLocationListener = new RefreshPendingLocationListener();
this.isSystem = isSystem;
}

public ThreadPool getThreadPool() {
Expand Down Expand Up @@ -430,7 +427,7 @@ public ShardFieldData fieldData() {
}

public boolean isSystem() {
return isSystem;
return indexSettings.getIndexMetadata().isSystem();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,7 @@ private synchronized IndexService createIndexService(IndexService.IndexCreationC
indexCreationContext);

final IndexModule indexModule = new IndexModule(idxSettings, analysisRegistry, getEngineFactory(idxSettings),
directoryFactories, () -> allowExpensiveQueries, indexNameExpressionResolver, recoveryStateFactories,
isSystemIndex(indexMetadata));
directoryFactories, () -> allowExpensiveQueries, indexNameExpressionResolver, recoveryStateFactories);
for (IndexingOperationListener operationListener : indexingOperationListeners) {
indexModule.addIndexOperationListener(operationListener);
}
Expand Down Expand Up @@ -672,10 +671,6 @@ private synchronized IndexService createIndexService(IndexService.IndexCreationC
);
}

private boolean isSystemIndex(IndexMetadata indexMetadata) {
return indexMetadata.isSystem();
}

private EngineFactory getEngineFactory(final IndexSettings idxSettings) {
final IndexMetadata indexMetadata = idxSettings.getIndexMetadata();
if (indexMetadata != null && indexMetadata.getState() == IndexMetadata.State.CLOSE) {
Expand Down Expand Up @@ -719,8 +714,7 @@ private EngineFactory getEngineFactory(final IndexSettings idxSettings) {
public synchronized MapperService createIndexMapperService(IndexMetadata indexMetadata) throws IOException {
final IndexSettings idxSettings = new IndexSettings(indexMetadata, this.settings, indexScopedSettings);
final IndexModule indexModule = new IndexModule(idxSettings, analysisRegistry, getEngineFactory(idxSettings),
directoryFactories, () -> allowExpensiveQueries, indexNameExpressionResolver, recoveryStateFactories,
isSystemIndex(indexMetadata));
directoryFactories, () -> allowExpensiveQueries, indexNameExpressionResolver, recoveryStateFactories);
pluginsService.onIndexModule(indexModule);
return indexModule.newIndexMapperService(xContentRegistry, mapperRegistry, scriptService);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ public void testWrapperIsBound() throws IOException {
Collections.emptyMap(),
() -> true,
new IndexNameExpressionResolver(),
Collections.emptyMap(),
randomBoolean());
Collections.emptyMap());
module.setReaderWrapper(s -> new Wrapper());

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

final IndexService indexService = newIndexService(module);
assertThat(indexService.getDirectoryFactory(), instanceOf(FooFunction.class));
Expand Down Expand Up @@ -519,8 +518,7 @@ public void testRegisterCustomRecoveryStateFactory() throws IOException {
Collections.emptyMap(),
() -> true,
new IndexNameExpressionResolver(),
recoveryStateFactories,
randomBoolean());
recoveryStateFactories);

final IndexService indexService = newIndexService(module);

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

private static IndexModule createIndexModule(IndexSettings indexSettings, AnalysisRegistry emptyAnalysisRegistry) {
return new IndexModule(indexSettings, emptyAnalysisRegistry, new InternalEngineFactory(), Collections.emptyMap(), () -> true,
new IndexNameExpressionResolver(), Collections.emptyMap(), randomBoolean());
new IndexNameExpressionResolver(), Collections.emptyMap());
}

class CustomQueryCache implements QueryCache {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,7 @@ protected IndexShard newShard(ShardRouting routing, ShardPath shardPath, IndexMe
Arrays.asList(listeners),
globalCheckpointSyncer,
retentionLeaseSyncer,
breakerService,
randomBoolean());
breakerService);
indexShard.addShardFailureCallback(DEFAULT_SHARD_FAILURE_HANDLER);
success = true;
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void testWatcherDisabledTests() throws Exception {
AnalysisRegistry registry = new AnalysisRegistry(TestEnvironment.newEnvironment(settings), emptyMap(), emptyMap(), emptyMap(),
emptyMap(), emptyMap(), emptyMap(), emptyMap(), emptyMap(), emptyMap());
IndexModule indexModule = new IndexModule(indexSettings, registry, new InternalEngineFactory(), Collections.emptyMap(),
() -> true, new IndexNameExpressionResolver(), Collections.emptyMap(), randomBoolean());
() -> true, new IndexNameExpressionResolver(), Collections.emptyMap());
// this will trip an assertion if the watcher indexing operation listener is null (which it is) but we try to add it
watcher.onIndexModule(indexModule);

Expand Down

0 comments on commit cffb69d

Please sign in to comment.