Using 2 config files - InternalSettingsPerparer issue


(vlagorce) #1

Hi Folks,

I need to have 2 configuration files.

The first (first-elasticsearch.yml) will be package in my jar* file,
and the second will be externalized. https://gist.github.com/1334242

It almost works but something looks strange in the
InternalSettingsPerparer.

  • builder.settings().loadFromClasspath load the first file and the
    path.config is resolved.
  • builder.build() instantiate a new InternalNode() which run
    InternalSettingsPerparer.prepareSettings(pSettings,
    loadConfigSettings).
  • prepareSettings load the file by using
    settingsBuilder.loadFromUrl(environment.resolveConfig("elasticsearch.yml"));
    settingsBuilder no contains the new value
    ~But in the end prepareSettings(..) execute
    settingsBuilder.put(pSettings). This will restore the previous values :
    (.

Is it a feature to override last loaded properties with the initial
settings ? I can't understand the need of calling the
settingsBuilder.put(pSettings) two times.

@Shay In the same time I think there's a typo in the class name :wink:
Perparer instead of Preparer.

====
*My ES is embeded.


(Shay Banon) #2

I am not sure I follow... . Do you mean that you expect the
first-elasticsearch.yml setting to override the ones loaded by
elasticsearch automatically from the classpath?

On Wed, Nov 2, 2011 at 7:39 PM, vlag vlagorce@gmail.com wrote:

Hi Folks,

I need to have 2 configuration files.

The first (first-elasticsearch.yml) will be package in my jar* file,
and the second will be externalized. https://gist.github.com/1334242

It almost works but something looks strange in the
InternalSettingsPerparer.

  • builder.settings().loadFromClasspath load the first file and the
    path.config is resolved.
  • builder.build() instantiate a new InternalNode() which run
    InternalSettingsPerparer.prepareSettings(pSettings,
    loadConfigSettings).
  • prepareSettings load the file by using

settingsBuilder.loadFromUrl(environment.resolveConfig("elasticsearch.yml"));
settingsBuilder no contains the new value
~But in the end prepareSettings(..) execute
settingsBuilder.put(pSettings). This will restore the previous values :
(.

Is it a feature to override last loaded properties with the initial
settings ? I can't understand the need of calling the
settingsBuilder.put(pSettings) two times.

@Shay In the same time I think there's a typo in the class name :wink:
Perparer instead of Preparer.

====
*My ES is embeded.


(vlagorce) #3

What you describe it's not what I expect, it's what's happened !

The "firts-elasticsearch.yml" is load from classpath (coded in my
methode) and define the location of the second. The second is loaded
when the node is create but even if the properties are loaded the
second call of settingsBuilder.put(pSettings) restore the properties
comming from the first file.

I just want to define configuration in my jar and be able to override
some properties when needed by server administrator.( like cluster-
name, allowed ip,.. )

On Nov 3, 12:03 am, Shay Banon kim...@gmail.com wrote:

I am not sure I follow... . Do you mean that you expect the
first-elasticsearch.yml setting to override the ones loaded by
elasticsearch automatically from the classpath?

On Wed, Nov 2, 2011 at 7:39 PM, vlag vlago...@gmail.com wrote:

Hi Folks,

I need to have 2 configuration files.

The first (first-elasticsearch.yml) will be package in my jar* file,
and the second will be externalized.https://gist.github.com/1334242

It almost works but something looks strange in the
InternalSettingsPerparer.

  • builder.settings().loadFromClasspath load the first file and the
    path.config is resolved.
  • builder.build() instantiate a new InternalNode() which run
    InternalSettingsPerparer.prepareSettings(pSettings,
    loadConfigSettings).
  • prepareSettings load the file by using

settingsBuilder.loadFromUrl(environment.resolveConfig("elasticsearch.yml")) ;
settingsBuilder no contains the new value
~But in the end prepareSettings(..) execute
settingsBuilder.put(pSettings). This will restore the previous values :
(.

Is it a feature to override last loaded properties with the initial
settings ? I can't understand the need of calling the
settingsBuilder.put(pSettings) two times.

@Shay In the same time I think there's a typo in the class name :wink:
Perparer instead of Preparer.

====
*My ES is embeded.


(Shay Banon) #4

Thats the order that its executed... . There is no reason though that you
can't simply construct your own settings object, load into the data from
the two files (in the order that you want), and then pass the settings to
the node builder. You can also configure it to not load the default
settings.

On Thu, Nov 3, 2011 at 10:29 AM, vlag vlagorce@gmail.com wrote:

What you describe it's not what I expect, it's what's happened !

The "firts-elasticsearch.yml" is load from classpath (coded in my
methode) and define the location of the second. The second is loaded
when the node is create but even if the properties are loaded the
second call of settingsBuilder.put(pSettings) restore the properties
comming from the first file.

I just want to define configuration in my jar and be able to override
some properties when needed by server administrator.( like cluster-
name, allowed ip,.. )

On Nov 3, 12:03 am, Shay Banon kim...@gmail.com wrote:

I am not sure I follow... . Do you mean that you expect the
first-elasticsearch.yml setting to override the ones loaded by
elasticsearch automatically from the classpath?

On Wed, Nov 2, 2011 at 7:39 PM, vlag vlago...@gmail.com wrote:

Hi Folks,

I need to have 2 configuration files.

The first (first-elasticsearch.yml) will be package in my jar* file,
and the second will be externalized.https://gist.github.com/1334242

It almost works but something looks strange in the
InternalSettingsPerparer.

  • builder.settings().loadFromClasspath load the first file and the
    path.config is resolved.
  • builder.build() instantiate a new InternalNode() which run
    InternalSettingsPerparer.prepareSettings(pSettings,
    loadConfigSettings).
  • prepareSettings load the file by using

settingsBuilder.loadFromUrl(environment.resolveConfig("elasticsearch.yml"))
;

settingsBuilder no contains the new value
~But in the end prepareSettings(..) execute
settingsBuilder.put(pSettings). This will restore the previous values :
(.

Is it a feature to override last loaded properties with the initial
settings ? I can't understand the need of calling the
settingsBuilder.put(pSettings) two times.

@Shay In the same time I think there's a typo in the class name :wink:
Perparer instead of Preparer.

====
*My ES is embeded.


(vlagorce) #5

...I just realize that...I am ashamed !!

I easily won the first price for "The useless question of the week
(.may be more ::)".

Thanks Shay.


(Shay Banon) #6

No need for that :), I thought it was a good question :slight_smile:

On Fri, Nov 4, 2011 at 11:14 AM, vlag vlagorce@gmail.com wrote:

...I just realize that...I am ashamed !!

I easily won the first price for "The useless question of the week
(.may be more ::)".

Thanks Shay.


(system) #7