Skip to content

Commit e28509f

Browse files
authored
Core: Less settings to AbstractComponent (#35140)
Stop passing `Settings` to `AbstractComponent`'s ctor. This allows us to stop passing around `Settings` in a *ton* of places. While this change touches many files, it touches them all in fairly small, mechanical ways, doing a few things per file: 1. Drop the `super(settings);` line on everything that extends `AbstractComponent`. 2. Drop the `settings` argument to the ctor if it is no longer used. 3. If the file doesn't use `logger` then drop `extends AbstractComponent` from it. 4. Clean up all compilation failure caused by the `settings` removal and drop any now unused `settings` isntances and method arguments. I've intentionally *not* removed the `settings` argument from a few files: 1. TransportAction 2. AbstractLifecycleComponent 3. BaseRestHandler These files don't *need* `settings` either, but this change is large enough as is. Relates to #34488
1 parent b5e5e93 commit e28509f

File tree

400 files changed

+706
-1366
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

400 files changed

+706
-1366
lines changed

benchmarks/src/main/java/org/elasticsearch/benchmark/routing/allocation/Allocators.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ public final class Allocators {
4646
private static class NoopGatewayAllocator extends GatewayAllocator {
4747
public static final NoopGatewayAllocator INSTANCE = new NoopGatewayAllocator();
4848

49-
protected NoopGatewayAllocator() {
50-
super(Settings.EMPTY);
51-
}
52-
5349
@Override
5450
public void applyStartedShards(RoutingAllocation allocation, List<ShardRouting> startedShards) {
5551
// noop
@@ -79,7 +75,7 @@ public static AllocationService createAllocationService(Settings settings) throw
7975

8076
public static AllocationService createAllocationService(Settings settings, ClusterSettings clusterSettings) throws
8177
InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
82-
return new AllocationService(settings,
78+
return new AllocationService(
8379
defaultAllocationDeciders(settings, clusterSettings),
8480
NoopGatewayAllocator.INSTANCE, new BalancedShardsAllocator(settings), EmptyClusterInfoService.INSTANCE);
8581
}
@@ -88,7 +84,7 @@ public static AllocationDeciders defaultAllocationDeciders(Settings settings, Cl
8884
IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException {
8985
Collection<AllocationDecider> deciders =
9086
ClusterModule.createAllocationDeciders(settings, clusterSettings, Collections.emptyList());
91-
return new AllocationDeciders(settings, deciders);
87+
return new AllocationDeciders(deciders);
9288

9389
}
9490

modules/lang-expression/src/main/java/org/elasticsearch/script/expression/ExpressionPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ public class ExpressionPlugin extends Plugin implements ScriptPlugin {
3131

3232
@Override
3333
public ScriptEngine getScriptEngine(Settings settings, Collection<ScriptContext<?>> contexts) {
34-
return new ExpressionScriptEngine(settings);
34+
return new ExpressionScriptEngine();
3535
}
3636
}

modules/lang-expression/src/main/java/org/elasticsearch/script/expression/ExpressionScriptEngine.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
import org.apache.lucene.search.SortField;
2929
import org.elasticsearch.SpecialPermission;
3030
import org.elasticsearch.common.Nullable;
31-
import org.elasticsearch.common.component.AbstractComponent;
32-
import org.elasticsearch.common.settings.Settings;
3331
import org.elasticsearch.index.fielddata.IndexFieldData;
3432
import org.elasticsearch.index.fielddata.IndexNumericFieldData;
3533
import org.elasticsearch.index.mapper.DateFieldMapper;
@@ -63,14 +61,10 @@
6361
*
6462
* Only contexts returning numeric types or {@link Object} are supported.
6563
*/
66-
public class ExpressionScriptEngine extends AbstractComponent implements ScriptEngine {
64+
public class ExpressionScriptEngine implements ScriptEngine {
6765

6866
public static final String NAME = "expression";
6967

70-
public ExpressionScriptEngine(Settings settings) {
71-
super(settings);
72-
}
73-
7468
@Override
7569
public String getType() {
7670
return NAME;

modules/lang-expression/src/test/java/org/elasticsearch/script/expression/ExpressionFieldScriptTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
package org.elasticsearch.script.expression;
2121

22-
import org.elasticsearch.common.settings.Settings;
2322
import org.elasticsearch.index.fielddata.AtomicNumericFieldData;
2423
import org.elasticsearch.index.fielddata.IndexNumericFieldData;
2524
import org.elasticsearch.index.fielddata.SortedNumericDoubleValues;
@@ -64,7 +63,7 @@ public void setUp() throws Exception {
6463
when(fieldData.getFieldName()).thenReturn("field");
6564
when(fieldData.load(anyObject())).thenReturn(atomicFieldData);
6665

67-
service = new ExpressionScriptEngine(Settings.EMPTY);
66+
service = new ExpressionScriptEngine();
6867
lookup = new SearchLookup(mapperService, ignored -> fieldData, null);
6968
}
7069

modules/lang-expression/src/test/java/org/elasticsearch/script/expression/ExpressionNumberSortScriptTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.io.IOException;
2323
import java.text.ParseException;
2424
import java.util.Collections;
25-
import org.elasticsearch.common.settings.Settings;
2625
import org.elasticsearch.index.fielddata.AtomicNumericFieldData;
2726
import org.elasticsearch.index.fielddata.IndexNumericFieldData;
2827
import org.elasticsearch.index.fielddata.SortedNumericDoubleValues;
@@ -63,7 +62,7 @@ public void setUp() throws Exception {
6362
when(fieldData.getFieldName()).thenReturn("field");
6463
when(fieldData.load(anyObject())).thenReturn(atomicFieldData);
6564

66-
service = new ExpressionScriptEngine(Settings.EMPTY);
65+
service = new ExpressionScriptEngine();
6766
lookup = new SearchLookup(mapperService, ignored -> fieldData, null);
6867
}
6968

modules/lang-expression/src/test/java/org/elasticsearch/script/expression/ExpressionTermsSetQueryTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.io.IOException;
2323
import java.text.ParseException;
2424
import java.util.Collections;
25-
import org.elasticsearch.common.settings.Settings;
2625
import org.elasticsearch.index.fielddata.AtomicNumericFieldData;
2726
import org.elasticsearch.index.fielddata.IndexNumericFieldData;
2827
import org.elasticsearch.index.fielddata.SortedNumericDoubleValues;
@@ -63,7 +62,7 @@ public void setUp() throws Exception {
6362
when(fieldData.getFieldName()).thenReturn("field");
6463
when(fieldData.load(anyObject())).thenReturn(atomicFieldData);
6564

66-
service = new ExpressionScriptEngine(Settings.EMPTY);
65+
service = new ExpressionScriptEngine();
6766
lookup = new SearchLookup(mapperService, ignored -> fieldData, null);
6867
}
6968

modules/lang-painless/src/main/java/org/elasticsearch/painless/PainlessScriptEngine.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
package org.elasticsearch.painless;
2121

2222
import org.elasticsearch.SpecialPermission;
23-
import org.elasticsearch.common.component.AbstractComponent;
2423
import org.elasticsearch.common.settings.Settings;
2524
import org.elasticsearch.painless.Compiler.Loader;
2625
import org.elasticsearch.painless.lookup.PainlessLookupBuilder;
@@ -54,7 +53,7 @@
5453
/**
5554
* Implementation of a ScriptEngine for the Painless language.
5655
*/
57-
public final class PainlessScriptEngine extends AbstractComponent implements ScriptEngine {
56+
public final class PainlessScriptEngine implements ScriptEngine {
5857

5958
/**
6059
* Standard name of the Painless language.
@@ -90,8 +89,6 @@ public final class PainlessScriptEngine extends AbstractComponent implements Scr
9089
* @param settings The settings to initialize the engine with.
9190
*/
9291
public PainlessScriptEngine(Settings settings, Map<ScriptContext<?>, List<Whitelist>> contexts) {
93-
super(settings);
94-
9592
defaultCompilerSettings.setRegexesEnabled(CompilerSettings.REGEX_ENABLED.get(settings));
9693

9794
Map<ScriptContext<?>, Compiler> contextsToCompilers = new HashMap<>();

modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorHighlightSubFetchPhase.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.elasticsearch.common.bytes.BytesReference;
3232
import org.elasticsearch.common.document.DocumentField;
3333
import org.elasticsearch.common.lucene.search.function.FunctionScoreQuery;
34-
import org.elasticsearch.common.settings.Settings;
3534
import org.elasticsearch.common.text.Text;
3635
import org.elasticsearch.index.query.ParsedQuery;
3736
import org.elasticsearch.search.SearchHit;
@@ -56,8 +55,8 @@
5655
final class PercolatorHighlightSubFetchPhase implements FetchSubPhase {
5756
private final HighlightPhase highlightPhase;
5857

59-
PercolatorHighlightSubFetchPhase(Settings settings, Map<String, Highlighter> highlighters) {
60-
this.highlightPhase = new HighlightPhase(settings, highlighters);
58+
PercolatorHighlightSubFetchPhase(Map<String, Highlighter> highlighters) {
59+
this.highlightPhase = new HighlightPhase(highlighters);
6160
}
6261

6362
boolean hitsExecutionNeeded(SearchContext context) { // for testing

modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorPlugin.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
package org.elasticsearch.percolator;
2121

2222
import org.elasticsearch.common.settings.Setting;
23-
import org.elasticsearch.common.settings.Settings;
2423
import org.elasticsearch.index.mapper.Mapper;
2524
import org.elasticsearch.plugins.MapperPlugin;
2625
import org.elasticsearch.plugins.Plugin;
@@ -35,13 +34,6 @@
3534
import static java.util.Collections.singletonMap;
3635

3736
public class PercolatorPlugin extends Plugin implements MapperPlugin, SearchPlugin {
38-
39-
private final Settings settings;
40-
41-
public PercolatorPlugin(Settings settings) {
42-
this.settings = settings;
43-
}
44-
4537
@Override
4638
public List<QuerySpec<?>> getQueries() {
4739
return singletonList(new QuerySpec<>(PercolateQueryBuilder.NAME, PercolateQueryBuilder::new, PercolateQueryBuilder::fromXContent));
@@ -51,7 +43,7 @@ public List<QuerySpec<?>> getQueries() {
5143
public List<FetchSubPhase> getFetchSubPhases(FetchPhaseConstructionContext context) {
5244
return Arrays.asList(
5345
new PercolatorMatchedSlotSubFetchPhase(),
54-
new PercolatorHighlightSubFetchPhase(settings, context.getHighlighters())
46+
new PercolatorHighlightSubFetchPhase(context.getHighlighters())
5547
);
5648
}
5749

modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorHighlightSubFetchPhaseTests.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.elasticsearch.common.bytes.BytesArray;
2929
import org.elasticsearch.common.lucene.search.function.FunctionScoreQuery;
3030
import org.elasticsearch.common.lucene.search.function.RandomScoreFunction;
31-
import org.elasticsearch.common.settings.Settings;
3231
import org.elasticsearch.search.fetch.subphase.highlight.SearchContextHighlight;
3332
import org.elasticsearch.search.internal.SearchContext;
3433
import org.elasticsearch.test.ESTestCase;
@@ -47,8 +46,7 @@ public class PercolatorHighlightSubFetchPhaseTests extends ESTestCase {
4746
public void testHitsExecutionNeeded() {
4847
PercolateQuery percolateQuery = new PercolateQuery("_name", ctx -> null, Collections.singletonList(new BytesArray("{}")),
4948
new MatchAllDocsQuery(), Mockito.mock(IndexSearcher.class), null, new MatchAllDocsQuery());
50-
PercolatorHighlightSubFetchPhase subFetchPhase = new PercolatorHighlightSubFetchPhase(Settings.EMPTY,
51-
emptyMap());
49+
PercolatorHighlightSubFetchPhase subFetchPhase = new PercolatorHighlightSubFetchPhase(emptyMap());
5250
SearchContext searchContext = Mockito.mock(SearchContext.class);
5351
Mockito.when(searchContext.highlight()).thenReturn(new SearchContextHighlight(Collections.emptyList()));
5452
Mockito.when(searchContext.query()).thenReturn(new MatchAllDocsQuery());

0 commit comments

Comments
 (0)