You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ch...@apache.org on 2007/03/21 12:11:13 UTC

svn commit: r520840 - in /webservices/axis2/trunk/java/modules: clustering/src/org/apache/axis2/cluster/tribes/ clustering/src/org/apache/axis2/cluster/tribes/util/ clustering/test/org/apache/axis2/clustering/configuration/ kernel/conf/ kernel/src/org/...

Author: chamikara
Date: Wed Mar 21 04:11:12 2007
New Revision: 520840

URL: http://svn.apache.org/viewvc?view=rev&rev=520840
Log:
Added a way to add parameters to the clustering area. 
Also users can set an AVOID_INITIATION_KEY parameter which will skip the default initiation of the CM.


Added:
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/util/
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/util/TribesUtil.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/ClusteringConstants.java
Modified:
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesClusterManager.java
    webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/configuration/TestConfigurationManagerListener.java
    webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/ClusterManager.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContext.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContextFactory.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ClusterBuilder.java

Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesClusterManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesClusterManager.java?view=diff&rev=520840&r1=520839&r2=520840
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesClusterManager.java (original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/TribesClusterManager.java Wed Mar 21 04:11:12 2007
@@ -16,6 +16,11 @@
 
 package org.apache.axis2.cluster.tribes;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.apache.axiom.om.OMElement;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.cluster.ClusterManager;
 import org.apache.axis2.cluster.ClusteringFault;
@@ -26,11 +31,15 @@
 import org.apache.axis2.cluster.tribes.context.TribesContextManager;
 import org.apache.axis2.cluster.tribes.info.TransientTribesChannelInfo;
 import org.apache.axis2.cluster.tribes.info.TransientTribesMemberInfo;
+import org.apache.axis2.cluster.tribes.util.TribesUtil;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.Parameter;
 import org.apache.axis2.rpc.receivers.RPCMessageReceiver;
 import org.apache.catalina.tribes.Channel;
 import org.apache.catalina.tribes.ChannelException;
+import org.apache.catalina.tribes.ManagedChannel;
+import org.apache.catalina.tribes.Member;
 import org.apache.catalina.tribes.group.GroupChannel;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -42,12 +51,14 @@
 	private ConfigurationContext configContext = null;
 	private ContextUpdater updater;
 	private static long timeout = 1000L; // this should be configured in the axis2.xml
+	private HashMap parameters = null;
 	
     private static final Log log = LogFactory.getLog(TribesClusterManager.class);
     
     public TribesClusterManager () {
 		contextManager = new TribesContextManager ();
 		configurationManager = new TribesConfigurationManager ();
+		parameters = new HashMap ();
     }
 	
 	public ContextManager getContextManager() {
@@ -75,7 +86,8 @@
         configurationManager.setSender(sender);
 
         try {
-			Channel channel = new GroupChannel();
+			ManagedChannel channel = new GroupChannel();
+
 			channel.addChannelListener (listener);
 			channel.addChannelListener(channelInfo);
 			channel.addMembershipListener(memberInfo);
@@ -85,6 +97,9 @@
 			contextManager.setSender(sender);
 			configurationManager.setSender(sender);
 			
+			Member[] members = channel.getMembers();
+			TribesUtil.printMembers (members);
+			
 			updater = new ContextUpdater ();
 			contextManager.setUpdater(updater);
 			
@@ -119,4 +134,39 @@
 	public void setContextManager(ContextManager contextManager) {
 		this.contextManager = (TribesContextManager) contextManager;
 	}
+
+	public void addParameter(Parameter param) throws AxisFault {
+		parameters.put(param.getName(), param);
+	}
+
+	public void deserializeParameters(OMElement parameterElement) throws AxisFault {
+		throw new UnsupportedOperationException ();
+	}
+
+	public Parameter getParameter(String name) {
+		return (Parameter) parameters.get(name);
+	}
+
+	public ArrayList getParameters() {
+		ArrayList list = new ArrayList ();
+		for (Iterator it=parameters.keySet().iterator();it.hasNext();) { 
+			list.add(parameters.get(it.next()));
+		}
+		
+		return list;
+	}
+
+	public boolean isParameterLocked(String parameterName) {
+		
+		Parameter parameter = (Parameter) parameters.get(parameterName);
+		if (parameter!=null)
+			return parameter.isLocked();
+		
+		return false;
+	}
+
+	public void removeParameter(Parameter param) throws AxisFault {
+		parameters.remove(param.getName());
+	}
+	
 }

Added: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/util/TribesUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/util/TribesUtil.java?view=auto&rev=520840
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/util/TribesUtil.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/cluster/tribes/util/TribesUtil.java Wed Mar 21 04:11:12 2007
@@ -0,0 +1,46 @@
+/*
+ * 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.cluster.tribes.util;
+
+import org.apache.catalina.tribes.Member;
+
+public class TribesUtil {
+
+	public static void printMembers(Member[] members) {
+		
+		System.out.println("*****************PRINTING MEMBERS OF THE CURRENT TRIBES GROUP****************");
+
+		if (members != null) {
+			int length = members.length;
+			for (int i = 0; i < length; i++) {
+				byte[] hostBts = members[i].getHost();
+				String HOST = null;
+				if (hostBts != null) {
+					for (int j = 0; j < hostBts.length; j++) {
+						HOST = HOST == null ? ("" + hostBts[j]) : (HOST + "." + hostBts[j]);
+					}
+				}
+
+				String port = "" + members[i].getPort();
+				System.out.println("Member " + (i + 1) + " NAME:" + members[i].getName() + " HOST:"
+						+ HOST + "  PORT:" + port);
+
+			}
+		}
+	}
+
+}

Modified: webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/configuration/TestConfigurationManagerListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/configuration/TestConfigurationManagerListener.java?view=diff&rev=520840&r1=520839&r2=520840
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/configuration/TestConfigurationManagerListener.java (original)
+++ webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/configuration/TestConfigurationManagerListener.java Wed Mar 21 04:11:12 2007
@@ -30,6 +30,10 @@
 		eventList = new ArrayList ();
 	}
 	
+	public void handleException(Throwable throwable) {
+		// TODO Auto-generated method stub
+	}
+
 	public void clearEventList () {
 		eventList.clear();
 	}

Modified: webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml?view=diff&rev=520840&r1=520839&r2=520840
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml (original)
+++ webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml Wed Mar 21 04:11:12 2007
@@ -244,6 +244,7 @@
     <!-- Configure and uncomment following for preparing Axis2 to a clustered environment -->
     <!-- 
     <cluster class="org.apache.axis2.cluster.tribes.TribesClusterManager">
+        <parameter name="param1" locked="false">value1</parameter>
     	<configurationManager class="org.apache.axis2.cluster.tribes.configuration.TribesConfigurationManager">
     	    <listeners>
     	    </listeners>

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/ClusterManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/ClusterManager.java?view=diff&rev=520840&r1=520839&r2=520840
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/ClusterManager.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/ClusterManager.java Wed Mar 21 04:11:12 2007
@@ -19,8 +19,10 @@
 import org.apache.axis2.cluster.configuration.ConfigurationManager;
 import org.apache.axis2.cluster.context.ContextManager;
 import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.ParameterInclude;
 
-public interface ClusterManager {
+public interface ClusterManager extends ParameterInclude {
+	
     public void init(ConfigurationContext configurationContext) throws ClusteringFault;
     public ContextManager getContextManager ();
     public ConfigurationManager getConfigurationManager ();

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/ClusteringConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/ClusteringConstants.java?view=auto&rev=520840
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/ClusteringConstants.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/cluster/ClusteringConstants.java Wed Mar 21 04:11:12 2007
@@ -0,0 +1,22 @@
+/*
+ * 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.cluster;
+
+public class ClusteringConstants {
+	public static final String AVOID_INITIATION_KEY = "AvoidInitiation";
+}

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=520840&r1=520839&r2=520840
==============================================================================
--- 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 Wed Mar 21 04:11:12 2007
@@ -21,6 +21,7 @@
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
 import org.apache.axis2.cluster.ClusterManager;
+import org.apache.axis2.cluster.ClusteringConstants;
 import org.apache.axis2.cluster.context.ContextManager;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.AxisServiceGroup;
@@ -29,6 +30,7 @@
 import org.apache.axis2.engine.DependencyManager;
 import org.apache.axis2.engine.ListenerManager;
 import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.util.JavaUtils;
 import org.apache.axis2.util.threadpool.ThreadFactory;
 import org.apache.axis2.util.threadpool.ThreadPool;
 
@@ -93,8 +95,17 @@
         		contextManager.setConfigurationContext(this);
         }
         
-        clusterManager.init(this);
+        if (shouldClusterBeInitiated(clusterManager))
+        	clusterManager.init(this);
     }
+    
+    private static boolean shouldClusterBeInitiated (ClusterManager clusterManager) {
+    	Parameter param = clusterManager.getParameter(ClusteringConstants.AVOID_INITIATION_KEY);
+    	if (param!=null && JavaUtils.isTrueExplicitly(param.getValue()))
+    		return false;
+    	else 
+    		return true;
+    }	
 
     protected void finalize() throws Throwable {
         super.finalize();

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContextFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContextFactory.java?view=diff&rev=520840&r1=520839&r2=520840
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContextFactory.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/context/ConfigurationContextFactory.java Wed Mar 21 04:11:12 2007
@@ -18,6 +18,8 @@
 
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
+import org.apache.axis2.cluster.ClusterManager;
+import org.apache.axis2.cluster.ClusteringConstants;
 import org.apache.axis2.deployment.AxisConfigBuilder;
 import org.apache.axis2.deployment.DeploymentConstants;
 import org.apache.axis2.deployment.DeploymentEngine;
@@ -35,6 +37,7 @@
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.modules.Module;
 import org.apache.axis2.transport.TransportSender;
+import org.apache.axis2.util.JavaUtils;
 import org.apache.axis2.util.SessionUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ClusterBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ClusterBuilder.java?view=diff&rev=520840&r1=520839&r2=520840
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ClusterBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/ClusterBuilder.java Wed Mar 21 04:11:12 2007
@@ -40,7 +40,8 @@
  * Builds a service description from OM
  */
 public class ClusterBuilder extends DescriptionBuilder {
-    private static final Log log = LogFactory.getLog(ClusterBuilder.class);
+
+	private static final Log log = LogFactory.getLog(ClusterBuilder.class);
     private AxisService service;
 
     public ClusterBuilder(AxisConfiguration axisConfig) {
@@ -68,6 +69,10 @@
             Class clazz = Class.forName(className);
             clusterManager = (ClusterManager) clazz.newInstance();
             
+            //loading the parameters.
+            Iterator params = clusterElement.getChildrenWithName(new QName(TAG_PARAMETER));
+            processParameters(params, clusterManager,null );
+            
             //loading the ConfigurationManager
             OMElement configurationManagerElement = clusterElement.getFirstChildWithName(
             			new QName (TAG_CONFIGURATION_MANAGER));
@@ -156,7 +161,6 @@
         } catch (IllegalAccessException e) {
             throw new DeploymentException(e);
         }
-
     }
 
 }



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