Whenever a property is set or removed, we record it in a
propertyDifferences Map in the AbstractContext. This Map keeps track of the
property changes that need to be replicated. So the modified
AbstractContext#setProperty method looks like this;
public void setProperty(String key, Object value) {
if (this.properties == null) {
this.properties = new HashMap();
}
properties.put(key, value);
propertyDifferences.put(key, new PropertyDifference(key, false));
}
The PropertyDifference object keeps track of the properties that have been
set(added/updated) or removed. The boolean entry is to indicate whether the
property was removed.
Before a node replicates its state, it will check the propertyDifferences Map,
transmit the differences, and clear this Map. When a node receives a
UpdateProperties message, it has to set/remove the properties from the
relevant contexts. But when it does this, these changes should not be
replicated once again.
Hence we need to add the following methods to AbstractContext;
/**
* Store a property in this context.
* But these properties should not be replicated when Axis2 is
clustered.
*
* @param key
* @param value
*/
public void setNonReplicableProperty(String key, Object value);
/**
* Remove a property. Only properties at this level will be removed.
* Properties of the parents cannot be removed using this method.
* The removal of the property will not be replicated when Axis2 is
clustered.
*
* @param key
*/
public void removePropertyNonReplicable(String key) ;
These will be called by the clustering mechanism when a n UpdateProperties
message is received by a node. In such a case, it should add the property to
the relevant context, but should not replicate it.
-- Azeez
On 5/19/07, Afkham Azeez <[EMAIL PROTECTED]> wrote:
When it comes to replicating properties in the context hierarchy, we
should only transmit the differences, i.e. only additions/updates/removals
to/from the properties object should be sent to the group.
However, AbstractContext#getProperties() is public. Anybody who gets hold
of this Map can add items to it, remove items from it, or update items in
it. This makes it impossible for us to track the changes to the properties
Map. Also, this is bad encapsulation. Users can add any object as the key to
this Map which will break many things. I suggest we remove this method(or
deprecate it?) and introduce the following;
public Iterator getPropertyNames(); // Will return only the property names
(keys in the Map)
public void removeProperty(String key);
public Object getProperty(String key);
public void setProperty(String key, Object value);
Without such a change, we may not be able to properly handle replication
of the properties.
--
Thanks
Afkham Azeez
http://www.wso2.org
GPG Fingerprint: 643F C2AF EB78 F886 40C9 B2A2 4AE2 C887 665E 0760
--
Thanks
Afkham Azeez
http://www.wso2.org
GPG Fingerprint: 643F C2AF EB78 F886 40C9 B2A2 4AE2 C887 665E 0760