tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1132383 - in /tomcat/trunk/java/org/apache/coyote/http11: Http11AprProtocol.java Http11NioProtocol.java Http11Protocol.java
Date Sun, 05 Jun 2011 12:33:29 GMT
Author: markt
Date: Sun Jun  5 12:33:29 2011
New Revision: 1132383

URL: http://svn.apache.org/viewvc?rev=1132383&view=rev
Log:
Align some of the code between the connection handlers.

Modified:
    tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java
    tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java?rev=1132383&r1=1132382&r2=1132383&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11AprProtocol.java Sun Jun  5 12:33:29
2011
@@ -205,7 +205,7 @@ public class Http11AprProtocol extends A
             protected AtomicInteger size = new AtomicInteger(0);
             @Override
             public boolean offer(Http11AprProcessor processor) {
-                boolean offer = (proto.getProcessorCache() == -1) ? true : (size.get() <
proto.getProcessorCache());
+                boolean offer = proto.getProcessorCache() == -1 ? true : size.get() <
proto.getProcessorCache();
                 //avoid over growing our cache or add after we have stopped
                 boolean result = false;
                 if ( offer ) {

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java?rev=1132383&r1=1132382&r2=1132383&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11NioProtocol.java Sun Jun  5 12:33:29
2011
@@ -25,6 +25,7 @@ import java.util.Iterator;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentLinkedQueue;
 import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
 
 import javax.management.ObjectName;
 
@@ -160,18 +161,19 @@ public class Http11NioProtocol extends A
     protected static class Http11ConnectionHandler implements Handler {
 
         protected Http11NioProtocol proto;
-        protected static int count = 0;
+        protected AtomicLong registerCount = new AtomicLong(0);
         protected RequestGroupInfo global = new RequestGroupInfo();
 
         protected ConcurrentHashMap<NioChannel, Http11NioProcessor> connections =
             new ConcurrentHashMap<NioChannel, Http11NioProcessor>();
 
-        protected ConcurrentLinkedQueue<Http11NioProcessor> recycledProcessors = new
ConcurrentLinkedQueue<Http11NioProcessor>() {
+        protected ConcurrentLinkedQueue<Http11NioProcessor> recycledProcessors =
+                new ConcurrentLinkedQueue<Http11NioProcessor>() {
             private static final long serialVersionUID = 1L;
             protected AtomicInteger size = new AtomicInteger(0);
             @Override
             public boolean offer(Http11NioProcessor processor) {
-                boolean offer = proto.getProcessorCache()==-1?true:size.get() < proto.getProcessorCache();
+                boolean offer = proto.getProcessorCache() == -1 ? true : size.get() <
proto.getProcessorCache();
                 //avoid over growing our cache or add after we have stopped
                 boolean result = false;
                 if ( offer ) {
@@ -215,16 +217,16 @@ public class Http11NioProtocol extends A
         }
 
         @Override
-        public void recycle() {
-            recycledProcessors.clear();
-        }
-        
-        @Override
         public SSLImplementation getSslImplementation() {
             return proto.sslImplementation;
         }
 
         @Override
+        public void recycle() {
+            recycledProcessors.clear();
+        }
+        
+        @Override
         public void release(SocketChannel socket) {
             if (log.isDebugEnabled()) 
                 log.debug("Iterating through our connections to release a socket channel:"+socket);
@@ -434,18 +436,20 @@ public class Http11NioProtocol extends A
             register(processor);
             return processor;
         }
-        AtomicInteger registerCount = new AtomicInteger(0);
-        public void register(Http11NioProcessor processor) {
+
+        protected void register(Http11NioProcessor processor) {
             if (proto.getDomain() != null) {
                 synchronized (this) {
                     try {
-                        registerCount.addAndGet(1);
-                        if (log.isDebugEnabled()) log.debug("Register ["+processor+"] count="+registerCount.get());
+                        long count = registerCount.incrementAndGet();
                         final RequestInfo rp = processor.getRequest().getRequestProcessor();
                         rp.setGlobalProcessor(global);
                         final ObjectName rpName = new ObjectName
                             (proto.getDomain() + ":type=RequestProcessor,worker="
-                             + proto.getName() + ",name=HttpRequest" + count++);
+                             + proto.getName() + ",name=HttpRequest" + count);
+                        if (log.isDebugEnabled()) {
+                            log.debug("Register " + rpName);
+                        }
                         if (Constants.IS_SECURITY_ENABLED) {
                             AccessController.doPrivileged(new PrivilegedAction<Void>()
{
                                 @Override
@@ -469,15 +473,16 @@ public class Http11NioProtocol extends A
             }
         }
     
-        public void deregister(Http11NioProcessor processor) {
+        protected void deregister(Http11NioProcessor processor) {
             if (proto.getDomain() != null) {
                 synchronized (this) {
                     try {
-                        registerCount.addAndGet(-1);
-                        if (log.isDebugEnabled()) log.debug("Deregister ["+processor+"] count="+registerCount.get());
                         RequestInfo rp = processor.getRequest().getRequestProcessor();
                         rp.setGlobalProcessor(null);
                         ObjectName rpName = rp.getRpName();
+                        if (log.isDebugEnabled()) {
+                            log.debug("Unregister " + rpName);
+                        }
                         Registry.getRegistry(null, null).unregisterComponent(rpName);
                         rp.setRpName(null);
                     } catch (Exception e) {
@@ -486,8 +491,5 @@ public class Http11NioProtocol extends A
                 }
             }
         }
-
     }
-
-
 }

Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java?rev=1132383&r1=1132382&r2=1132383&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/Http11Protocol.java Sun Jun  5 12:33:29 2011
@@ -119,12 +119,12 @@ public class Http11Protocol extends Abst
             new ConcurrentHashMap<SocketWrapper<Socket>, Http11Processor>();
 
         protected ConcurrentLinkedQueue<Http11Processor> recycledProcessors = 
-            new ConcurrentLinkedQueue<Http11Processor>() {
+                new ConcurrentLinkedQueue<Http11Processor>() {
             private static final long serialVersionUID = 1L;
             protected AtomicInteger size = new AtomicInteger(0);
             @Override
             public boolean offer(Http11Processor processor) {
-                boolean offer = (proto.getProcessorCache() == -1) ? true : (size.get() <
proto.getProcessorCache());
+                boolean offer = proto.getProcessorCache() == -1 ? true : size.get() <
proto.getProcessorCache();
                 //avoid over growing our cache or add after we have stopped
                 boolean result = false;
                 if ( offer ) {
@@ -316,8 +316,5 @@ public class Http11Protocol extends Abst
                 }
             }
         }
-
     }
-
-
 }



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


Mime
View raw message