You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Brian Pugh <tr...@yahoo.com> on 2008/10/17 00:33:00 UTC

[CONFIGURATION] FileChangedReloadingStrategy not working for SubnodeConfiguration with a CombinedConfiguration parent

Hi,

I'm somewhat new to configuration and have run into what appears to be a bug (but maybe I'm just doing something wrong).  I'm hoping to either confirm that this is a bug (in which case I'll enter a JIRA) or get some insight on what I'm doing wrong.

I'm trying to use an Combined configuration that consists of two XMLConfigurations.  I want to then get a SubnodeConfiguration from the combined configuration.  The XMLConfigurations have the FileChangedReloadingStrategy set, the combined configuration has the setForceReloadCheck flag set and the subnodeconfiguration was obtained passing in the true flag to the configurationAt method.  However, I don't seem to see changes that are made to the two underlying files.  It does work if I operate on the combined configuration or if a subnodeconfiguration has an XMLConfiguration as its parent, but if a subnode configuration has a combined configuration as the parent, the changes are not detected.  

Below is some code that shows how I'm using the various configurations and the various scenarios I described above.  The last assertion fails because the change to the file is not detected when the subnodeconfiguration has a parent that is a combinedconfiguration.  Any help or insight would be greatly appreciated!


 @Test
  public void testSubnodeReadload() throws ConfigurationException {
    XMLConfiguration xmlConfiguration = new XMLConfiguration("service.xml");
    FileChangedReloadingStrategy fileReloadStrategy = new FileChangedReloadingStrategy();
    fileReloadStrategy.setRefreshDelay(1000);
    xmlConfiguration.setReloadingStrategy(fileReloadStrategy);
    XMLConfiguration config2 = new XMLConfiguration("environment.xml");
    FileChangedReloadingStrategy fileReloadStrategy2 = new FileChangedReloadingStrategy();
    fileReloadStrategy2.setRefreshDelay(1000);
    xmlConfiguration.setReloadingStrategy(fileReloadStrategy2);

    CombinedConfiguration combinedConfig = new CombinedConfiguration();
    combinedConfig.setForceReloadCheck(true);
    combinedConfig.addConfiguration(xmlConfiguration);
    combinedConfig.addConfiguration(config2);
    int queue0threads2 = xmlConfiguration.getInt("messaging-new.queue(0).threads");
    assert 2 == queue0threads2;

    //change the value in service.xml to 4
    int queue0threads4 = xmlConfiguration.getInt("messaging-new.queue(0).threads");
    assert 4 == queue0threads4;


    SubnodeConfiguration subConfigHier = xmlConfiguration.configurationAt("messaging-new.queue(0)", true);
    int queue0threadsCombinedSub4 = subConfigHier.getInt("threads");
    assert queue0threadsCombinedSub4 == 4;

    //change the value service.xml to 8
    int queue0threadsCombinedSub8 = subConfigHier.getInt("threads");
    assert queue0threadsCombinedSub8 == 8;


    SubnodeConfiguration subNodeConfigParentIsCombinedConfig = combinedConfig.configurationAt("messaging-new.queue(0)", true);
    int queue0threadsSub8 = subNodeConfigParentIsCombinedConfig.getInt("threads");
    assert queue0threadsSub8 == 8;

    //change the value service.xml file to 16
    int queue0threadsSub16 = subNodeConfigParentIsCombinedConfig.getInt("threads");
    assert queue0threadsSub16 == 16;         //THIS TEST FAILS

  }





      

Re: [CONFIGURATION] FileChangedReloadingStrategy not working for SubnodeConfiguration with a CombinedConfiguration parent

Posted by Brian Pugh <tr...@yahoo.com>.
Thanks for confirming this issue for me Oliver.  I opened a ticket that can be seen at:
https://issues.apache.org/jira/browse/CONFIGURATION-341

--- On Fri, 10/17/08, Oliver Heger <ol...@oliver-heger.de> wrote:
From: Oliver Heger <ol...@oliver-heger.de>
Subject: Re: [CONFIGURATION] FileChangedReloadingStrategy not working for SubnodeConfiguration with a CombinedConfiguration parent
To: "Commons Users List" <us...@commons.apache.org>
Date: Friday, October 17, 2008, 11:19 AM

Brian Pugh schrieb:
> Hi,
> 
> I'm somewhat new to configuration and have run into what appears to be
a bug (but maybe I'm just doing something wrong).  I'm hoping to either
confirm that this is a bug (in which case I'll enter a JIRA) or get some
insight on what I'm doing wrong.
> 
> I'm trying to use an Combined configuration that consists of two
XMLConfigurations.  I want to then get a SubnodeConfiguration from the combined
configuration.  The XMLConfigurations have the FileChangedReloadingStrategy set,
the combined configuration has the setForceReloadCheck flag set and the
subnodeconfiguration was obtained passing in the true flag to the
configurationAt method.  However, I don't seem to see changes that are made
to the two underlying files.  It does work if I operate on the combined
configuration or if a subnodeconfiguration has an XMLConfiguration as its
parent, but if a subnode configuration has a combined configuration as the
parent, the changes are not detected.  
> 
> Below is some code that shows how I'm using the various configurations
and the various scenarios I described above.  The last assertion fails because
the change to the file is not detected when the subnodeconfiguration has a
parent that is a combinedconfiguration.  Any help or insight would be greatly
appreciated!
> 
Unfortunately I have to confirm that this is a bug: the reloading check 
obviously does not work in the constellation you describe.

So it would be great if you could create a ticket in Jira.

Thanks
Oliver

> 
>  @Test
>   public void testSubnodeReadload() throws ConfigurationException {
>     XMLConfiguration xmlConfiguration = new
XMLConfiguration("service.xml");
>     FileChangedReloadingStrategy fileReloadStrategy = new
FileChangedReloadingStrategy();
>     fileReloadStrategy.setRefreshDelay(1000);
>     xmlConfiguration.setReloadingStrategy(fileReloadStrategy);
>     XMLConfiguration config2 = new
XMLConfiguration("environment.xml");
>     FileChangedReloadingStrategy fileReloadStrategy2 = new
FileChangedReloadingStrategy();
>     fileReloadStrategy2.setRefreshDelay(1000);
>     xmlConfiguration.setReloadingStrategy(fileReloadStrategy2);
> 
>     CombinedConfiguration combinedConfig = new CombinedConfiguration();
>     combinedConfig.setForceReloadCheck(true);
>     combinedConfig.addConfiguration(xmlConfiguration);
>     combinedConfig.addConfiguration(config2);
>     int queue0threads2 =
xmlConfiguration.getInt("messaging-new.queue(0).threads");
>     assert 2 == queue0threads2;
> 
>     //change the value in service.xml to 4
>     int queue0threads4 =
xmlConfiguration.getInt("messaging-new.queue(0).threads");
>     assert 4 == queue0threads4;
> 
> 
>     SubnodeConfiguration subConfigHier =
xmlConfiguration.configurationAt("messaging-new.queue(0)", true);
>     int queue0threadsCombinedSub4 =
subConfigHier.getInt("threads");
>     assert queue0threadsCombinedSub4 == 4;
> 
>     //change the value service.xml to 8
>     int queue0threadsCombinedSub8 =
subConfigHier.getInt("threads");
>     assert queue0threadsCombinedSub8 == 8;
> 
> 
>     SubnodeConfiguration subNodeConfigParentIsCombinedConfig =
combinedConfig.configurationAt("messaging-new.queue(0)", true);
>     int queue0threadsSub8 =
subNodeConfigParentIsCombinedConfig.getInt("threads");
>     assert queue0threadsSub8 == 8;
> 
>     //change the value service.xml file to 16
>     int queue0threadsSub16 =
subNodeConfigParentIsCombinedConfig.getInt("threads");
>     assert queue0threadsSub16 == 16;         //THIS TEST FAILS
> 
>   }
> 
> 
> 
> 
> 
>       


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: [CONFIGURATION] FileChangedReloadingStrategy not working for SubnodeConfiguration with a CombinedConfiguration parent

Posted by Oliver Heger <ol...@oliver-heger.de>.
Brian Pugh schrieb:
> Hi,
> 
> I'm somewhat new to configuration and have run into what appears to be a bug (but maybe I'm just doing something wrong).  I'm hoping to either confirm that this is a bug (in which case I'll enter a JIRA) or get some insight on what I'm doing wrong.
> 
> I'm trying to use an Combined configuration that consists of two XMLConfigurations.  I want to then get a SubnodeConfiguration from the combined configuration.  The XMLConfigurations have the FileChangedReloadingStrategy set, the combined configuration has the setForceReloadCheck flag set and the subnodeconfiguration was obtained passing in the true flag to the configurationAt method.  However, I don't seem to see changes that are made to the two underlying files.  It does work if I operate on the combined configuration or if a subnodeconfiguration has an XMLConfiguration as its parent, but if a subnode configuration has a combined configuration as the parent, the changes are not detected.  
> 
> Below is some code that shows how I'm using the various configurations and the various scenarios I described above.  The last assertion fails because the change to the file is not detected when the subnodeconfiguration has a parent that is a combinedconfiguration.  Any help or insight would be greatly appreciated!
> 
Unfortunately I have to confirm that this is a bug: the reloading check 
obviously does not work in the constellation you describe.

So it would be great if you could create a ticket in Jira.

Thanks
Oliver

> 
>  @Test
>   public void testSubnodeReadload() throws ConfigurationException {
>     XMLConfiguration xmlConfiguration = new XMLConfiguration("service.xml");
>     FileChangedReloadingStrategy fileReloadStrategy = new FileChangedReloadingStrategy();
>     fileReloadStrategy.setRefreshDelay(1000);
>     xmlConfiguration.setReloadingStrategy(fileReloadStrategy);
>     XMLConfiguration config2 = new XMLConfiguration("environment.xml");
>     FileChangedReloadingStrategy fileReloadStrategy2 = new FileChangedReloadingStrategy();
>     fileReloadStrategy2.setRefreshDelay(1000);
>     xmlConfiguration.setReloadingStrategy(fileReloadStrategy2);
> 
>     CombinedConfiguration combinedConfig = new CombinedConfiguration();
>     combinedConfig.setForceReloadCheck(true);
>     combinedConfig.addConfiguration(xmlConfiguration);
>     combinedConfig.addConfiguration(config2);
>     int queue0threads2 = xmlConfiguration.getInt("messaging-new.queue(0).threads");
>     assert 2 == queue0threads2;
> 
>     //change the value in service.xml to 4
>     int queue0threads4 = xmlConfiguration.getInt("messaging-new.queue(0).threads");
>     assert 4 == queue0threads4;
> 
> 
>     SubnodeConfiguration subConfigHier = xmlConfiguration.configurationAt("messaging-new.queue(0)", true);
>     int queue0threadsCombinedSub4 = subConfigHier.getInt("threads");
>     assert queue0threadsCombinedSub4 == 4;
> 
>     //change the value service.xml to 8
>     int queue0threadsCombinedSub8 = subConfigHier.getInt("threads");
>     assert queue0threadsCombinedSub8 == 8;
> 
> 
>     SubnodeConfiguration subNodeConfigParentIsCombinedConfig = combinedConfig.configurationAt("messaging-new.queue(0)", true);
>     int queue0threadsSub8 = subNodeConfigParentIsCombinedConfig.getInt("threads");
>     assert queue0threadsSub8 == 8;
> 
>     //change the value service.xml file to 16
>     int queue0threadsSub16 = subNodeConfigParentIsCombinedConfig.getInt("threads");
>     assert queue0threadsSub16 == 16;         //THIS TEST FAILS
> 
>   }
> 
> 
> 
> 
> 
>       


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org