tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r609778 - in /tomcat/trunk/java/org/apache/catalina/tribes: group/interceptors/ThroughputInterceptor.java transport/nio/NioReceiver.java
Date Mon, 07 Jan 2008 21:11:27 GMT
Author: fhanik
Date: Mon Jan  7 13:11:26 2008
New Revision: 609778

URL: http://svn.apache.org/viewvc?rev=609778&view=rev
Log:
minor fixes

Modified:
    tomcat/trunk/java/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptor.java
    tomcat/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java

Modified: tomcat/trunk/java/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptor.java?rev=609778&r1=609777&r2=609778&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptor.java
(original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/group/interceptors/ThroughputInterceptor.java
Mon Jan  7 13:11:26 2008
@@ -16,6 +16,10 @@
 
 package org.apache.catalina.tribes.group.interceptors;
 
+import java.text.DecimalFormat;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+
 import org.apache.catalina.tribes.ChannelException;
 import org.apache.catalina.tribes.ChannelMessage;
 import org.apache.catalina.tribes.Member;
@@ -23,10 +27,6 @@
 import org.apache.catalina.tribes.group.InterceptorPayload;
 import org.apache.catalina.tribes.io.ChannelData;
 import org.apache.catalina.tribes.io.XByteBuffer;
-import java.text.DecimalFormat;
-import org.apache.catalina.tribes.membership.MemberImpl;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
 
 
 
@@ -61,7 +61,7 @@
             super.sendMessage(destination, msg, payload);
         }catch ( ChannelException x ) {
             msgTxErr.addAndGet(1);
-            access.addAndGet(-1);
+            if ( access.get() == 1 ) access.addAndGet(-1);
             throw x;
         } 
         mbTx += ((double)(bytes*destination.length))/(1024d*1024d);
@@ -115,6 +115,46 @@
 
     public int getInterval() {
         return interval;
+    }
+
+    public double getLastCnt() {
+        return lastCnt;
+    }
+
+    public double getMbAppTx() {
+        return mbAppTx;
+    }
+
+    public double getMbRx() {
+        return mbRx;
+    }
+
+    public double getMbTx() {
+        return mbTx;
+    }
+
+    public AtomicLong getMsgRxCnt() {
+        return msgRxCnt;
+    }
+
+    public AtomicLong getMsgTxCnt() {
+        return msgTxCnt;
+    }
+
+    public AtomicLong getMsgTxErr() {
+        return msgTxErr;
+    }
+
+    public long getRxStart() {
+        return rxStart;
+    }
+
+    public double getTimeTx() {
+        return timeTx;
+    }
+
+    public long getTxStart() {
+        return txStart;
     }
 
 }

Modified: tomcat/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java?rev=609778&r1=609777&r2=609778&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java (original)
+++ tomcat/trunk/java/org/apache/catalina/tribes/transport/nio/NioReceiver.java Mon Jan  7
13:11:26 2008
@@ -37,6 +37,7 @@
 import java.util.LinkedList;
 import java.util.Set;
 import java.nio.channels.CancelledKeyException;
+import java.nio.channels.ClosedSelectorException;
 
 /**
  * @author Filip Hanik
@@ -303,8 +304,7 @@
 
         }
         serverChannel.close();
-        if (selector != null)
-            selector.close();
+        closeSelector();
     }
 
     
@@ -319,13 +319,34 @@
         if (selector != null) {
             try {
                 selector.wakeup();
-                selector.close();
+                closeSelector();
             } catch (Exception x) {
                 log.error("Unable to close cluster receiver selector.", x);
             } finally {
                 selector = null;
             }
         }
+    }
+
+    private void closeSelector() throws IOException {
+        Selector selector = this.selector;
+        this.selector = null;
+        if (selector==null) return;
+        try {
+            Iterator it = selector.keys().iterator();
+            // look at each key in the selected set
+            while (it.hasNext()) {
+                SelectionKey key = (SelectionKey)it.next();
+                key.channel().close();
+                key.attach(null);
+                key.cancel();
+            }
+        }catch ( IOException ignore ){
+            if (log.isWarnEnabled()) {
+                log.warn("Unable to cleanup on selector close.",ignore);
+            }
+        }catch ( ClosedSelectorException ignore){}
+        selector.close();
     }
 
     // ----------------------------------------------------------



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


Mime
View raw message