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

Remove environment from transport client #13383

Merged
merged 7 commits into from Sep 8, 2015

Conversation

rjernst
Copy link
Member

@rjernst rjernst commented Sep 8, 2015

Transport clients run embedded within external applications, so
elasticsearch should not be doing anything with the filesystem, as there
is not elasticsearch home.

This change makes a number of cleanups to the internal API for loading
settings and creating an environment. The loadFromConfig option was
removed, since it was always true except for tests. We now always
attempt to load settings from config a file when an environment is
created. The prepare methods were also simplified so there is now
prepareSettingsAndEnvironment which nodes use, and prepareSettings which
the transport client uses. I also attempted to improve the tests, but
there is a still a lot of follow up work to do there.

closes #13155

NOTE: I left a handful of TODOs for things that looked fishy in prepareSettingsAndEnvironment. In general this should really be cleaned up to be much simpler. There are far to many ways to configure the settings for a developer to understand the code, so I don't know how a user would understand whether to put a setting in properties, env vars, or one of many possible files, or forcing a property, or setting a default, etc.

Transport clients run embedded within external applications, so
elasticsearch should not be doing anything with the filesystem, as there
is not elasticsearch home.

This change makes a number of cleanups to the internal API for loading
settings and creating an environment. The loadFromConfig option was
removed, since it was always true except for tests. We now always
attempt to load settings from config a file when an environment is
created. The prepare methods were also simplified so there is now
prepareSettingsAndEnvironment which nodes use, and prepareSettings which
the transport client uses. I also attempted to improve the tests, but
there is a still a lot of follow up work to do there.

closes elastic#13155
@@ -197,7 +197,7 @@ private static void setupLogging(Settings settings, Environment environment) {

private static Tuple<Settings, Environment> initialSettings(boolean foreground) {
Terminal terminal = foreground ? Terminal.DEFAULT : null;
return InternalSettingsPreparer.prepareSettings(EMPTY_SETTINGS, true, terminal);
return InternalSettingsPreparer.prepareSettingsAndEnvironment(EMPTY_SETTINGS, terminal);
Copy link
Contributor

Choose a reason for hiding this comment

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

it might be simpler to just name this InternalSettingsPreparer.prepareEnvironment and return only Environment since it has the settings already as a member then we can spare the tuple and things are less funky?

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 think the only issue with that right now is the last line of the method, which modifies the log file setting to be absolute, after creating the environment.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah I wonder if we should do this first?

Copy link
Member Author

Choose a reason for hiding this comment

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

well it is using the resolved config dir from the environment...

Copy link
Member Author

Choose a reason for hiding this comment

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

but i agree, this is already breaking. i will move it and simplify as you suggested

@s1monw
Copy link
Contributor

s1monw commented Sep 8, 2015

left some minors LGTM otherwise

@clintongormley
Copy link

@rjernst could you also add a note to the breaking changes docs please: https://www.elastic.co/guide/en/elasticsearch/reference/2.0/_java_api_changes.html

@s1monw
Copy link
Contributor

s1monw commented Sep 8, 2015

@clintongormley what is the breaking change here?

@clintongormley
Copy link

@s1monw the fact that the node client now requires a path.home setting, which it didn't before.

@rjernst
Copy link
Member Author

rjernst commented Sep 8, 2015

It's also breaking because the loadConfigSettings argument is gone.

@clintongormley I added a note to the migration guide.

@rjernst
Copy link
Member Author

rjernst commented Sep 8, 2015

@s1monw I updated to remove the extra path.logs setter at the end of prepare. It was only there for logging, so I moved it directly to the logging configurator.

@s1monw
Copy link
Contributor

s1monw commented Sep 8, 2015

LGTM

rjernst added a commit that referenced this pull request Sep 8, 2015
Remove environment from transport client
@rjernst rjernst merged commit 55795f8 into elastic:master Sep 8, 2015
@rjernst rjernst deleted the go_away_transport_paths branch September 8, 2015 20:28
rjernst added a commit that referenced this pull request Sep 8, 2015
Remove environment from transport client
rjernst added a commit that referenced this pull request Sep 8, 2015
Remove environment from transport client
@rjernst
Copy link
Member Author

rjernst commented Sep 8, 2015

2.x commit: 2d698d6
2.0 commit: 5cd65d0

rjernst added a commit to rjernst/elasticsearch that referenced this pull request Dec 8, 2015
The tribe node creates one local client node for each cluster it
connects to. Refactorings in elastic#13383 broke this so that each local client
node now tries to load the full elasticsearch.yml that the real tribe
node uses.

This change fixes the problem by adding a TribeClientNode which is a
subclass of Node. The Environment the node uses is now passed in (in
place of Settings), and the TribeClientNode simply does not use
InternalSettingsPreparer.prepareEnvironment.

The tests around tribe nodes are not great. The existing tests pass, but
I also manually tested by creating 2 local clusters, and configuring and
starting a tribe node. With this I was able to see in the logs the tribe
node connecting to each cluster.

closes elastic#13383
@mtraynham
Copy link

Just ran into this with an upgrade from 1.7 to 2.2, since we were using elasticsearch.yml to config the node name for our TransportClient.

I want to point out that the documentation (here) is wrong to suggest you can still do this.

Or using elasticsearch.yml file as shown in Node Client

clintongormley added a commit that referenced this pull request Feb 28, 2016
Remove comment about configuring the transport client in the config file

Relates to #13383 (comment)
@clintongormley
Copy link

thanks @mtraynham - fixed in 1769e9b

clintongormley added a commit that referenced this pull request Feb 28, 2016
Remove comment about configuring the transport client in the config file

Relates to #13383 (comment)
clintongormley added a commit that referenced this pull request Feb 28, 2016
Remove comment about configuring the transport client in the config file

Relates to #13383 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2.0.beta1 - Exception "path.home is not configured" when starting ES in transport and client mode
4 participants