Skip to content
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

Merged
merged 6 commits into from Oct 30, 2018

Conversation

nik9000
Copy link
Member

@nik9000 nik9000 commented Oct 30, 2018

Drops the Settings member from AbstractComponent, moving it from the
base class on to the classes that use it. For the most part this is a
mechanical change that doesn't drop Settings accesses. The one
exception to this is naming threads where it switches from an invocation
that passes Settings and extracts the node name to one that explicitly
passes the node name.

This change doesn't drop the Settings argument from
AbstractComponent's ctor because this change is big enough as is.
We'll do that in a follow up change.

Drops the `Settings` member from `AbstractComponent`, moving it from the
base class on to the classes that use it. For the most part this is a
mechanical change that doesn't drop `Settings` accesses. The one
exception to this is naming threads where it switches from an invocation
that passes `Settings` and extracts the node name to one that explicitly
passes the node name.

This change doesn't drop the `Settings` argument from
`AbstractComponent`'s ctor because this change is big enough as is.
We'll do that in a follow up change.
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@@ -82,21 +82,21 @@ public URLRepository(RepositoryMetaData metadata, Environment environment,
NamedXContentRegistry namedXContentRegistry) {
super(metadata, environment.settings(), namedXContentRegistry);

if (URL_SETTING.exists(metadata.settings()) == false && REPOSITORIES_URL_SETTING.exists(settings) == false) {
if (URL_SETTING.exists(metadata.settings()) == false && REPOSITORIES_URL_SETTING.exists(environment.settings()) == false) {
Copy link
Member Author

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.

Copy link
Member

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 it

Copy link
Member Author

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.

@@ -93,6 +93,7 @@ public static Deployment fromString(String string) {
}
}

private final Settings settings;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is my "normal" pattern for this PR.

@@ -108,6 +109,7 @@ public static Deployment fromString(String string) {
public AzureUnicastHostsProvider(Settings settings, AzureComputeService azureComputeService,
TransportService transportService, NetworkService networkService) {
super(settings);
Copy link
Member Author

Choose a reason for hiding this comment

The 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.

@@ -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),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this method to EsExecutors because I like how explicit it is. We already have the node name in a few places and don't have settings in this one.

@@ -26,10 +26,8 @@
public abstract class AbstractComponent {

protected final Logger logger;
protected final Settings settings;

public AbstractComponent(Settings settings) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm intentionally keeping the settings argument because removing it is bigger than this change. We do much more plumbing of this object then we do using it.

@@ -50,21 +50,24 @@
public abstract class AbstractScopedSettings extends AbstractComponent {
public static final String ARCHIVED_SETTINGS_PREFIX = "archived.";
private Settings lastSettingsApplied = Settings.EMPTY;
private static final Pattern KEY_PATTERN = Pattern.compile("^(?:[-\\w]+[.])*[-\\w]+$");
private static final Pattern GROUP_KEY_PATTERN = Pattern.compile("^(?:[-\\w]+[.])+$");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were out of order.

@@ -58,7 +58,7 @@
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;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to have SETTINGS and settings so I renamed this.

@nik9000
Copy link
Member Author

nik9000 commented Oct 30, 2018

Failure looks real. Oops!

Copy link
Member

@jaymode jaymode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I left a few questions/comments

@@ -163,7 +163,7 @@ protected AnalyzeResponse shardOperation(AnalyzeRequest request, ShardId shardId
}
final AnalysisRegistry analysisRegistry = indicesService.getAnalysis();
final int maxTokenCount = indexService == null ?
IndexSettings.MAX_TOKEN_COUNT_SETTING.get(settings) : indexService.getIndexSettings().getMaxTokenCount();
IndexSettings.MAX_TOKEN_COUNT_SETTING.get(Settings.EMPTY) : indexService.getIndexSettings().getMaxTokenCount();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why Settings.EMPTY here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! Good catch. I was going to leave a comment about it on the PR but forgot. I think I'll go with using settings here instead of this.

So you can specify index.analyze.max_token_count in elasticsearch.yml. Or on an index. I'm not sure why. But you can. When I made this change I thought "there is no way we document this so we don't need to support reading it from elasticsearch.yml" but I think that is not a good change to be sneaking into this.

private static final Pattern KEY_PATTERN = Pattern.compile("^(?:[-\\w]+[.])*[-\\w]+$");
private static final Pattern GROUP_KEY_PATTERN = Pattern.compile("^(?:[-\\w]+[.])+$");
private static final Pattern AFFIX_KEY_PATTERN = Pattern.compile("^(?:[-\\w]+[.])+[*](?:[.][-\\w]+)+$");
private Settings lastSettingsApplied = Settings.EMPTY;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need the assignment here since it is assigned in the constructor?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just moving it around but I see what you mean. I'll fix.

@@ -204,6 +204,8 @@

private static final String DATA_BLOB_PREFIX = "__";

private final Settings globalSettings;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just call this settings?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest of the class calls it globalSettings. I'll just rename it everywhere. So the class lines up with the rest of our classes.

@@ -25,13 +25,15 @@

public class TransportDeleteUserAction extends HandledTransportAction<DeleteUserRequest, DeleteUserResponse> {

private Settings settings;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make it final?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@nik9000
Copy link
Member Author

nik9000 commented Oct 30, 2018

@jaymode, I pushed a commit that fixes what you asked for and left comments for a few other things.

Copy link
Member

@jaymode jaymode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@nik9000
Copy link
Member Author

nik9000 commented Oct 30, 2018

Thanks @jaymode!

@nik9000 nik9000 merged commit 086ada4 into elastic:master Oct 30, 2018
nik9000 added a commit that referenced this pull request Oct 31, 2018
Drops the `Settings` member from `AbstractComponent`, moving it from the
base class on to the classes that use it. For the most part this is a
mechanical change that doesn't drop `Settings` accesses. The one
exception to this is naming threads where it switches from an invocation
that passes `Settings` and extracts the node name to one that explicitly
passes the node name.

This change doesn't drop the `Settings` argument from
`AbstractComponent`'s ctor because this change is big enough as is.
We'll do that in a follow up change.
DaveCTurner added a commit to DaveCTurner/elasticsearch that referenced this pull request Nov 7, 2018
The previous merge introduced semantic conflicts that were not resolved at
merge time, particularly due to PRs elastic#35083, elastic#35140 and elastic#35172. This fixes that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants