axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From az...@apache.org
Subject svn commit: r657365 - in /webservices/axis2/trunk/java/modules: clustering/src/org/apache/axis2/clustering/tribes/TribesClusterManager.java kernel/src/org/apache/axis2/clustering/ClusteringConstants.java
Date Sat, 17 May 2008 14:35:34 GMT
Author: azeez
Date: Sat May 17 07:35:34 2008
New Revision: 657365

URL: http://svn.apache.org/viewvc?rev=657365&view=rev
Log:
Introducing constants


Modified:
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesClusterManager.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/clustering/ClusteringConstants.java

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=657365&r1=657364&r2=657365&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
Sat May 17 07:35:34 2008
@@ -128,12 +128,7 @@
 
         setMaximumRetries();
         byte[] domain = getClusterDomain();
-
-        Parameter membershipSchemeParam = getParameter("membershipScheme");
-        String membershipScheme = ClusteringConstants.MembershipScheme.MULTICAST_BASED;
-        if (membershipSchemeParam != null) {
-            membershipScheme = ((String) membershipSchemeParam.getValue()).trim();
-        }
+        String membershipScheme = getMembershipScheme();
 
         // Add all the ChannelInterceptors
         addInterceptors(channel, domain, membershipScheme);
@@ -156,7 +151,7 @@
                                           ". Please set an IP address other than " +
                                           localHost + " in your /etc/hosts file or set the
" +
                                           ClusteringConstants.LOCAL_IP_ADDRESS +
-                                          " System property and retry.");
+                                          " System property and retry."); //TODO: setting
the value in the axis2.xml file
             }
         } catch (ChannelException e) {
             String msg = "Error starting Tribes channel";
@@ -194,7 +189,21 @@
     }
 
     /**
+     * Get the membership scheme applicable to this cluster
+     * @return The membership scheme. Only "wka" & "multicast" are valid return values.
+     */
+    private String getMembershipScheme() {
+        Parameter membershipSchemeParam = getParameter("membershipScheme");
+        String membershipScheme = ClusteringConstants.MembershipScheme.MULTICAST_BASED;
+        if (membershipSchemeParam != null) {
+            membershipScheme = ((String) membershipSchemeParam.getValue()).trim();
+        }
+        return membershipScheme;
+    }
+
+    /**
      * Get the clustering domain to which this node belongs to
+     *
      * @return The clustering domain to which this node belongs to
      */
     private byte[] getClusterDomain() {
@@ -203,7 +212,7 @@
         if (domainParam != null) {
             domain = ((String) domainParam.getValue()).getBytes();
         } else {
-            domain = "apache.axis2.domain".getBytes();
+            domain = ClusteringConstants.DEFAULT_DOMAIN.getBytes();
         }
         return domain;
     }
@@ -310,41 +319,35 @@
             for (org.apache.axis2.clustering.Member member : members) {
                 StaticMember tribesMember;
                 try {
-                    tribesMember = new StaticMember(member.getHostName(),
-                                                    member.getPort(),
-                                                    0,
-                                                    payload);
+                    tribesMember = new StaticMember(member.getHostName(), member.getPort(),
+                                                    0, payload);
                 } catch (IOException e) {
                     String msg = "Could not add static member " +
                                  member.getHostName() + ":" + member.getPort();
                     log.error(msg, e);
                     throw new ClusteringFault(msg, e);
                 }
+                
                 // Do not add the local member to the list of members
                 if (!(Arrays.equals(localMember.getHost(), tribesMember.getHost()) &&
                       localMember.getPort() == tribesMember.getPort())) {
                     tribesMember.setDomain(domain);
-                    staticMembershipInterceptor.addStaticMember(tribesMember);
-                    try {
 
-                        // Before adding a static member, we will try to verify whether
-                        // we can connect to it
-                        InetAddress addr = InetAddress.getByName(member.getHostName());
-                        SocketAddress sockaddr = new InetSocketAddress(addr,
-                                                                       member.getPort());
-                        new Socket().connect(sockaddr, 3000);
+                    // We will add the member even if it is offline at this moment. When
the
+                    // member comes online, it will be detected by the GMS
+                    staticMembershipInterceptor.addStaticMember(tribesMember);
+                    if (canConnect(member)) {
                         membershipManager.memberAdded(tribesMember);
                         log.info("Added static member " + TribesUtil.getHost(tribesMember));
-                    } catch (Exception e) {
-                        log.info("Could not connect to member " +
-                                 TribesUtil.getHost(tribesMember));
+                    } else {
+                        log.info("Could not connect to member " + TribesUtil.getHost(tribesMember));
                     }
                 }
             }
         } else if (membershipScheme.equals(ClusteringConstants.MembershipScheme.MULTICAST_BASED))
{
             log.info("Using multicast based membership management scheme");
             configureMulticastParameters(channel, domain);
-        } else {                                        
+        } else {
             String msg = "Invalid membership scheme '" + membershipScheme +
                          "'. Supported schemes are multicast & wka";
             log.error(msg);
@@ -353,6 +356,29 @@
     }
 
     /**
+     * Before adding a static member, we will try to verify whether we can connect to it
+     *
+     * @param member The member whose connectvity needs to be verified
+     * @return true, if the member can be contacted; false, otherwise.
+     */
+    private boolean canConnect(org.apache.axis2.clustering.Member member) {
+        boolean canConnect = false;
+        try {
+            InetAddress addr = InetAddress.getByName(member.getHostName());
+            SocketAddress sockaddr = new InetSocketAddress(addr,
+                                                           member.getPort());
+            new Socket().connect(sockaddr, 3000);
+            canConnect = true;
+        } catch (IOException ignored) {
+            // A debug level log is sufficient here since we are only trying to verify whether
+            // the member in concern is online or offline
+//            log.debug("Cannot connect to member " +
+//                      member.getHostName() + ":" + member.getPort(), e);
+        }
+        return canConnect;
+    }
+
+    /**
      * Add ChannelInterceptors. The order of the interceptors that are added will depend
on the
      * membership management scheme
      *
@@ -412,7 +438,7 @@
      * parameters
      *
      * @param channel The Tribes channel
-     * @param domain The clustering domain to which this node belongs to
+     * @param domain  The clustering domain to which this node belongs to
      */
     private void configureMulticastParameters(ManagedChannel channel,
                                               byte[] domain) {

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=657365&r1=657364&r2=657365&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
Sat May 17 07:35:34 2008
@@ -36,6 +36,11 @@
      */
     public static final String DOMAIN = "domain";
 
+    /**
+     * The default domain to which this node belongs to
+     */
+    public static final String DEFAULT_DOMAIN = "apache.axis2.domain";
+
     public static final String NODE_MANAGER_SERVICE = "Axis2NodeManager";
     public static final String REQUEST_BLOCKING_HANDLER = "RequestBlockingHandler";
     public static final String CLUSTER_INITIALIZED = "local_cluster.initialized";
@@ -49,6 +54,13 @@
      */
     public static final String SYNCHRONIZE_ALL_MEMBERS = "synchronizeAll";
 
+    /**
+     * The main cluster configuration parameters
+     */
+    public static final class Parameters {
+
+    }
+
     public static final class MembershipScheme {
         /**
          * Multicast based membership discovery scheme



Mime
View raw message