axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From az...@apache.org
Subject svn commit: r547602 - /webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/
Date Fri, 15 Jun 2007 10:27:38 GMT
Author: azeez
Date: Fri Jun 15 03:27:36 2007
New Revision: 547602

URL: http://svn.apache.org/viewvc?view=rev&rev=547602
Log:
Removing calls to Member.getName since this is a costly operation. Calculating the host id
in a different way.


Modified:
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/AckManager.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ChannelListener.java
    webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ChannelSender.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/TribesControlCommandProcessor.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

Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/AckManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/AckManager.java?view=diff&rev=547602&r1=547601&r2=547602
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/AckManager.java
(original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/AckManager.java
Fri Jun 15 03:27:36 2007
@@ -50,6 +50,7 @@
 
     public static boolean isMessageAcknowledged(String messageUniqueId,
                                                 ChannelSender sender) throws ClusteringFault
{
+
         boolean isAcknowledged = false;
         MessageACK ack = (MessageACK) messageAckTable.get(messageUniqueId);
         List memberList = ack.getMemberList();
@@ -62,8 +63,9 @@
         } else {
             for (int i = 0; i < members.length; i++) {
                 Member member = members[i];
-                if (member.isReady() && !memberList.contains(member.getName())) {
-                    log.debug("[NO ACK] from member " + member.getName());
+                String memberHost = TribesUtil.getHost(member);
+                if (member.isReady() && !memberList.contains(memberHost)) {
+                    log.debug("[NO ACK] from member " + memberHost);
                     log.debug("ACKed member list=" + memberList);
 
                     // At this point, resend the original message back to the node which
has not

Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ChannelListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ChannelListener.java?view=diff&rev=547602&r1=547601&r2=547602
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ChannelListener.java
(original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ChannelListener.java
Fri Jun 15 03:27:36 2007
@@ -94,7 +94,7 @@
             && !(msg instanceof GetStateResponseCommand)) {
             return;
         }
-        log.debug("RECEIVED MESSAGE " + msg + " from " + sender.getName());
+        log.debug("RECEIVED MESSAGE " + msg + " from " + TribesUtil.getHost(sender));
 
         // Need to process ACKs as soon as they are received since otherwise,
         // unnecessary retransmissions will take place

Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ChannelSender.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ChannelSender.java?view=diff&rev=547602&r1=547601&r2=547602
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ChannelSender.java
(original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/ChannelSender.java
Fri Jun 15 03:27:36 2007
@@ -92,10 +92,10 @@
         try {
             if (member.isReady()) {
                 channel.send(new Member[]{member}, cmd, 0);
-                log.debug("Sent " + cmd + " to " + member.getName());
+                log.debug("Sent " + cmd + " to " + TribesUtil.getHost(member));
             }
         } catch (ChannelException e) {
-            String message = "Could not send message to " + member.getName() +
+            String message = "Could not send message to " + TribesUtil.getHost(member) +
                              ". Reason " + e.getMessage();
             log.warn(message);
         }

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?view=diff&rev=547602&r1=547601&r2=547602
==============================================================================
--- 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 Jun 15 03:27:36 2007
@@ -131,7 +131,7 @@
                 channelListener.setContextManager(contextManager);
 
                 Member[] members = channel.getMembers();
-                log.info("Local Tribes Member " + channel.getLocalMember(true).getName());
+                log.info("Local Tribes Member " + TribesUtil.getLocalHost(channel));
                 TribesUtil.printMembers(members);
 
                 // If there is at least one member in the Tribe, get the current state from
a member
@@ -151,9 +151,9 @@
                         members = channel.getMembers();
                         int memberIndex = random.nextInt(members.length);
                         Member member = members[memberIndex];
-                        if (!sentMembersList.contains(member.getName())) {
+                        if (!sentMembersList.contains(TribesUtil.getHost(member))) {
                             sender.sendToMember(new GetStateCommand(), member);
-                            sentMembersList.add(member.getName());
+                            sentMembersList.add(TribesUtil.getHost(member));
                             log.debug("WAITING FOR STATE UPDATE...");
                             Thread.sleep(1000);
                         }

Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesControlCommandProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesControlCommandProcessor.java?view=diff&rev=547602&r1=547601&r2=547602
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesControlCommandProcessor.java
(original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/tribes/TribesControlCommandProcessor.java
Fri Jun 15 03:27:36 2007
@@ -61,7 +61,7 @@
             channelSender.sendToMember(getStateRespCmd, sender);
         } else if (command instanceof AckCommand) {
             AckCommand cmd = (AckCommand) command;
-            cmd.setMemberId(sender.getName());
+            cmd.setMemberId(TribesUtil.getHost(sender));
             cmd.execute(configurationContext);
         } else {
             command.execute(configurationContext);

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?view=diff&rev=547602&r1=547601&r2=547602
==============================================================================
--- 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
Fri Jun 15 03:27:36 2007
@@ -28,12 +28,12 @@
     private static Log log = LogFactory.getLog(TribesMembershipListener.class);
 
     public void memberAdded(Member member) {
-        log.info("New member " + member.getName() + " joined cluster.");
+        log.info("New member " + TribesUtil.getHost(member) + " joined cluster.");
        //        System.err.println("++++++ IS COORD="+TribesClusterManager.nbc.isCoordinator());
     }
 
     public void memberDisappeared(Member member) {
-        log.info("Member " + member.getName() + " left cluster");
+        log.info("Member " + TribesUtil.getHost(member) + " left cluster");
 //        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?view=diff&rev=547602&r1=547601&r2=547602
==============================================================================
--- 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 Jun 15 03:27:36 2007
@@ -16,6 +16,7 @@
 
 package org.apache.axis2.clustering.tribes;
 
+import org.apache.catalina.tribes.Channel;
 import org.apache.catalina.tribes.Member;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -25,21 +26,12 @@
     private static Log log = LogFactory.getLog(TribesUtil.class);
 
     public static void printMembers(Member[] members) {
-
-
         if (members != null) {
             int length = members.length;
             if (length > 0) {
                 log.info("Members of current cluster");
                 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]);
-                        }
-                    }
-                    log.info("Member" + (i + 1) + " " + members[i].getName());
+                    log.info("Member" + (i + 1) + " " + getHost(members[i]));
                 }
             } else {
                 log.info("No members in current cluster");
@@ -47,4 +39,19 @@
         }
     }
 
+    public static String getHost(Member member) {
+        byte[] hostBytes = member.getHost();
+        StringBuffer host = new StringBuffer();
+        if (hostBytes != null) {
+            for (int i = 0; i < hostBytes.length; i++) {
+                int hostByte = hostBytes[i] >= 0 ? (int) hostBytes[i] : (int) hostBytes[i]
+ 256;
+                host.append(hostByte).append(".");
+            }
+        }
+        return host.append(":").append(member.getPort()).toString();
+    }
+
+    public static String getLocalHost(Channel channel) {
+        return getHost(channel.getLocalMember(true));
+    }
 }



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


Mime
View raw message