axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From az...@apache.org
Subject svn commit: r539716 [2/2] - in /webservices/axis2/trunk/java/modules: clustering/src/org/apache/axis2/cluster/handlers/ clustering/src/org/apache/axis2/cluster/listeners/ clustering/src/org/apache/axis2/cluster/tribes/ clustering/src/org/apache/axis2/c...
Date Sat, 19 May 2007 09:04:23 GMT
Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/info/TransientTribesChannelInfo.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/info/TransientTribesChannelInfo.java?view=diff&rev=539716&r1=539715&r2=539716
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/info/TransientTribesChannelInfo.java
(original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/info/TransientTribesChannelInfo.java
Sat May 19 02:04:21 2007
@@ -19,7 +19,7 @@
 import java.io.Serializable;
 
 import org.apache.axis2.cluster.CommandType;
-import org.apache.axis2.cluster.tribes.context.ContextCommandMessage;
+import org.apache.axis2.cluster.context.ContextCommandMessage;
 import org.apache.catalina.tribes.ChannelListener;
 import org.apache.catalina.tribes.Member;
 

Copied: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/CommandMessage.java
(from r538503, webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/CommandMessage.java)
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/CommandMessage.java?view=diff&rev=539716&p1=webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/CommandMessage.java&r1=538503&p2=webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/CommandMessage.java&r2=539716
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/CommandMessage.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/CommandMessage.java
Sat May 19 02:04:21 2007
@@ -14,11 +14,11 @@
  * limitations under the License.
  */
 
-package org.apache.axis2.cluster.tribes;
+package org.apache.axis2.cluster;
 
 import java.io.Serializable;
 
-public class CommandMessage implements Serializable {
+public abstract class CommandMessage implements Serializable {
 
 	protected int commandType;
 
@@ -29,9 +29,11 @@
 	public void setCommandType(int commandType) {
 		this.commandType = commandType;
 	}
-	
-	public CommandMessage (int commandType) {
+
+    protected CommandMessage() {
+    }
+
+    public CommandMessage (int commandType) {
 		this.commandType = commandType;
 	}
-	
 }

Copied: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/context/ContextCommandMessage.java
(from r538503, webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/ContextCommandMessage.java)
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/context/ContextCommandMessage.java?view=diff&rev=539716&p1=webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/ContextCommandMessage.java&r1=538503&p2=webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/context/ContextCommandMessage.java&r2=539716
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/context/ContextCommandMessage.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/context/ContextCommandMessage.java
Sat May 19 02:04:21 2007
@@ -14,67 +14,27 @@
  * limitations under the License.
  */
 
-package org.apache.axis2.cluster.tribes.context;
+package org.apache.axis2.cluster.context;
 
-import org.apache.axis2.cluster.tribes.CommandMessage;
+import org.apache.axis2.cluster.ClusteringFault;
+import org.apache.axis2.cluster.CommandMessage;
+import org.apache.axis2.context.ConfigurationContext;
 
-public class ContextCommandMessage extends CommandMessage {
+public abstract class ContextCommandMessage extends CommandMessage {
 
-	private String parentId;
-	private String contextId;
-	private String axisDescriptionName;
-	private int contextType;
-
-	public ContextCommandMessage(int commandType, String parentId, String contextId,
-			String axisDescriptionName, int contextType) {
-		super (commandType);
-		this.parentId = parentId;
-		this.contextId = contextId;
-		this.axisDescriptionName = axisDescriptionName;
-		this.contextType = contextType;
-	}
-
-	public String getContextId() {
-		return contextId;
-	}
-
-	public void setContextId(String contextId) {
-		this.contextId = contextId;
-	}
-
-	public String getParentId() {
-		return parentId;
-	}
-
-	public void setParentId(String parentId) {
-		this.parentId = parentId;
-	}
-
-	public String toString() {
-		StringBuilder builder = new StringBuilder();
-		builder.append("TribesCommandMessage [");
-		builder.append(getCommandType() + ",");
-		builder.append(parentId + ",");
-		builder.append(contextId + ",");
-		builder.append(axisDescriptionName + "]");
-
-		return builder.toString();
-	}
-
-	public String getAxisDescriptionName() {
-		return axisDescriptionName;
-	}
-
-	public void setAxisDescriptionName(String axisDescriptionName) {
-		this.axisDescriptionName = axisDescriptionName;
-	}
-
-	public int getContextType() {
-		return contextType;
-	}
-
-	public void setContextType(int contextType) {
-		this.contextType = contextType;
-	}
+    public static final int CREATE_SERVICE_GROUP_CONTEXT_MSG = 0;
+    public static final int CREATE_SERVICE_CONTEXT_MSG = 1;
+    public static final int CREATE_SESSION_CONTEXT_MSG = 2;
+    public static final int UPDATE_SERVICE_GROUP_CONTEXT_MSG = 3;
+    public static final int UPDATE_SERVICE_CONTEXT_MSG = 4;
+    public static final int UPDATE_CONFIGURATION_CONTEXT_MSG = 5;
+    public static final int DELETE_SERVICE_GROUP_CONTEXT_MSG = 6;
+    public static final int DELETE_SERVICE_CONTEXT_MSG = 7;
 
+    protected ContextCommandMessage() {
+    }
+
+    public abstract void execute(ConfigurationContext configContext) throws ClusteringFault;
+
+    public abstract int getMessageType();
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/context/ContextManagerListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/context/ContextManagerListener.java?view=diff&rev=539716&r1=539715&r2=539716
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/context/ContextManagerListener.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/context/ContextManagerListener.java
Sat May 19 02:04:21 2007
@@ -16,11 +16,16 @@
 
 package org.apache.axis2.cluster.context;
 
+import org.apache.axis2.cluster.ClusteringFault;
 import org.apache.axis2.context.ConfigurationContext;
 
 public interface ContextManagerListener {
-    public void contextAdded(ContextEvent event);
-    public void contextRemoved(ContextEvent event);
-    public void contextUpdated(ContextEvent event);
-    public void setConfigurationContext (ConfigurationContext configurationContext);
+    
+    public void contextAdded(ContextCommandMessage message) throws ClusteringFault;
+
+    public void contextRemoved(ContextCommandMessage message) throws ClusteringFault;
+
+    public void contextUpdated(ContextCommandMessage message) throws ClusteringFault;
+
+    public void setConfigurationContext(ConfigurationContext configurationContext);
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/AbstractContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/AbstractContext.java?view=diff&rev=539716&r1=539715&r2=539716
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/AbstractContext.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/AbstractContext.java
Sat May 19 02:04:21 2007
@@ -23,6 +23,7 @@
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.i18n.Messages;
 
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -41,6 +42,7 @@
 
     protected transient AbstractContext parent;
     protected transient Map properties;
+    private transient Map propertyDifferences = new HashMap();
 
     protected AbstractContext(AbstractContext parent) {
         this.parent = parent;
@@ -50,12 +52,16 @@
     }
 
     /**
-     * @return Returns AbstractContext.
+     * @return Returns the parent of this context.
      */
     public AbstractContext getParent() {
         return parent;
     }
 
+    /**
+     * @return The properties
+     * @deprecated
+     */
     public Map getProperties() {
         if (this.properties == null) {
             this.properties = new HashMap();
@@ -64,24 +70,108 @@
     }
 
     /**
+     * An iterator over a collection of <code>String</code> objects, which are
the
+     * keys in the properties object.
+     *
+     * @return Iterator over a collection of keys
+     */
+    public Iterator getPropertyNames() {
+        return properties.keySet().iterator();
+    }
+
+    /**
      * Retrieves an object given a key.
      *
      * @param key - if not found, will return null
      * @return Returns the property.
      */
     public Object getProperty(String key) {
-        Object obj;
-
-        obj = properties == null ? null : properties.get(key);
-
+        Object obj = properties == null ? null : properties.get(key);
         if ((obj == null) && (parent != null)) {
             obj = parent.getProperty(key);
-        }
+        } else {
 
+            // Assume that a property is which is read may be updated.
+            // i.e. The object pointed to by 'value' may be modified after it is read
+            propertyDifferences.put(key, new PropertyDifference(key, false));
+        }
         return obj;
     }
 
     /**
+     * Store a property in this context
+     *
+     * @param key
+     * @param value
+     */
+    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));
+    }
+
+    /**
+     * 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) {
+        if (this.properties == null) {
+            this.properties = new HashMap();
+        }
+        properties.put(key, value);
+    }
+
+    /**
+     * Remove a property. Only properties at this level will be removed.
+     * Properties of the parents cannot be removed using this method.
+     *
+     * @param key
+     */
+    public void removeProperty(String key) {
+        if (properties != null) {
+            properties.remove(key);
+        }
+        propertyDifferences.put(key, new PropertyDifference(key, true));
+    }
+
+    /**
+     * 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) {
+        if (properties != null) {
+            properties.remove(key);
+        }
+    }
+
+    /**
+     * Get the property differences since the last transmission by the clustering
+     * mechanism
+     *
+     * @return The property differences
+     */
+    public Map getPropertyDifferences() {
+        return Collections.unmodifiableMap(propertyDifferences);
+    }
+
+    /**
+     * Once the clustering mechanism transmits the property differences,
+     * it should call this method to avoid retransmitting stuff that has already
+     * been sent.
+     */
+    public void clearPropertyDifferences() {
+        propertyDifferences.clear();
+    }
+
+    /**
      * @param context
      */
     public void setParent(AbstractContext context) {
@@ -118,35 +208,17 @@
      */
     public void mergeProperties(Map props) {
         if (props != null) {
-            Iterator iterator = props.keySet().iterator();
-
-            while (iterator.hasNext()) {
+            if (this.properties == null) {
+                this.properties = new HashMap();
+            }
+            for (Iterator iterator = props.keySet().iterator();
+                 iterator.hasNext();) {
                 Object key = iterator.next();
-
-                if (this.properties == null) {
-                    this.properties = new HashMap();
-                }
-
                 this.properties.put(key, props.get(key));
             }
-
         }
     }
 
-
-    /**
-     * Store a property for message context
-     *
-     * @param key
-     * @param value
-     */
-    public void setProperty(String key, Object value) {
-        if (this.properties == null) {
-            this.properties = new HashMap();
-        }
-        properties.put(key, value);
-    }
-
     /**
      * ServiceContext and ServiceGroupContext are not getting automatically garbage collected.
And there
      * is no specific way for some one to go and make it garbage collectible.
@@ -183,9 +255,10 @@
 
         //Calling the ClusterManager probably to replicate the updated state of the context.
         if (clusterManager != null) {
-        	ContextManager contextManager = clusterManager.getContextManager();
-        	if (contextManager!=null && contextManager.isContextClusterable (this))
-        		contextManager.updateContext(this);
+            ContextManager contextManager = clusterManager.getContextManager();
+            if (contextManager != null && contextManager.isContextClusterable(this))
{
+                contextManager.updateContext(this);
+            }
         }
 
         //Other logic needed for flushing the contexts

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java?view=diff&rev=539716&r1=539715&r2=539716
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java
Sat May 19 02:04:21 2007
@@ -237,8 +237,7 @@
         }
     }
 
-    public void registerServiceGroupContextintoSoapSessionTable(
-            ServiceGroupContext serviceGroupContext) {
+    public void registerServiceGroupContextintoSoapSessionTable(ServiceGroupContext serviceGroupContext)
{
         String id = serviceGroupContext.getId();
         serviceGroupContextMap.put(id, serviceGroupContext);
         serviceGroupContext.touch();

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/PropertyDifference.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/PropertyDifference.java?view=auto&rev=539716
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/PropertyDifference.java
(added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/PropertyDifference.java
Sat May 19 02:04:21 2007
@@ -0,0 +1,60 @@
+/*                                                                             
+ * Copyright 2004,2005 The Apache Software Foundation.                         
+ *                                                                             
+ * Licensed under the Apache License, Version 2.0 (the "License");             
+ * you may not use this file except in compliance with the License.            
+ * You may obtain a copy of the License at                                     
+ *                                                                             
+ *      http://www.apache.org/licenses/LICENSE-2.0                             
+ *                                                                             
+ * Unless required by applicable law or agreed to in writing, software         
+ * distributed under the License is distributed on an "AS IS" BASIS,           
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.    
+ * See the License for the specific language governing permissions and         
+ * limitations under the License.                                              
+ */
+package org.apache.axis2.context;
+
+import java.io.Serializable;
+
+/**
+ * This class holds the difference between two properties which are stored in the
+ * AbstractContext
+ */
+public class PropertyDifference implements Serializable {
+
+    private String key;
+    private Object value;
+    private boolean isRemoved;
+
+    public PropertyDifference(String key, boolean isRemoved) {
+        this.key = key;
+        this.isRemoved = isRemoved;
+    }
+
+    public PropertyDifference(String key, Object value, boolean isRemoved) {
+        this.key = key;
+        this.value = value;
+        this.isRemoved = isRemoved;
+    }
+
+    public String getKey() {
+        return key;
+    }
+
+    public Object getValue() {
+        return value;
+    }
+
+    public void setValue(Object value) {
+        this.value = value;
+    }
+
+    public boolean isRemoved() {
+        return isRemoved;
+    }
+
+    public void setRemoved(boolean removed) {
+        isRemoved = removed;
+    }
+}

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ServiceGroupContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ServiceGroupContext.java?view=diff&rev=539716&r1=539715&r2=539716
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ServiceGroupContext.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ServiceGroupContext.java
Sat May 19 02:04:21 2007
@@ -17,6 +17,7 @@
 
 package org.apache.axis2.context;
 
+import org.apache.axiom.om.util.UUIDGenerator;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.cluster.ClusterManager;
 import org.apache.axis2.cluster.context.ContextManager;
@@ -28,7 +29,6 @@
 import org.apache.axis2.util.ObjectStateUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.axiom.om.util.UUIDGenerator;
 
 import java.io.Externalizable;
 import java.io.IOException;
@@ -132,6 +132,18 @@
      * @throws AxisFault if something goes wrong
      */
     public ServiceContext getServiceContext(AxisService service) throws AxisFault {
+        return getServiceContext(service, true);
+    }
+
+    /**
+     * @param service
+     * @param replicate Indicates whether the newly created ServiceContext
+     *                  has to be replicated across the cluster
+     * @return
+     * @throws AxisFault
+     */
+    public ServiceContext getServiceContext(AxisService service,
+                                            boolean replicate) throws AxisFault {
         AxisService axisService = axisServiceGroup.getService(service.getName());
         if (axisService == null) {
             throw new AxisFault(Messages.getMessage("invalidserviceinagroup",
@@ -147,13 +159,16 @@
             getRootContext().contextCreated(serviceContext);
             serviceContextMap.put(service.getName(), serviceContext);
 
-            ClusterManager clusterManager = axisService.getAxisConfiguration().getClusterManager();
-            if (clusterManager != null) {
-            	ContextManager contextManager = clusterManager.getContextManager();
-            	if (contextManager!=null)
-            		contextManager.addContext(serviceContext);
+            if (replicate) {
+                ClusterManager clusterManager =
+                        axisService.getAxisConfiguration().getClusterManager();
+                if (clusterManager != null) {
+                    ContextManager contextManager = clusterManager.getContextManager();
+                    if (contextManager != null) {
+                        contextManager.addContext(serviceContext);
+                    }
+                }
             }
-
         }
         return serviceContext;
     }
@@ -366,7 +381,7 @@
         // trace point
         if (log.isTraceEnabled()) {
             log.trace(myClassName + ":readExternal():  BEGIN  bytes available in stream ["
+
-                    in.available() + "]  ");
+                      in.available() + "]  ");
         }
 
         // serialization version ID
@@ -539,7 +554,7 @@
     private void checkActivateWarning(String methodname) {
         if (needsToBeReconciled) {
             log.warn(myClassName + ":" + methodname + "(): ****WARNING**** " + myClassName
+
-                    ".activate(configurationContext) needs to be invoked.");
+                     ".activate(configurationContext) needs to be invoked.");
         }
     }
 



---------------------------------------------------------------------
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