-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Core: Drop settings member from AbstractComponent #35083
Changes from all commits
b5192e3
11092e0
c2ce7be
378b411
c6ec0d0
d0c059c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,6 +93,7 @@ public static Deployment fromString(String string) { | |
} | ||
} | ||
|
||
private final Settings settings; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is my "normal" pattern for this PR. |
||
private final AzureComputeService azureComputeService; | ||
private TransportService transportService; | ||
private NetworkService networkService; | ||
|
@@ -108,6 +109,7 @@ public static Deployment fromString(String string) { | |
public AzureUnicastHostsProvider(Settings settings, AzureComputeService azureComputeService, | ||
TransportService transportService, NetworkService networkService) { | ||
super(settings); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll drop this call and the ones like it in a follow up change, but it'll be quite large so I wanted to separate it from this one. |
||
this.settings = settings; | ||
this.azureComputeService = azureComputeService; | ||
this.transportService = transportService; | ||
this.networkService = networkService; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,7 +58,7 @@ public class TestDeprecationHeaderRestAction extends BaseRestHandler { | |
Setting.boolSetting("test.setting.not_deprecated", false, | ||
Setting.Property.NodeScope, Setting.Property.Dynamic); | ||
|
||
private static final Map<String, Setting<?>> SETTINGS; | ||
private static final Map<String, Setting<?>> SETTINGS_MAP; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't want to have |
||
|
||
static { | ||
Map<String, Setting<?>> settingsMap = new HashMap<>(3); | ||
|
@@ -67,14 +67,17 @@ public class TestDeprecationHeaderRestAction extends BaseRestHandler { | |
settingsMap.put(TEST_DEPRECATED_SETTING_TRUE2.getKey(), TEST_DEPRECATED_SETTING_TRUE2); | ||
settingsMap.put(TEST_NOT_DEPRECATED_SETTING.getKey(), TEST_NOT_DEPRECATED_SETTING); | ||
|
||
SETTINGS = Collections.unmodifiableMap(settingsMap); | ||
SETTINGS_MAP = Collections.unmodifiableMap(settingsMap); | ||
} | ||
|
||
public static final String DEPRECATED_ENDPOINT = "[/_test_cluster/deprecated_settings] exists for deprecated tests"; | ||
public static final String DEPRECATED_USAGE = "[deprecated_settings] usage is deprecated. use [settings] instead"; | ||
|
||
private final Settings settings; | ||
|
||
public TestDeprecationHeaderRestAction(Settings settings, RestController controller) { | ||
super(settings); | ||
this.settings = settings; | ||
|
||
controller.registerAsDeprecatedHandler(RestRequest.Method.GET, "/_test_cluster/deprecated_settings", this, | ||
DEPRECATED_ENDPOINT, deprecationLogger); | ||
|
@@ -107,7 +110,7 @@ public RestChannelConsumer prepareRequest(RestRequest request, NodeClient client | |
|
||
builder.startObject().startArray("settings"); | ||
for (String setting : settings) { | ||
builder.startObject().field(setting, SETTINGS.get(setting).getRaw(this.settings)).endObject(); | ||
builder.startObject().field(setting, SETTINGS_MAP.get(setting).getRaw(this.settings)).endObject(); | ||
} | ||
builder.endArray().endObject(); | ||
channel.sendResponse(new BytesRestResponse(RestStatus.OK, builder)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,7 +134,7 @@ protected synchronized void doStart() { | |
addListener(localNodeMasterListeners); | ||
threadPoolExecutor = EsExecutors.newSinglePrioritizing( | ||
nodeName + "/" + CLUSTER_UPDATE_THREAD_NAME, | ||
daemonThreadFactory(settings, CLUSTER_UPDATE_THREAD_NAME), | ||
daemonThreadFactory(nodeName, CLUSTER_UPDATE_THREAD_NAME), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added this method to |
||
threadPool.getThreadContext(), | ||
threadPool.scheduler()); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,10 +26,8 @@ | |
public abstract class AbstractComponent { | ||
|
||
protected final Logger logger; | ||
protected final Settings settings; | ||
|
||
public AbstractComponent(Settings settings) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm intentionally keeping the |
||
this.logger = LogManager.getLogger(getClass()); | ||
this.settings = settings; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these repositories use
environment.settings()
instead of the "normal" settings object. This seems a bit fishy to be honest but it is what they have always done.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this is a case for removing
settings()
from Environment separately? Tbh, I've been guilty of just passing in the environment and using the settings on itThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe! Or making it come back some other way. Or something. The trouble is that we enrich the settings that the rest of the application gets with other stuff so some stuff is just missing from
Environment.settings()
at it isn't obvious unless you've read a bunch of the startup code.