axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From az...@apache.org
Subject svn commit: r601231 - in /webservices/axis2/trunk/java/modules: clustering/src/org/apache/axis2/clustering/context/ clustering/src/org/apache/axis2/clustering/tribes/ kernel/src/org/apache/axis2/clustering/ kernel/src/org/apache/axis2/clustering/context/
Date Wed, 05 Dec 2007 07:23:33 GMT
Author: azeez
Date: Tue Dec  4 23:23:31 2007
New Revision: 601231

URL: http://svn.apache.org/viewvc?rev=601231&view=rev
Log:
Handle replication of only selected properties


Modified:
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/ContextClusteringCommandFactory.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/DefaultContextManager.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesClusterManager.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/ClusteringConstants.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/context/ContextManager.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/context/Replicator.java

Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/ContextClusteringCommandFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/ContextClusteringCommandFactory.java?rev=601231&r1=601230&r2=601231&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/ContextClusteringCommandFactory.java
(original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/ContextClusteringCommandFactory.java
Tue Dec  4 23:23:31 2007
@@ -19,12 +19,13 @@
 package org.apache.axis2.clustering.context;
 
 import org.apache.axiom.om.util.UUIDGenerator;
+import org.apache.axis2.clustering.ClusteringFault;
 import org.apache.axis2.clustering.context.commands.ContextClusteringCommandCollection;
+import org.apache.axis2.clustering.context.commands.DeleteServiceGroupContextCommand;
 import org.apache.axis2.clustering.context.commands.UpdateConfigurationContextCommand;
 import org.apache.axis2.clustering.context.commands.UpdateContextCommand;
 import org.apache.axis2.clustering.context.commands.UpdateServiceContextCommand;
 import org.apache.axis2.clustering.context.commands.UpdateServiceGroupContextCommand;
-import org.apache.axis2.clustering.context.commands.DeleteServiceGroupContextCommand;
 import org.apache.axis2.clustering.tribes.AckManager;
 import org.apache.axis2.context.AbstractContext;
 import org.apache.axis2.context.ConfigurationContext;
@@ -42,15 +43,15 @@
 import java.util.Map;
 
 /**
- * 
+ *
  */
 public final class ContextClusteringCommandFactory {
 
     private static final Log log = LogFactory.getLog(ContextClusteringCommandFactory.class);
 
     public static ContextClusteringCommandCollection
-            getCommandCollection(AbstractContext[] contexts,
-                                 Map excludedReplicationPatterns) {
+    getCommandCollection(AbstractContext[] contexts,
+                         Map excludedReplicationPatterns) {
 
         ArrayList commands = new ArrayList(contexts.length);
         ContextClusteringCommandCollection collection =
@@ -69,8 +70,8 @@
     }
 
     /**
-     * @param context
-     * @param excludedPropertyPatterns
+     * @param context                  The context
+     * @param excludedPropertyPatterns The property patterns to be excluded
      * @param includeAllProperties     True - Include all properties,
      *                                 False - Include only property differences
      * @return ContextClusteringCommand
@@ -79,6 +80,49 @@
                                                             Map excludedPropertyPatterns,
                                                             boolean includeAllProperties)
{
 
+        UpdateContextCommand cmd = toUpdateContextCommand(context);
+        if (cmd != null) {
+            cmd.setUniqueId(UUIDGenerator.getUUID());
+            fillProperties(cmd,
+                           context,
+                           excludedPropertyPatterns,
+                           includeAllProperties);
+            if (cmd.isPropertiesEmpty()) {
+                cmd = null;
+            } else {
+                AckManager.addInitialAcknowledgement(cmd);
+            }
+        }
+
+        synchronized (context) {
+            context.clearPropertyDifferences(); // Once we send the diffs, we should clear
the diffs
+        }
+        return cmd;
+    }
+
+
+    public static ContextClusteringCommand getUpdateCommand(AbstractContext context,
+                                                            String[] propertyNames)
+            throws ClusteringFault {
+
+        UpdateContextCommand cmd = toUpdateContextCommand(context);
+        if (cmd != null) {
+            cmd.setUniqueId(UUIDGenerator.getUUID());
+            fillProperties(cmd, context, propertyNames);
+            if (cmd.isPropertiesEmpty()) {
+                cmd = null;
+            } else {
+                AckManager.addInitialAcknowledgement(cmd);
+            }
+        }
+
+        synchronized (context) {
+            context.clearPropertyDifferences(); // Once we send the diffs, we should clear
the diffs
+        }
+        return cmd;
+    }
+
+    private static UpdateContextCommand toUpdateContextCommand(AbstractContext context) {
         UpdateContextCommand cmd = null;
         if (context instanceof ConfigurationContext) {
             cmd = new UpdateConfigurationContextCommand();
@@ -98,29 +142,13 @@
             updateServiceCmd.setServiceGroupContextId(serviceCtx.getServiceGroupContext().getId());
             updateServiceCmd.setServiceName(serviceCtx.getAxisService().getName());
         }
-        if (cmd != null) {
-            cmd.setUniqueId(UUIDGenerator.getUUID());
-            fillProperties(cmd,
-                           context,
-                           excludedPropertyPatterns,
-                           includeAllProperties);
-            if (cmd.isPropertiesEmpty()) {
-                cmd = null;
-            } else {
-                AckManager.addInitialAcknowledgement(cmd);
-            }
-        }
-
-        synchronized (context) {
-            context.clearPropertyDifferences(); // Once we send the diffs, we should clear
the diffs
-        }
         return cmd;
     }
 
     /**
-     * @param updateCmd
-     * @param context
-     * @param excludedPropertyPatterns
+     * @param updateCmd                The command
+     * @param context                  The context
+     * @param excludedPropertyPatterns The property patterns to be excluded from replication
      * @param includeAllProperties     True - Include all properties,
      *                                 False - Include only property differences
      */
@@ -158,8 +186,7 @@
                     if (prop instanceof Serializable) { // First check whether it is serializable
 
                         // Next check whether it matches an excluded pattern
-                        if (!isExcluded(key, context.getClass().getName(), excludedPropertyPatterns))
-                        {
+                        if (!isExcluded(key, context.getClass().getName(), excludedPropertyPatterns))
{
                             log.debug("sending property =" + key + "-" + prop);
                             PropertyDifference diff = new PropertyDifference(key, prop, false);
                             updateCmd.addProperty(diff);
@@ -170,6 +197,31 @@
         }
     }
 
+    private static void fillProperties(UpdateContextCommand updateCmd,
+                                       AbstractContext context,
+                                       String[] propertyNames) throws ClusteringFault {
+        synchronized (context) {
+            Map diffs = context.getPropertyDifferences();
+            for (int i = 0; i < propertyNames.length; i++) {
+                String key = propertyNames[i];
+                Object prop = context.getPropertyNonReplicable(key);
+
+                // First check whether it is serializable
+                if (prop instanceof Serializable) {
+                    log.debug("sending property =" + key + "-" + prop);
+                    PropertyDifference diff = (PropertyDifference) diffs.get(key);
+                    diff.setValue(prop);
+                    updateCmd.addProperty(diff);
+                } else {
+                    String msg =
+                            "Trying to replicate non-serializable property " + key +
+                            " in context " + context;
+                    throw new ClusteringFault(msg);
+                }
+            }
+        }
+    }
+
     private static boolean isExcluded(String propertyName,
                                       String ctxClassName,
                                       Map excludedPropertyPatterns) {
@@ -216,9 +268,9 @@
             DeleteServiceGroupContextCommand cmd = new DeleteServiceGroupContextCommand();
             cmd.setUniqueId(UUIDGenerator.getUUID());
             cmd.setServiceGroupContextId(sgCtx.getId());
-            
+
             return cmd;
-        } 
+        }
         return null;
     }
 }

Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/DefaultContextManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/DefaultContextManager.java?rev=601231&r1=601230&r2=601231&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/DefaultContextManager.java
(original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/context/DefaultContextManager.java
Tue Dec  4 23:23:31 2007
@@ -65,6 +65,17 @@
         return null;
     }
 
+    public String updateContext(AbstractContext context,
+                                String[] propertyNames) throws ClusteringFault {
+        ContextClusteringCommand cmd =
+                ContextClusteringCommandFactory.getUpdateCommand(context, propertyNames);
+        if (cmd != null) {
+            processor.process(cmd);
+            return cmd.getUniqueId();
+        }
+        return null;
+    }
+
     public String updateContexts(AbstractContext[] contexts) throws ClusteringFault {
         ContextClusteringCommandCollection cmd =
                 ContextClusteringCommandFactory.getCommandCollection(contexts,

Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesClusterManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesClusterManager.java?rev=601231&r1=601230&r2=601231&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesClusterManager.java
(original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesClusterManager.java
Tue Dec  4 23:23:31 2007
@@ -134,7 +134,7 @@
         controlCmdProcessor.setChannelSender(sender);
         channel = new GroupChannel();
 
-        String localIP = System.getProperty("local.ip.address"); //TODO: Use ClusteringConstants.LOCAL_IP_ADDRESS
+        String localIP = System.getProperty(ClusteringConstants.LOCAL_IP_ADDRESS); 
         if (localIP != null) {
             ReceiverBase receiver = (ReceiverBase) channel.getChannelReceiver();
             receiver.setAddress(localIP);
@@ -291,13 +291,8 @@
     }
 
     public boolean isParameterLocked(String parameterName) {
-
         Parameter parameter = (Parameter) parameters.get(parameterName);
-        if (parameter != null) {
-            return parameter.isLocked();
-        }
-
-        return false;
+        return parameter != null && parameter.isLocked();
     }
 
     public void removeParameter(Parameter param) throws AxisFault {

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/ClusteringConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/ClusteringConstants.java?rev=601231&r1=601230&r2=601231&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/ClusteringConstants.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/ClusteringConstants.java
Tue Dec  4 23:23:31 2007
@@ -32,5 +32,5 @@
     public static final String CLUSTER_INITIALIZED = "local_cluster.initialized";
     public static final String TIME_TO_SEND = "local_cluster.time.to.send";
     public static final String BLOCK_ALL_REQUESTS = "local_wso2wsas.block.requests";
-    public static final String LOCAL_IP_ADDRESS = "local.ip.address";
+    public static final String LOCAL_IP_ADDRESS = "axis2.local.ip.address";
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/context/ContextManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/context/ContextManager.java?rev=601231&r1=601230&r2=601231&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/context/ContextManager.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/context/ContextManager.java
Tue Dec  4 23:23:31 2007
@@ -34,34 +34,45 @@
      * This could be addition of new properties, modifications of existing properties or
      * removal of properties.
      *
-     * @param context
+     * @param context The AbstractContext containing the properties to be replicated
      * @return The UUID of the message that was sent to the group communications framework
-     * @throws ClusteringFault
+     * @throws ClusteringFault If replication fails
      */
     String updateContext(AbstractContext context) throws ClusteringFault;
 
     /**
+     * This method is called when one need to update/replicate only certains properties in
the
+     * specified <code>context</code>
+     *
+     * @param context       The AbstractContext containing the properties to be replicated
+     * @param propertyNames The names of the specific properties that should be replicated
+     * @return The UUID of the message that was sent to the group communications framework
+     * @throws ClusteringFault If replication fails
+     */
+    String updateContext(AbstractContext context, String[] propertyNames) throws ClusteringFault;
+
+    /**
      * This method is called when properties in a collection of {@link AbstractContext}s
are updated.
      * This could be addition of new properties, modifications of existing properties or
      * removal of properties.
      *
-     * @param contexts
+     * @param contexts The AbstractContexts containing the properties to be replicated
      * @return The UUID of the message that was sent to the group communications framework
-     * @throws ClusteringFault
+     * @throws ClusteringFault If replication fails
      */
     String updateContexts(AbstractContext[] contexts) throws ClusteringFault;
 
     /**
      * This method is called when a new {@link AbstractContext} is removed from the system
      *
-     * @param context
+     * @param context The AbstractContext to be removed
      * @return The UUID of the message that was sent to the group communications framework
-     * @throws ClusteringFault
+     * @throws ClusteringFault If context removal fails
      */
     String removeContext(AbstractContext context) throws ClusteringFault;
 
     /**
-     * @param context
+     * @param context AbstractContext
      * @return True - if the provided {@link AbstractContext}  is clusterable
      */
     boolean isContextClusterable(AbstractContext context);
@@ -69,20 +80,20 @@
     /**
      * Indicates whether a particular message has been ACKed by all members of a cluster
      *
-     * @param messageUniqueId
+     * @param messageUniqueId The UUID of the message in concern
      * @return true - if all memebers have ACKed the message with ID <code>messageUniqueId</code>
      *         false - otherwise
-     * @throws ClusteringFault
+     * @throws ClusteringFault If an error occurs while checking whether a message is ACKed
      */
     boolean isMessageAcknowledged(String messageUniqueId) throws ClusteringFault;
 
     /**
-     * @param listener
+     * @param listener ContextManagerListener
      */
     void setContextManagerListener(ContextManagerListener listener);
 
     /**
-     * @param configurationContext
+     * @param configurationContext ConfigurationContext
      */
     void setConfigurationContext(ConfigurationContext configurationContext);
 
@@ -92,7 +103,8 @@
      * <p/>
      * Generally, we can use the context class name as the context type.
      *
-     * @param contextType
+     * @param contextType The type of the context such as ConfigurationContext,
+     *                    ServiceGroupContext & ServiceContext
      * @param patterns    The patterns
      */
     void setReplicationExcludePatterns(String contextType, List patterns);

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/context/Replicator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/context/Replicator.java?rev=601231&r1=601230&r2=601231&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/context/Replicator.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/context/Replicator.java
Tue Dec  4 23:23:31 2007
@@ -20,14 +20,13 @@
 package org.apache.axis2.clustering.context;
 
 import org.apache.axis2.clustering.ClusterManager;
-import org.apache.axis2.clustering.ClusteringFault;
 import org.apache.axis2.clustering.ClusteringConstants;
+import org.apache.axis2.clustering.ClusteringFault;
 import org.apache.axis2.context.AbstractContext;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.ServiceContext;
 import org.apache.axis2.context.ServiceGroupContext;
-import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -38,116 +37,126 @@
 
     private static final Log log = LogFactory.getLog(Replicator.class);
 
+    /**
+     * Replicates all serializable properties in the ConfigurationContext, ServiceGroupContext
&
+     * ServiceContext
+     *
+     * @param msgContext The MessageContext associated with the ServiceContext,
+     *                   ServiceGroupContext and ConfigurationContext to be replicated
+     * @throws ClusteringFault If replication fails
+     */
     public static void replicate(MessageContext msgContext) throws ClusteringFault {
-        if (!doReplication(msgContext)) {
+        if (!canReplicate(msgContext)) {
             return;
         }
-        log.debug("Going to replicate state...");
-        try {
-            replicateState(msgContext);
-        } catch (Exception e) {
-            String message = "Could not replicate the state";
-            log.error(message, e);
-            throw new ClusteringFault(message, e);
+        log.debug("Going to replicate state stored in ConfigurationContext," +
+                  " ServiceGroupContext, ServiceContext associated with " + msgContext +
"...");
+        ConfigurationContext configurationContext = msgContext.getConfigurationContext();
+        ContextManager contextManager = getContextManager(msgContext);
+        List contexts = new ArrayList();
+
+        // Do we need to replicate state stored in ConfigurationContext?
+        if (!configurationContext.getPropertyDifferences().isEmpty()) {
+            contexts.add(configurationContext);
+        }
+
+        // Do we need to replicate state stored in ServiceGroupContext?
+        ServiceGroupContext sgContext = msgContext.getServiceGroupContext();
+        if (sgContext != null && !sgContext.getPropertyDifferences().isEmpty()) {
+            contexts.add(sgContext);
+        }
+
+        // Do we need to replicate state stored in ServiceContext?
+        ServiceContext serviceContext = msgContext.getServiceContext();
+        if (serviceContext != null && !serviceContext.getPropertyDifferences().isEmpty())
{
+            contexts.add(serviceContext);
+        }
+
+        // Do the actual replication here
+        if (!contexts.isEmpty()) {
+            AbstractContext[] contextArray =
+                    (AbstractContext[]) contexts.toArray(new AbstractContext[contexts.size()]);
+            String msgUUID = contextManager.updateContexts(contextArray);
+            waitForACKs(contextManager, msgUUID, msgContext.getRootContext());
         }
     }
 
+    /**
+     * Replicate all serializable properties stored in the given <code>abstractContext</code>.
+     *
+     * @param abstractContext The AbstractContext which holds the properties to be replicated
+     * @throws ClusteringFault If replication fails
+     */
     public static void replicate(AbstractContext abstractContext) throws ClusteringFault
{
-        if (!doReplication(abstractContext)) {
+        if (!canReplicate(abstractContext)) {
             return;
         }
-        log.debug("Going to replicate state...");
-        try {
-            replicateState(abstractContext);
-        } catch (Exception e) {
-            String message = "Could not replicate the state";
-            log.error(message, e);
-            throw new ClusteringFault(message, e);
+        log.debug("Going to replicate state in " + abstractContext + "...");
+        ContextManager contextManager = getContextManager(abstractContext);
+        if (!abstractContext.getPropertyDifferences().isEmpty()) {
+            String msgUUID = contextManager.updateContext(abstractContext);
+            waitForACKs(contextManager, msgUUID, abstractContext.getRootContext());
         }
     }
 
     /**
-     * Do replication only if context replication is enabled.
-     * Also note that if there are no members, we need not do any replication
+     * Replicate all the properties given in <code>propertyNames</code>
+     * in the specified <code>abstractContext</code>
      *
-     * @param abstractContext
-     * @return true - State needs to be replicated
-     *         false - otherwise
+     * @param abstractContext The context to be replicated
+     * @param propertyNames   The names of the properties to be replicated
+     * @throws ClusteringFault IF replication fails
      */
-    private static boolean doReplication(AbstractContext abstractContext) {
+    public static void replicate(AbstractContext abstractContext,
+                                 String[] propertyNames) throws ClusteringFault {
+        if (!canReplicate(abstractContext)) {
+            return;
+        }
+        log.debug("Going to replicate selected properties in " + abstractContext + "...");
+        ContextManager contextManager = getContextManager(abstractContext);
+        String msgUUID = contextManager.updateContext(abstractContext, propertyNames);
+        if (msgUUID != null) {
+            waitForACKs(contextManager, msgUUID, abstractContext.getRootContext());
+        }
+    }
+
+    private static ContextManager getContextManager(AbstractContext abstractContext) {
         ClusterManager clusterManager =
                 abstractContext.getRootContext().getAxisConfiguration().getClusterManager();
-        return clusterManager != null &&
-               clusterManager.getContextManager() != null;
+        return clusterManager.getContextManager();
     }
 
-    private static void replicateState(AbstractContext abstractContext) throws ClusteringFault
{
+    /**
+     * Check whether the state store in the specified <code>abstractContext</code>
can be replicated.
+     * Also note that if there are no members, we need not do any replication
+     *
+     * @param abstractContext The context to be subjected to this test
+     * @return true - State needs to be replicated
+     *         false - otherwise
+     */
+    private static boolean canReplicate(AbstractContext abstractContext) {
         ClusterManager clusterManager =
                 abstractContext.getRootContext().getAxisConfiguration().getClusterManager();
-        if (clusterManager != null) {
-            ContextManager contextManager = clusterManager.getContextManager();
-            if (contextManager == null) {
-                String msg = "Cannot replicate contexts since " +
-                             "ContextManager is not specified in the axis2.xml file.";
-                throw new ClusteringFault(msg);
-            }
-            if (!abstractContext.getPropertyDifferences().isEmpty()) {
-                String msgUUID = contextManager.updateContext(abstractContext);
-                waitForACKs(contextManager, msgUUID, abstractContext.getRootContext());
-            }
-        } else {
-            String msg = "Cannot replicate contexts since " +
-                         "ClusterManager is not specified in the axis2.xml file.";
-            throw new ClusteringFault(msg);
+        boolean canReplicate = false;
+        if (clusterManager != null && clusterManager.getContextManager() != null)
{
+            canReplicate =
+                    clusterManager.getContextManager().isContextClusterable(abstractContext);
         }
+        return canReplicate;
     }
 
-    private static void replicateState(MessageContext msgContext) throws ClusteringFault
{
-        ConfigurationContext configurationContext = msgContext.getConfigurationContext();
-        AxisConfiguration axisConfiguration = configurationContext.getAxisConfiguration();
-        ClusterManager clusterManager = axisConfiguration.getClusterManager();
-
-        if (clusterManager != null) {
-
-            ContextManager contextManager = clusterManager.getContextManager();
-            if (contextManager == null) {
-                String msg = "Cannot replicate contexts since " +
-                             "ContextManager is not specified in the axis2.xml file.";
-                throw new ClusteringFault(msg);
-            }
-
-            List contexts = new ArrayList();
-
-            // Do we need to replicate state stored in ConfigurationContext?
-            if (!configurationContext.getPropertyDifferences().isEmpty()) {
-                contexts.add(configurationContext);
-            }
-
-            // Do we need to replicate state stored in ServiceGroupContext?
-            ServiceGroupContext sgContext = msgContext.getServiceGroupContext();
-            if (sgContext != null && !sgContext.getPropertyDifferences().isEmpty())
{
-                contexts.add(sgContext);
-            }
-
-            // Do we need to replicate state stored in ServiceContext?
-            ServiceContext serviceContext = msgContext.getServiceContext();
-            if (serviceContext != null && !serviceContext.getPropertyDifferences().isEmpty())
{
-                contexts.add(serviceContext);
-            }
-
-            // Do the actual replication here
-            if (!contexts.isEmpty()) {
-                AbstractContext[] contextArray =
-                        (AbstractContext[]) contexts.toArray(new AbstractContext[contexts.size()]);
-                String msgUUID = contextManager.updateContexts(contextArray);
-                waitForACKs(contextManager, msgUUID, msgContext.getRootContext());
-            }
-
-        } else {
-            String msg = "Cannot replicate contexts since " +
-                         "ClusterManager is not specified in the axis2.xml file.";
-            throw new ClusteringFault(msg);
-        }
+    /**
+     * Check whether the state store in the specified <code>messageContext</code>
can be replicated.
+     * Also note that if there are no members, we need not do any replication
+     *
+     * @param messageContext The MessageContext to be subjected to this test
+     * @return true - State needs to be replicated
+     *         false - otherwise
+     */
+    private static boolean canReplicate(MessageContext messageContext) {
+        ClusterManager clusterManager =
+                messageContext.getRootContext().getAxisConfiguration().getClusterManager();
+        return clusterManager != null && clusterManager.getContextManager() != null;
     }
 
     private static void waitForACKs(ContextManager contextManager,



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message