activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r898774 - in /activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport: nio/SelectorManager.java nio/SelectorSelection.java nio/SelectorWorker.java stomp/StompNIOTransport.java
Date Wed, 13 Jan 2010 14:38:53 GMT
Author: dejanb
Date: Wed Jan 13 14:38:52 2010
New Revision: 898774

URL: http://svn.apache.org/viewvc?rev=898774&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQ-2440 - more stomp+nip (and just nio) transport
improvements

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/nio/SelectorManager.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/nio/SelectorSelection.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/nio/SelectorWorker.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompNIOTransport.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/nio/SelectorManager.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/nio/SelectorManager.java?rev=898774&r1=898773&r2=898774&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/nio/SelectorManager.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/nio/SelectorManager.java
Wed Jan 13 14:38:52 2010
@@ -79,11 +79,6 @@
 
     public synchronized void onWorkerEmptyEvent(SelectorWorker worker) {
         freeWorkers.remove(worker);
-        try {
-            // no more connections on worker, close it
-            worker.close();
-        } catch (IOException e) {
-        }
     }
 
     public synchronized void onWorkerNotFullEvent(SelectorWorker worker) {

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/nio/SelectorSelection.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/nio/SelectorSelection.java?rev=898774&r1=898773&r2=898774&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/nio/SelectorSelection.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/nio/SelectorSelection.java
Wed Jan 13 14:38:52 2010
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.transport.nio;
 
+import java.io.IOException;
 import java.nio.channels.ClosedChannelException;
 import java.nio.channels.SelectionKey;
 import java.nio.channels.SocketChannel;
@@ -64,11 +65,15 @@
 
     public void close() {
         worker.decrementUseCounter();
-    	
+        
         // Lock when mutating state of the selector
         worker.lock();
         try {
             key.cancel();
+            if (!worker.isRunning()) {
+                worker.close();
+            }
+        } catch (IOException e) {
         } finally {
             worker.unlock();
         }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/nio/SelectorWorker.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/nio/SelectorWorker.java?rev=898774&r1=898773&r2=898774&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/nio/SelectorWorker.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/nio/SelectorWorker.java
Wed Jan 13 14:38:52 2010
@@ -17,11 +17,11 @@
 package org.apache.activemq.transport.nio;
 
 import java.io.IOException;
+import java.nio.channels.ClosedSelectorException;
 import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
 import java.util.Iterator;
 import java.util.Set;
-
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -72,7 +72,8 @@
             Thread.currentThread().setName("Selector Worker: " + id);
             while (isRunning()) {
                 
-                lockBarrier();       	
+                lockBarrier();
+                
                 int count = selector.select(10);
                 if (count == 0) {
                     continue;
@@ -115,8 +116,10 @@
                 }
 
             }
+        } catch (ClosedSelectorException cse) {
+            // Don't accept any more selections
+            manager.onWorkerEmptyEvent(this);
         } catch (IOException e) {
-
             // Don't accept any more selections
             manager.onWorkerEmptyEvent(this);
 

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompNIOTransport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompNIOTransport.java?rev=898774&r1=898773&r2=898774&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompNIOTransport.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/stomp/StompNIOTransport.java
Wed Jan 13 14:38:52 2010
@@ -17,7 +17,6 @@
 package org.apache.activemq.transport.stomp;
 
 import java.io.ByteArrayInputStream;
-import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.EOFException;
 import java.io.IOException;
@@ -32,7 +31,6 @@
 
 import org.apache.activemq.command.Command;
 import org.apache.activemq.transport.Transport;
-import org.apache.activemq.transport.nio.NIOInputStream;
 import org.apache.activemq.transport.nio.NIOOutputStream;
 import org.apache.activemq.transport.nio.SelectorManager;
 import org.apache.activemq.transport.nio.SelectorSelection;
@@ -131,8 +129,7 @@
                
            }
         } catch (IOException e) {
-            selection.close();
-            onException(e);
+            onException(e);  
         } catch (Throwable e) {
             onException(IOExceptionSupport.create(e));
         }
@@ -145,7 +142,10 @@
     }
 
     protected void doStop(ServiceStopper stopper) throws Exception {
-        selection.disable();
+        try {
+            selection.close();
+        } catch (Exception e) {
+        }
         super.doStop(stopper);
     }
 }



Mime
View raw message