Can't override default properties once set in config.properties

867 views
Skip to first unread message

Alain Kreienbuhl

unread,
Apr 3, 2016, 5:44:12 AM4/3/16
to HystrixOSS
Hello

I wish to configure a default timeoutInMilliseconds  a bit higher (1) and also in case we notice that the setting is too low in the production env be able to change it dynamically (2).

So for (1) I have defined in a config.properties

hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds = <myval>

It's picked up nicely as new default value.

For (2) I have a rest service that does 

ConfigurationManager.getConfigInstance().setProperty(key, value);


But once that property is defined in the config.property, it's not possible to dynamically change this  value through that code.
Setting the value doesn't fail but the getProperty always returns the initial (config.properties) defined value.


Am I missing something or is this by design ? 

Thanks for your help

Alain

Matt Jacobs

unread,
Apr 4, 2016, 9:37:18 AM4/4/16
to HystrixOSS
Sure, we change config on-the-fly fairly commonly, so this is definitely a valid use case.  Hystrix uses Archaius as its configuration library.  You may set up Archaius in a number of ways to get live-reloading working.  Here is some documentation to get you started:


-Matt

Alain Kreienbuhl

unread,
Apr 4, 2016, 3:47:43 PM4/4/16
to HystrixOSS
Hello  Matt,

Thanks for your answer. 

I read these links but when config.properties on the classpath with the property set to 1234 than setting the prop like below fails 

 @Test
 
public void should_change_confiprop_default() {
 
String key = "hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds";
 assertEquals
("1234",String.valueOf(ConfigurationManager.getConfigInstance().getProperty(key)));
 
ConfigurationManager.getConfigInstance().setProperty(key,"5678");
 assertEquals
("5678",String.valueOf(ConfigurationManager.getConfigInstance().getProperty(key)));  //fails :-(
 
}



It's seams that when doing ConfigurationManager.getConfigInstance().getProperty(key) will retreive the property for the first source having the key.



  Snippet from com.netflix.config.ConcurrentCompositeConfiguration.getProperty(String)
 
public Object getProperty(String key)
   
{
       
if (overrideProperties.containsKey(key)) {
           
return overrideProperties.getProperty(key);
       
}
       
Configuration firstMatchingConfiguration = null;
       
for (Configuration config : configList)
       
{
           
if (config.containsKey(key))
           
{
                firstMatchingConfiguration
= config;
               
break;
           
}
       
}


       
if (firstMatchingConfiguration != null)
       
{
           
return firstMatchingConfiguration.getProperty(key);
       
}
       
else
       
{
           
return null;
       
}
   
}



confList is : [org.apache.commons.configuration.SystemConfiguration@7fc229ab, com.netflix.config.DynamicURLConfiguration@2cbb3d47, com.netflix.config.ConcurrentMapConfiguration@527e5409]

The config.properties looks like to be loaded in the DynamicURLConfiguration [value 1234] while when i'm setting the property it happens in the last one : ConcurrentMapConfiguration [value 5678]

So the getproperty will always be returned from the DynamicURLConfiguration. 

I don't see how I can change this behavior.

Thanks for your help.

Alain

Matt Jacobs

unread,
Apr 8, 2016, 12:22:23 PM4/8/16
to HystrixOSS
This comes down to Archaius behavior.  You'll get a more accurate answer by posting the question here: https://groups.google.com/forum/#!topic/achaius-users/

rohans...@gmail.com

unread,
Feb 1, 2018, 10:13:24 AM2/1/18
to HystrixOSS
Hi Alain,


Did you find any way to resolve or fix this config,properties.So that any other java method or rest api can override those values. Since  me to got similar issue where semaphore.maxConcurrentRequests   needs to be change dynamically

Thanks,
Rohan
Reply all
Reply to author
Forward
0 new messages