axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From az...@apache.org
Subject svn commit: r702441 - in /webservices/axis2/trunk/java/modules: clustering/src/org/apache/axis2/clustering/tribes/ kernel/conf/ kernel/src/org/apache/axis2/clustering/
Date Tue, 07 Oct 2008 11:47:32 GMT
Author: azeez
Date: Tue Oct  7 04:47:31 2008
New Revision: 702441

URL: http://svn.apache.org/viewvc?rev=702441&view=rev
Log:
Setting isActive property on Members


Modified:
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/Axis2Coordinator.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/TribesClusterManager.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesMembershipListener.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesUtil.java
    webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/ClusteringConstants.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/Member.java

Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/Axis2Coordinator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/Axis2Coordinator.java?rev=702441&r1=702440&r2=702441&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/Axis2Coordinator.java
(original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/Axis2Coordinator.java
Tue Oct  7 04:47:31 2008
@@ -21,6 +21,7 @@
  *  The non-blocking coordinator interceptor 
  */
 public class Axis2Coordinator extends NonBlockingCoordinator {
+
     public void fireInterceptorEvent(InterceptorEvent event) {
         int type = event.getEventType();
         if (type == CoordinationEvent.EVT_CONF_RX && isCoordinator()) {

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=702441&r1=702440&r2=702441&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
Tue Oct  7 04:47:31 2008
@@ -34,11 +34,8 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Properties;
 import java.util.Random;
 
 /**
@@ -150,7 +147,7 @@
         if (loadBalanceEventHandler != null) {
             log.info("Application member " + TribesUtil.getName(member) + " joined group
" +
                      new String(member.getDomain()));
-            loadBalanceEventHandler.applicationMemberAdded(toAxis2Member(member));
+            loadBalanceEventHandler.applicationMemberAdded(TribesUtil.toAxis2Member(member));
         }
 
         if (shouldAddMember) {
@@ -259,7 +256,7 @@
         }
     }
 
-    private org.apache.axis2.clustering.Member toAxis2Member(Member member) {
+    /*private org.apache.axis2.clustering.Member toAxis2Member(Member member) {
         org.apache.axis2.clustering.Member axis2Member =
                 new org.apache.axis2.clustering.Member(TribesUtil.getHost(member),
                                                        member.getPort());
@@ -275,6 +272,10 @@
             axis2Member.setHttpsPort(Integer.parseInt(https));
         }
 
+        String isActive = props.getProperty("IS_ACTIVE");
+        if(isActive != null && isActive.trim().length() != 0){
+            axis2Member.setActive(Boolean.valueOf(isActive));
+        }
         return axis2Member;
     }
 
@@ -288,7 +289,7 @@
             // This error will never occur
         }
         return props;
-    }
+    }*/
 
     private boolean isLocalMemberInitialized() {
         if (configContext == null) {
@@ -309,7 +310,7 @@
 
         // Is this an application domain member?
         if (loadBalanceEventHandler != null) {
-            loadBalanceEventHandler.applicationMemberRemoved(toAxis2Member(member));
+            loadBalanceEventHandler.applicationMemberRemoved(TribesUtil.toAxis2Member(member));
         }
     }
 

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=702441&r1=702440&r2=702441&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 Oct  7 04:47:31 2008
@@ -162,7 +162,7 @@
         setMaximumRetries();
         configureMode(domain);
         configureMembershipScheme(domain, mode.getMembershipManagers());
-        setMemberTransportInfo();
+        setMemberInfo();
 
         TribesMembershipListener membershipListener = new TribesMembershipListener(primaryMembershipManager);
         channel.addMembershipListener(membershipListener);
@@ -206,26 +206,32 @@
         log.info("Cluster initialization completed.");
     }
 
-    private void setMemberTransportInfo() throws ClusteringFault {
-        Properties transportInfo = new Properties();
+    private void setMemberInfo() throws ClusteringFault {
+        Properties memberInfo = new Properties();
         AxisConfiguration axisConfig = configurationContext.getAxisConfiguration();
         TransportInDescription httpTransport = axisConfig.getTransportIn("http");
         if (httpTransport != null) {
             Parameter port = httpTransport.getParameter("port");
             if (port != null) {
-                transportInfo.put("HTTP", port.getValue());
+                memberInfo.put("HTTP", port.getValue());
             }
         }
         TransportInDescription httpsTransport = axisConfig.getTransportIn("https");
         if (httpsTransport != null) {
             Parameter port = httpsTransport.getParameter("port");
             if (port != null) {
-                transportInfo.put("HTTPS", port.getValue());
+                memberInfo.put("HTTPS", port.getValue());
             }
         }
+        Parameter isActiveParam = getParameter(ClusteringConstants.Parameters.IS_ACTIVE);
+        if(isActiveParam != null){
+            System.out.println("##### isActive=" + isActiveParam.getValue());
+            memberInfo.setProperty(ClusteringConstants.Parameters.IS_ACTIVE,
+                                   (String)isActiveParam.getValue());
+        }
         ByteArrayOutputStream bout = new ByteArrayOutputStream();
         try {
-            transportInfo.store(bout, "");
+            memberInfo.store(bout, "");
         } catch (IOException e) {
             String msg = "Cannot store member transport properties in the ByteArrayOutputStream";
             log.error(msg, e);

Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesMembershipListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesMembershipListener.java?rev=702441&r1=702440&r2=702441&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesMembershipListener.java
(original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesMembershipListener.java
Tue Oct  7 04:47:31 2008
@@ -39,14 +39,18 @@
     public void memberAdded(Member member) {
         if (membershipManager.memberAdded(member)) {
             log.info("New member " + TribesUtil.getName(member) + " joined cluster.");
+            if (TribesUtil.toAxis2Member(member).isActive()) {
+            } else {
+            }
         }
         //        System.err.println("++++++ IS COORD="+TribesClusterManager.nbc.isCoordinator());
     }
 
     public void memberDisappeared(Member member) {
         log.info("Member " + TribesUtil.getName(member) + " left cluster");
-        membershipManager.memberDisappeared(member);
-
+        if (TribesUtil.toAxis2Member(member).isActive()) {
+        } else {
+        }
 //        System.err.println("++++++ IS COORD="+TribesClusterManager.nbc.isCoordinator());
     }
 }

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=702441&r1=702440&r2=702441&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
Tue Oct  7 04:47:31 2008
@@ -24,6 +24,11 @@
 import org.apache.catalina.tribes.util.Arrays;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.axis2.clustering.ClusteringConstants;
+
+import java.util.Properties;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
 
 public class TribesUtil {
 
@@ -45,7 +50,7 @@
     }
 
     public static String getName(Member member) {
-        return getHost(member) + ":" + member.getPort() + "(" + new String(member.getDomain())+
")";
+        return getHost(member) + ":" + member.getPort() + "(" + new String(member.getDomain())
+ ")";
     }
 
     public static String getHost(Member member) {
@@ -68,18 +73,53 @@
     }
 
     public static byte[] getRpcMembershipChannelId(byte[] domain) {
-       return (new String(domain) + ":" + TribesConstants.RPC_MEMBERSHIP_CHANNEL).getBytes();
+        return (new String(domain) + ":" + TribesConstants.RPC_MEMBERSHIP_CHANNEL).getBytes();
     }
 
     public static byte[] getRpcInitChannelId(byte[] domain) {
         return (new String(domain) + ":" + TribesConstants.RPC_INIT_CHANNEL).getBytes();
     }
 
-    public static boolean isInDomain(Member member, byte[] domain){
+    public static boolean isInDomain(Member member, byte[] domain) {
         return Arrays.equals(domain, member.getDomain());
     }
 
-    public static boolean areInSameDomain(Member member1, Member member2){
+    public static boolean areInSameDomain(Member member1, Member member2) {
         return Arrays.equals(member1.getDomain(), member2.getDomain());
     }
+
+    public static org.apache.axis2.clustering.Member toAxis2Member(Member member) {
+        org.apache.axis2.clustering.Member axis2Member =
+                new org.apache.axis2.clustering.Member(TribesUtil.getHost(member),
+                                                       member.getPort());
+        Properties props = getProperties(member.getPayload());
+
+        String http = props.getProperty("HTTP");
+        if (http != null && http.trim().length() != 0) {
+            axis2Member.setHttpPort(Integer.parseInt(http));
+        }
+
+        String https = props.getProperty("HTTPS");
+        if (https != null && https.trim().length() != 0) {
+            axis2Member.setHttpsPort(Integer.parseInt(https));
+        }
+
+        String isActive = props.getProperty(ClusteringConstants.Parameters.IS_ACTIVE);
+        if (isActive != null && isActive.trim().length() != 0) {
+            axis2Member.setActive(Boolean.valueOf(isActive));
+        }
+        return axis2Member;
+    }
+
+    private static Properties getProperties(byte[] payload) {
+        Properties props = null;
+        try {
+            ByteArrayInputStream bin = new ByteArrayInputStream(payload);
+            props = new Properties();
+            props.load(bin);
+        } catch (IOException ignored) {
+            // This error will never occur
+        }
+        return props;
+    }
 }

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=702441&r1=702440&r2=702441&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml (original)
+++ webservices/axis2/trunk/java/modules/kernel/conf/axis2.xml Tue Oct  7 04:47:31 2008
@@ -266,6 +266,12 @@
         <parameter name="AvoidInitiation">true</parameter>
 
         <!--
+           Indicates whether this member is active or not. This will be useful in a setup
where
+           members are deployed in ACTIVE and/or PASSIVE configuration 
+        -->
+        <parameter name="isActive">true</parameter>
+
+        <!--
            The membership scheme used in this setup. The only values supported at the moment
are
            "multicast" and "wka"
 

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=702441&r1=702440&r2=702441&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 Oct  7 04:47:31 2008
@@ -98,6 +98,11 @@
          * the cluster.
          */
         public static final String AVOID_INITIATION = "AvoidInitiation";
+
+        /**
+         * Indicates whether this member is ACTIVE or PASSIVE
+         */
+        public static final String IS_ACTIVE = "isActive";
     }
 
     public static final class MembershipScheme {

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/Member.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/Member.java?rev=702441&r1=702440&r2=702441&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/Member.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/Member.java
Tue Oct  7 04:47:31 2008
@@ -40,6 +40,11 @@
      */
     private int httpsPort = -1;
 
+    /**
+     * Indicates whether this member is ACTIVE or PASSIVE
+     */
+    private boolean isActive = true;
+
     public Member(String hostName, int port) {
         this.hostName = hostName;
         this.port = port;
@@ -69,6 +74,14 @@
         this.httpPort = httpPort;
     }
 
+    public boolean isActive() {
+        return isActive;
+    }
+
+    public void setActive(boolean active) {
+        isActive = active;
+    }
+
     public boolean equals(Object o) {
         if (this == o) {
             return true;
@@ -94,6 +107,6 @@
 
     public String toString() {
         return "Host:" + hostName + ", Port: " + port +
-               ", HTTP:" + httpPort + ", HTTPS:" + httpsPort;
+               ", HTTP:" + httpPort + ", HTTPS:" + httpsPort +", ACTIVE:" + isActive;
     }
 }



Mime
View raw message