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 az...@apache.org on 2008/05/12 12:51:04 UTC

svn commit: r655465 - in /webservices/axis2/trunk/java/modules: clustering/src/org/apache/axis2/clustering/tribes/ clustering/test/org/apache/axis2/clustering/tribes/ kernel/conf/

Author: azeez
Date: Mon May 12 03:51:04 2008
New Revision: 655465

URL: http://svn.apache.org/viewvc?rev=655465&view=rev
Log:
1. Added parameter to bind the NW interface on which multicasts will be received
2. Added test classes to check multicasting on a N 


Added:
    webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/tribes/MulticastReceiver.java
    webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/tribes/MulticastSender.java
Modified:
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesClusterManager.java
    webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml

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=655465&r1=655464&r2=655465&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 Mon May 12 03:51:04 2008
@@ -49,16 +49,13 @@
 import org.apache.catalina.tribes.group.RpcChannel;
 import org.apache.catalina.tribes.group.interceptors.DomainFilterInterceptor;
 import org.apache.catalina.tribes.group.interceptors.OrderInterceptor;
-import org.apache.catalina.tribes.group.interceptors.StaticMembershipInterceptor;
 import org.apache.catalina.tribes.group.interceptors.TcpFailureDetector;
-import org.apache.catalina.tribes.membership.StaticMember;
 import org.apache.catalina.tribes.transport.MultiPointSender;
 import org.apache.catalina.tribes.transport.ReceiverBase;
 import org.apache.catalina.tribes.transport.ReplicationTransmitter;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -158,6 +155,8 @@
         } else {
             domain = "apache.axis2.domain".getBytes();
         }
+        channel.getMembershipService().getProperties().setProperty("mcastClusterDomain",
+                                                                   new String(domain));
 
         // Add all the ChannelInterceptors
         addInterceptors(channel, domain);
@@ -263,6 +262,11 @@
         if (mcastAddress != null) {
             mcastProps.setProperty("mcastAddress", ((String) mcastAddress.getValue()).trim());
         }
+        Parameter mcastBindAddress = getParameter("multicastBindAddress");
+        if (mcastBindAddress != null) {
+            mcastProps.setProperty("mcastBindAddress", ((String) mcastBindAddress.getValue()).trim());
+        }
+
         Parameter mcastPort = getParameter("multicastPort");
         if (mcastPort != null) {
             mcastProps.setProperty("mcastPort", ((String) mcastPort.getValue()).trim());
@@ -279,7 +283,7 @@
         // Set the IP address that will be advertised by this node
         ReceiverBase receiver = (ReceiverBase) channel.getChannelReceiver();
         Parameter tcpListenHost = getParameter("tcpListenHost");
-        if(tcpListenHost != null){
+        if (tcpListenHost != null) {
             String host = ((String) tcpListenHost.getValue()).trim();
             mcastProps.setProperty("tcpListenHost", host);
             mcastProps.setProperty("bindAddress", host);
@@ -291,7 +295,7 @@
         }
 
         Parameter tcpListenPort = getParameter("tcpListenPort");
-        if(tcpListenPort != null){
+        if (tcpListenPort != null) {
             String port = ((String) tcpListenPort.getValue()).trim();
             mcastProps.setProperty("tcpListenPort", port);
             receiver.setPort(Integer.parseInt(port));

Added: webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/tribes/MulticastReceiver.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/tribes/MulticastReceiver.java?rev=655465&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/tribes/MulticastReceiver.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/tribes/MulticastReceiver.java Mon May 12 03:51:04 2008
@@ -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.clustering.tribes;
+
+import java.net.DatagramPacket;
+import java.net.InetAddress;
+import java.net.MulticastSocket;
+
+/**
+ *
+ */
+public class MulticastReceiver {
+
+    public static final String ip = "228.1.2.3";
+    public static final int port = 45678;
+
+    public static void main(String[] args) throws Exception {
+
+        MulticastSocket msocket = new MulticastSocket(port);
+        InetAddress group = InetAddress.getByName(ip);
+        msocket.joinGroup(group);
+
+        byte[] inbuf = new byte[1024];
+        DatagramPacket packet = new DatagramPacket(inbuf, inbuf.length);
+
+        // Wait for packet
+        msocket.receive(packet);
+
+        // Data is now in inbuf
+        int numBytesReceived = packet.getLength();
+        System.out.println("Recd: " + new String(inbuf, 0, numBytesReceived));
+    }
+}

Added: webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/tribes/MulticastSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/tribes/MulticastSender.java?rev=655465&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/tribes/MulticastSender.java (added)
+++ webservices/axis2/trunk/java/modules/clustering/test/org/apache/axis2/clustering/tribes/MulticastSender.java Mon May 12 03:51:04 2008
@@ -0,0 +1,54 @@
+/*                                                                             
+ * 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.clustering.tribes;
+
+import java.io.IOException;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.net.InetAddress;
+import java.net.SocketException;
+
+/**
+ *
+ */
+public class MulticastSender {
+    public static final String ip = "228.1.2.3";
+    public static final int port = 45678;
+
+    public static void main(String[] args) throws Exception {
+
+        // Multicast send
+        byte[] outbuf = "Hello world".getBytes();
+
+
+        DatagramSocket socket = null;
+        try {
+            socket = new DatagramSocket();
+            InetAddress groupAddr = InetAddress.getByName(ip);
+            DatagramPacket packet = new DatagramPacket(outbuf, outbuf.length, groupAddr, port);
+            socket.send(packet);
+        } catch (SocketException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            if (socket != null) {
+                socket.close();
+            }
+        }
+        System.out.println("Sent");
+    }
+}

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?rev=655465&r1=655464&r2=655465&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml (original)
+++ webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml Mon May 12 03:51:04 2008
@@ -252,6 +252,7 @@
         <parameter name="maxRetries">10</parameter>
 
         <parameter name="multicastAddress">228.0.0.4</parameter>
+        <parameter name="multicastBindAddress">127.0.0.1</parameter>
         <parameter name="multicastPort">45564</parameter>
         <parameter name="multicastFrequency">500</parameter>
         <parameter name="multicastMemberDropTime">3000</parameter>



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