axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From az...@apache.org
Subject svn commit: r674009 - in /webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering: control/wka/ tribes/
Date Fri, 04 Jul 2008 11:14:36 GMT
Author: azeez
Date: Fri Jul  4 04:14:35 2008
New Revision: 674009

URL: http://svn.apache.org/viewvc?rev=674009&view=rev
Log:
1. Notify the LB group when a new load balancer member joins
2. No need to LeaveGroup message
3. Code improvements


Added:
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/OperationMode.java
      - copied, changed from r673345, webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/Mode.java
Removed:
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/control/wka/LeaveGroupCommand.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/Mode.java
Modified:
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ApplicationMode.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/LoadBalancerInterceptor.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/LoadBalancerMode.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/MembershipManager.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/MulticastBasedMembershipScheme.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesClusterManager.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesUtil.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/WkaBasedMembershipScheme.java

Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ApplicationMode.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ApplicationMode.java?rev=674009&r1=674008&r2=674009&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ApplicationMode.java
(original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ApplicationMode.java
Fri Jul  4 04:14:35 2008
@@ -27,7 +27,7 @@
 /**
  *  Represents a member running in application mode
  */
-public class ApplicationMode implements Mode {
+public class ApplicationMode implements OperationMode {
 
      private static final Log log = LogFactory.getLog(LoadBalancerMode.class);
 

Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/LoadBalancerInterceptor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/LoadBalancerInterceptor.java?rev=674009&r1=674008&r2=674009&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/LoadBalancerInterceptor.java
(original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/LoadBalancerInterceptor.java
Fri Jul  4 04:14:35 2008
@@ -19,8 +19,6 @@
 import org.apache.catalina.tribes.group.ChannelInterceptorBase;
 import org.apache.catalina.tribes.membership.Membership;
 
-import java.util.Arrays;
-
 /**
  * This interceptor is used when this member is part of a load balancer cluster.
  * This load balancer is responsible for load balancing across applications deployed in
@@ -43,9 +41,10 @@
     }
 
     public void messageReceived(ChannelMessage msg) {
-        // Ignore all messages which are not intended for the load balancer group
+        // Ignore all messages which are not intended for the load balancer group or which
are not
+        // membership messages
         if (okToProcess(msg.getOptions()) ||
-            Arrays.equals(msg.getAddress().getDomain(), loadBalancerDomain)) {
+            TribesUtil.isInDomain(msg.getAddress(), loadBalancerDomain)) {
             super.messageReceived(msg);
         }
     }

Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/LoadBalancerMode.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/LoadBalancerMode.java?rev=674009&r1=674008&r2=674009&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/LoadBalancerMode.java
(original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/LoadBalancerMode.java
Fri Jul  4 04:14:35 2008
@@ -27,14 +27,13 @@
 import org.apache.commons.logging.LogFactory;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 
 /**
  * Represents a member running in load balance mode
  */
-public class LoadBalancerMode implements Mode {
+public class LoadBalancerMode implements OperationMode {
 
     private static final Log log = LogFactory.getLog(LoadBalancerMode.class);
 
@@ -88,9 +87,14 @@
         return membershipManagers;
     }
 
-    public void notifyMemberJoin(final Member member) { 
+    public void notifyMemberJoin(final Member member) {
 
-        if (Arrays.equals(loadBalancerDomain, member.getDomain())) {  // A peer load balancer
has joined. Need to send it the entire member lists
+        if (TribesUtil.isInDomain(member, loadBalancerDomain)) {  // A peer load balancer
has joined
+
+            // Notify all members in the LB group
+            primaryMembershipManager.sendMemberJoinedToAll(member);
+
+            // Send the MEMBER_LISTS of all the groups to the the new LB member
             for (MembershipManager manager : membershipManagers) {
                 manager.sendMemberList(member);
             }
@@ -100,28 +104,42 @@
             Thread th = new Thread() {
                 public void run() {
                     for (MembershipManager manager : membershipManagers) {
-                        if (Arrays.equals(manager.getDomain(), member.getDomain())) {
+                        if (TribesUtil.isInDomain(member, manager.getDomain())) {
+
+                            // Send MEMBER_JOINED to the group of the new member
                             manager.sendMemberJoinedToAll(member);
-                            MemberJoinedCommand cmd = new MemberJoinedCommand();
-                            cmd.setMember(member);
-                            try {
-                                RpcChannel rpcChannel = manager.getRpcMembershipChannel();
-                                rpcChannel.send(primaryMembershipManager.getMembers(),
-                                                cmd,
-                                                RpcChannel.ALL_REPLY,
-                                                Channel.SEND_OPTIONS_ASYNCHRONOUS,
-                                                10000);
-                            } catch (ChannelException e) {
-                                String errMsg = "Could not send MEMBER_JOINED[" +
-                                                TribesUtil.getName(member) +
-                                                "] to all load balancer members ";
-                                log.error(errMsg, e);
-                                throw new RemoteProcessException(errMsg, e);
-                            }
+
+                            // Send MEMBER_JOINED to the load balancer group
+                            sendMemberJoinedToLoadBalancerGroup(manager.getRpcMembershipChannel(),
+                                                                member);
                             break;
                         }
                     }
                 }
+
+                /**
+                 * Send MEMBER_JOINED to the load balancer group
+                 * @param rpcChannel The RpcChannel corresponding to the member's group
+                 * @param member  The member who joined
+                 */
+                private void sendMemberJoinedToLoadBalancerGroup(RpcChannel rpcChannel,
+                                                                 Member member) {
+                    MemberJoinedCommand cmd = new MemberJoinedCommand();
+                    cmd.setMember(member);
+                    try {
+                        rpcChannel.send(primaryMembershipManager.getMembers(),
+                                        cmd,
+                                        RpcChannel.ALL_REPLY,
+                                        Channel.SEND_OPTIONS_ASYNCHRONOUS,
+                                        10000);
+                    } catch (ChannelException e) {
+                        String errMsg = "Could not send MEMBER_JOINED[" +
+                                        TribesUtil.getName(member) +
+                                        "] to all load balancer members ";
+                        log.error(errMsg, e);
+                        throw new RemoteProcessException(errMsg, e);
+                    }
+                }
             };
             th.start();
         }

Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/MembershipManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/MembershipManager.java?rev=674009&r1=674008&r2=674009&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/MembershipManager.java
(original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/MembershipManager.java
Fri Jul  4 04:14:35 2008
@@ -134,7 +134,7 @@
 
         // If this member already exists or if the member belongs to another domain,
         // there is no need to add it
-        if (members.contains(member) || !Arrays.equals(domain, member.getDomain())) {
+        if (members.contains(member) || !TribesUtil.isInDomain(member, domain)) {
             return false;
         }
 
@@ -146,7 +146,7 @@
         }
 
         boolean shouldAddMember = localMember == null ||
-                                  Arrays.equals(localMember.getDomain(), member.getDomain());
+                                  TribesUtil.areInSameDomain(localMember, member);
 
         // If this member is a load balancer, notify the respective load balance event handler?
         if (loadBalanceEventHandler != null) {
@@ -179,9 +179,9 @@
                     // if it does not belong to this domain, simply remove it from the members
                     if(responses != null && responses.length > 0 && responses[0]
!= null){
                         Member source = responses[0].getSource();
-                        if(!Arrays.equals(source.getDomain(), member.getDomain())){
+                        if(!TribesUtil.areInSameDomain(source, member)){
                             if(log.isDebugEnabled()){
-                                log.debug("Member " + TribesUtil.getName(source) +
+                                log.debug("WKA Member " + TribesUtil.getName(source) +
                                           " does not belong to local domain " + new String(domain)+
                                           ". Hence removing it from the list.");
                             }

Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/MulticastBasedMembershipScheme.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/MulticastBasedMembershipScheme.java?rev=674009&r1=674008&r2=674009&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/MulticastBasedMembershipScheme.java
(original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/MulticastBasedMembershipScheme.java
Fri Jul  4 04:14:35 2008
@@ -53,10 +53,10 @@
     /**
      * The mode in which this member operates such as "loadBalance" or "application"
      */
-    private Mode mode;
+    private OperationMode mode;
 
     public MulticastBasedMembershipScheme(ManagedChannel channel,
-                                          Mode mode,
+                                          OperationMode mode,
                                           Map<String, Parameter> parameters,
                                           byte[] domain) {
         this.channel = channel;

Copied: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/OperationMode.java
(from r673345, webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/Mode.java)
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/OperationMode.java?p2=webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/OperationMode.java&p1=webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/Mode.java&r1=673345&r2=674009&rev=674009&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/Mode.java
(original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/OperationMode.java
Fri Jul  4 04:14:35 2008
@@ -21,9 +21,9 @@
 import java.util.List;
 
 /**
- * The mode in which this member is running such a loadBalance or application
+ * The mode in which this member is operating such a loadBalance or application
  */
-public interface Mode {
+public interface OperationMode {
 
     /**
      * Add channel interecptors

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=674009&r1=674008&r2=674009&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
Fri Jul  4 04:14:35 2008
@@ -87,7 +87,7 @@
     /**
      * The mode in which this member operates such as "loadBalance" or "application"
      */
-    private Mode mode;
+    private OperationMode mode;
 
     /**
      * Static members

Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesUtil.java?rev=674009&r1=674008&r2=674009&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesUtil.java
(original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesUtil.java
Fri Jul  4 04:14:35 2008
@@ -21,6 +21,7 @@
 
 import org.apache.catalina.tribes.Channel;
 import org.apache.catalina.tribes.Member;
+import org.apache.catalina.tribes.util.Arrays;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -73,4 +74,12 @@
     public static byte[] getRpcInitChannelId(byte[] domain) {
         return (new String(domain) + ":" + TribesConstants.RPC_INIT_CHANNEL).getBytes();
     }
+
+    public static boolean isInDomain(Member member, byte[] domain){
+        return Arrays.equals(domain, member.getDomain());
+    }
+
+    public static boolean areInSameDomain(Member member1, Member member2){
+        return Arrays.equals(member1.getDomain(), member2.getDomain());
+    }
 }

Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/WkaBasedMembershipScheme.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/WkaBasedMembershipScheme.java?rev=674009&r1=674008&r2=674009&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/WkaBasedMembershipScheme.java
(original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/WkaBasedMembershipScheme.java
Fri Jul  4 04:14:35 2008
@@ -77,10 +77,10 @@
     /**
      * The mode in which this member operates such as "loadBalance" or "application"
      */
-    private Mode mode;
+    private OperationMode mode;
 
     public WkaBasedMembershipScheme(ManagedChannel channel,
-                                    Mode mode,
+                                    OperationMode mode,
                                     List<MembershipManager> applicationDomainMembershipManagers,
                                     MembershipManager primaryMembershipManager,
                                     Map<String, Parameter> parameters,
@@ -418,8 +418,8 @@
                 command.execute(null); // Set the list of current members
 
                 // If the WKA member is not part of this group, remove it
-                if (!Arrays.equals(response.getSource().getDomain(),
-                                   primaryMembershipManager.getLocalMember().getDomain()))
{
+                if (!TribesUtil.areInSameDomain(response.getSource(),
+                                                primaryMembershipManager.getLocalMember()))
{
                     primaryMembershipManager.memberDisappeared(response.getSource());
                     if (log.isDebugEnabled()) {
                         log.debug("Removed member " + TribesUtil.getName(response.getSource())
+



Mime
View raw message