Author: fhanik
Date: Fri Mar  9 15:38:29 2007
New Revision: 516602

URL: http://svn.apache.org/viewvc?view=rev&rev=516602
Log:
added fairness counter, using this counter, I will be able to make sure that 
connections are treated evenly in my next revision of the NioEndpoint. No point 
in having 20k connections if only half get love.



Modified:
    tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java

Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java?view=diff&rev=516602&r1=516601&r2=516602
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Fri 
Mar  9 15:38:29 2007
@@ -1095,6 +1095,8 @@
             } else {
                 final SelectionKey key = 
socket.getIOChannel().keyFor(socket.getPoller().getSelector());
                 final KeyAttachment att = (KeyAttachment) key.attachment();
+                //we are registering the key to start with, reset the fairness 
counter.
+                att.setFairness(0);
                 try {
                     if (key != null) {
                         key.interestOps(interestOps);
@@ -1304,6 +1306,8 @@
                                         if (!processSocket(channel, 
SocketStatus.OPEN))
                                             processSocket(channel, 
SocketStatus.DISCONNECT);
                                     } else {
+                                        //increase the fairness counter
+                                        attachment.incFairness();
                                         //reregister it
                                         attachment.interestOps(interestOps);
                                         sk.interestOps(interestOps);
@@ -1319,6 +1323,8 @@
                                             
channel.getIOChannel().socket().close();
                                         }
                                     } else {
+                                        //increase the fairness counter
+                                        attachment.incFairness();
                                         //reregister it
                                         attachment.interestOps(interestOps);
                                         sk.interestOps(interestOps);
@@ -1393,6 +1399,7 @@
             comet = false;
             timeout = -1;
             error = false;
+            fairness = 0;
         }
         
         public void reset() {
@@ -1425,6 +1432,9 @@
             if ( latch == null || latch.getCount() == 0 ) this.latch = new 
CountDownLatch(cnt); 
             else throw new IllegalStateException("Latch must be at count 0 or 
null.");
         }
+        public int getFairness() { return fairness; }
+        public void setFairness(int f) { fairness = f;}
+        public void incFairness() { fairness++; }
         protected Object mutex = new Object();
         protected long lastAccess = -1;
         protected boolean currentAccess = false;
@@ -1433,7 +1443,7 @@
         protected boolean error = false;
         protected NioChannel channel = null;
         protected CountDownLatch latch = null;
-
+        protected int fairness = 0;
     }
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to