You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@synapse.apache.org by WALTON Jason <Ja...@alcatel-lucent.com> on 2007/09/10 18:55:49 UTC

Changing configuration dynamically

I'm looking to dynamically change the configuration of Synapse while it
is running.  I notice that SynapseConfiguration has methods such as
"addProxyService" which would seem to allow these sorts of changes,
programmatically.  The "Extending Synapse" article on the Synapse main
page notes that it is recommended that custom mediator implementations
do not modify the SynapseConfiguration as it is shared system wide, but
this also seems to imply that it could be changed.  I also had a quick
peek at the WSO2 ESB, since it is built on Synapse, and it seems to make
changes by calling into the SynapseConfiguration.
 
However, digging into the implementation, I see no indication of any
form of thread synchronization in SynapseConfiguration, nor anywhere it
is referenced.  This seems to imply that changing the configuration
while running would not be thread safe.  Am I missing the
synchronization mechanism?

Re: Changing configuration dynamically

Posted by Ruwan Linton <ru...@gmail.com>.
Hi Jason,

On 9/11/07, WALTON Jason <Ja...@alcatel-lucent.com> wrote:
>
>    I'm looking to dynamically change the configuration of Synapse while it
> is running
>
> How exactly are you planning to do this? Could you elaborate on the
> proposed approach?
>
>
> An excellent question!  :)  I have yet to decide on the mechanism, but
> likely something similar to WSO2, with a set of web services which allow one
> or more administrators to make changes to the configuration on the fly.
>
> Alternatively, updating the current "registry" based system so that all
> elements, including Proxies, can be modified.
>

No. Current implementation does not allow you to get proxy services from the
registry. Also if you read my comment on the SYNAPSE-125 carefully, you will
understand that the full configuration can not be made dynamic by putting it
in to the registry. (At least for the moment)

I understand, from https://issues.apache.org/jira/browse/SYNAPSE-125,
> that the current implementation would try to rebuild the entire
> configuration,
>

No.  We do not support the full configuration to be dynamic (when you
specify it in the registry it is static, i.e one time load), please read the
comment on the SYNAPSE-125 carefully.

and I haven't dug into the code at all, but perhaps this could be modified
> such that the registry reads in elements and "synchronizes" the
> configuration with the registry, instead of rebuilding from scratch.
>

This looks a good approach when we are going to support this.

However, digging into the implementation, I see no indication of any form of
> thread synchronization in SynapseConfiguration, nor anywhere it is
> referenced.  This seems to imply that changing the configuration while
> running would not be thread safe.  Am I missing the synchronization
> mechanism?
>
> Right now we have a single user model for administration from that
> implementation. We will address any such issue soon as we integrate with
> user management functionality in the near future
>
> Right, so only one administrator can edit the configuration at a time; but
> if we have a single configuration object shared system wide, then while one
> administrator is making changes to the configuration, the Synapse mediators
> could be trying to read from that configuration at the same time.  If the
> administrator is adding a new proxy, for example, this involves adding the
> Proxy to a HashMap in the SynapseConfiguration, which is not thread safe,
> because a mediator could be trying to read from that same HashMap while it
> is being modified, with undefined results.  I was expecting to find a
> ReadWriteLock here, or to see the SynapseConfiguration object which is
> shared be marked "volatile" and have it cloned/modified/replaced every time
> a modification was made, or something along similar lines.  I was just
> wondering if "something along similar lines" exists, and I'm just missing
> it, or if changing the configuration on the fly under heavy load is likely
> to cause chaos and mayhem?
>

I think we have to address this synchronization problem in the Synapse
Configuration (with the introduction of the user management)

Thanks,
Ruwan

-- 
Ruwan Linton
http://www.wso2.org - "Oxygenating the Web Services Platform"

RE: Changing configuration dynamically

Posted by WALTON Jason <Ja...@alcatel-lucent.com>.
		I'm looking to dynamically change the configuration of
Synapse while it is running

	How exactly are you planning to do this? Could you elaborate on
the proposed approach? 
	 

An excellent question!  :)  I have yet to decide on the mechanism, but
likely something similar to WSO2, with a set of web services which allow
one or more administrators to make changes to the configuration on the
fly.
 
Alternatively, updating the current "registry" based system so that all
elements, including Proxies, can be modified.  I understand, from
https://issues.apache.org/jira/browse/SYNAPSE-125, that the current
implementation would try to rebuild the entire configuration, and I
haven't dug into the code at all, but perhaps this could be modified
such that the registry reads in elements and "synchronizes" the
configuration with the registry, instead of rebuilding from scratch.


		However, digging into the implementation, I see no
indication of any form of thread synchronization in
SynapseConfiguration, nor anywhere it is referenced.  This seems to
imply that changing the configuration while running would not be thread
safe.  Am I missing the synchronization mechanism?

	Right now we have a single user model for administration from
that implementation. We will address any such issue soon as we integrate
with user management functionality in the near future
	
	

Right, so only one administrator can edit the configuration at a time;
but if we have a single configuration object shared system wide, then
while one administrator is making changes to the configuration, the
Synapse mediators could be trying to read from that configuration at the
same time.  If the administrator is adding a new proxy, for example,
this involves adding the Proxy to a HashMap in the SynapseConfiguration,
which is not thread safe, because a mediator could be trying to read
from that same HashMap while it is being modified, with undefined
results.  I was expecting to find a ReadWriteLock here, or to see the
SynapseConfiguration object which is shared be marked "volatile" and
have it cloned/modified/replaced every time a modification was made, or
something along similar lines.  I was just wondering if "something along
similar lines" exists, and I'm just missing it, or if changing the
configuration on the fly under heavy load is likely to cause chaos and
mayhem?


Re: Changing configuration dynamically

Posted by "Asankha C. Perera" <as...@wso2.com>.
Hi Jason
> I'm looking to dynamically change the configuration of Synapse while 
> it is running
How exactly are you planning to do this? Could you elaborate on the 
proposed approach?
> The "Extending Synapse" article on the Synapse main page notes that it 
> is recommended that custom mediator implementations do not modify the 
> SynapseConfiguration as it is shared system wide, but this also seems 
> to imply that it could be changed.
Well it "could" - but a mediator should *not* try to update the 
configuration - as it is just a part of that configuration itself, and 
should only be worried about how it performs its message mediation, 
against the current message that was passed into it
>   I also had a quick peek at the WSO2 ESB, since it is built on 
> Synapse, and it seems to make changes by calling into the 
> SynapseConfiguration.
Yes, we do this via a set of "Admin" web services that we deploy to the 
parent Axis2 engine, that has access to the Synapse configuation. 
Usually, I do not try to promote the WSO2 ESB on any Apache mailing list 
- but since you have directly asked about it - you may view, study or re 
use the code - or just use it as it is as the WSO2 ESB, without trying 
to reinvent it all over again. Its under the ASL v2 license and the 
code, JIRA and mailing lists public too.
> However, digging into the implementation, I see no indication of any 
> form of thread synchronization in SynapseConfiguration, nor anywhere 
> it is referenced.  This seems to imply that changing the configuration 
> while running would not be thread safe.  Am I missing the 
> synchronization mechanism?
Right now we have a single user model for administration from that 
implementation. We will address any such issue soon as we integrate with 
user management functionality in the near future

asankha