tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r377499 - in /tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp: ReplicationTransmitter.java SimpleTcpCluster.java
Date Mon, 13 Feb 2006 21:39:53 GMT
Author: fhanik
Date: Mon Feb 13 13:39:52 2006
New Revision: 377499

URL: http://svn.apache.org/viewcvs?rev=377499&view=rev
Log:
more code cleanup

Modified:
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java
    tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java?rev=377499&r1=377498&r2=377499&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java
(original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/ReplicationTransmitter.java
Mon Feb 13 13:39:52 2006
@@ -415,11 +415,9 @@
     
     /**
      * Send data to one member
-     * FIXME set filtering messages
      * @see org.apache.catalina.cluster.ClusterSender#sendMessage(org.apache.catalina.cluster.ClusterMessage,
org.apache.catalina.cluster.Member)
      */
-    public void sendMessage(ClusterMessage message, Member member)
-            throws java.io.IOException {       
+    public void sendMessage(ClusterMessage message, Member member) throws IOException { 
     
         long time = 0 ;
         if(doTransmitterProcessingStats) {
             time = System.currentTimeMillis();
@@ -440,47 +438,21 @@
      * Send to all senders at same cluster domain as message from address
      * @param message Cluster message to send
      * @since 5.5.10
-     * FIXME Refactor with sendMessage get a sender list from
      */
-    public void sendMessageClusterDomain(ClusterMessage message) 
-         throws java.io.IOException {
-        long time = 0;
-        if (doTransmitterProcessingStats) {
-            time = System.currentTimeMillis();
-        }
-        try {
-            String domain = message.getAddress().getDomain();
-            if(domain == null)
-                throw new RuntimeException("Domain at member not set");
-            ClusterData data = serialize(message);
-            IDataSender[] senders = getSenders();
-            for (int i = 0; i < senders.length; i++) {
-
-                IDataSender sender = senders[i];
-                if(domain.equals(sender.getDomain())) {
-                    try {
-                        boolean success = sendMessageData(data, sender);
-                    } catch (Exception x) {
-                        //THIS WILL NEVER HAPPEN, as sendMessageData swallows the error
-                    }
-                }
-            }
-        } finally {
-            // FIXME better exception handling
-            if (doTransmitterProcessingStats) {
-                addProcessingStats(time);
-            }
-        }
+    public void sendMessageClusterDomain(ClusterMessage message) throws IOException {
+        sendMessage(message,true);
     
     }
 
+    public void sendMessage(ClusterMessage message) throws IOException {
+        sendMessage(message,false);
+    }
+
     /**
      * send message to all senders (broadcast)
      * @see org.apache.catalina.cluster.ClusterSender#sendMessage(org.apache.catalina.cluster.ClusterMessage)
-     * FIXME Refactor with sendMessageClusterDomain!
      */
-    public void sendMessage(ClusterMessage message)
-            throws java.io.IOException {
+    public void sendMessage(ClusterMessage message, boolean domainOnly) throws IOException
{
         long time = 0;
         if (doTransmitterProcessingStats) {
             time = System.currentTimeMillis();
@@ -491,19 +463,19 @@
             for (int i = 0; i < senders.length; i++) {
 
                 IDataSender sender = senders[i];
-                try {
-                    sendMessageData(data, sender);
-                } catch (Exception x) {
-                    // FIXME remember exception and send it at finally
-                }
+                //domain filter
+                String domain = message.getAddress().getDomain();
+                if ( domainOnly && !(domain.equals(sender.getDomain())) ) continue;
+                sendMessageData(data, sender);
             }
         } finally {
-            // FIXME better exception handling
             if (doTransmitterProcessingStats) {
                 addProcessingStats(time);
             }
         }
     }
+        
+    
 
     /**
      * start the sender and register transmitter mbean
@@ -828,9 +800,9 @@
      * @throws java.io.IOException If an error occurs
      */
     protected boolean sendMessageData(ClusterData data,
-                                   IDataSender sender) throws java.io.IOException {
+                                      IDataSender sender) {
         if (sender == null)
-            throw new java.io.IOException("Sender not available. Make sure sender information
is available to the ReplicationTransmitter.");
+            throw new RuntimeException("Sender not available. Make sure sender information
is available to the ReplicationTransmitter.");
         try {
             // deprecated not needed DataSender#pushMessage can handle connection
             if (autoConnect) {

Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java?rev=377499&r1=377498&r2=377499&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java
(original)
+++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/tcp/SimpleTcpCluster.java
Mon Feb 13 13:39:52 2006
@@ -1005,29 +1005,7 @@
         clusterLog = null ;
    }
 
-    /**
-     * send message to all cluster members same cluster domain
-     * 
-     * @see org.apache.catalina.cluster.CatalinaCluster#send(org.apache.catalina.cluster.ClusterMessage)
-     */
-    public void sendClusterDomain(ClusterMessage msg) {
-        long start = 0;
-        if (doClusterLog)
-            start = System.currentTimeMillis();
-        try {
-            msg.setAddress(membershipService.getLocalMember());
-            clusterSender.sendMessageClusterDomain(msg);
-        } catch (Exception x) {
-            if (notifyLifecycleListenerOnFailure) {
-                // Notify our interested LifecycleListeners
-                lifecycle.fireLifecycleEvent(SEND_MESSAGE_FAILURE_EVENT,
-                        new SendMessageData(msg, null, x));
-            }
-            log.error("Unable to send message through cluster sender.", x);
-        }
-        if (doClusterLog)
-            logSendMessage(msg, start, null);
-    } 
+    
 
 
     /**
@@ -1057,6 +1035,31 @@
             log.error("sendToMember: member " + dest + " not found!");
         }        
     }
+    
+    /**
+     * send message to all cluster members same cluster domain
+     * 
+     * @see org.apache.catalina.cluster.CatalinaCluster#send(org.apache.catalina.cluster.ClusterMessage)
+     */
+    public void sendClusterDomain(ClusterMessage msg) {
+        long start = 0;
+        if (doClusterLog)
+            start = System.currentTimeMillis();
+        try {
+            msg.setAddress(membershipService.getLocalMember());
+            clusterSender.sendMessageClusterDomain(msg);
+        } catch (Exception x) {
+            if (notifyLifecycleListenerOnFailure) {
+                // Notify our interested LifecycleListeners
+                lifecycle.fireLifecycleEvent(SEND_MESSAGE_FAILURE_EVENT,
+                        new SendMessageData(msg, null, x));
+            }
+            log.error("Unable to send message through cluster sender.", x);
+        }
+        if (doClusterLog)
+            logSendMessage(msg, start, null);
+    } 
+
     
     /**
      * send a cluster message to one member



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message