r26767 - trunk/freenet/src/freenet/node

[email protected]
Newsgroups gmane.network.freenet.cvs
Message-ID <[email protected]>
Author: j16sdiz
Date: 2009-04-14 04:42:30 +0000 (Tue, 14 Apr 2009)
New Revision: 26767

Modified:
   trunk/freenet/src/freenet/node/ThrottleWindowManager.java
Log:
Logging for ThrottleWindowManager

Modified: trunk/freenet/src/freenet/node/ThrottleWindowManager.java
===================================================================
--- trunk/freenet/src/freenet/node/ThrottleWindowManager.java	2009-04-14 04:42:10 UTC (rev 26766)
+++ trunk/freenet/src/freenet/node/ThrottleWindowManager.java	2009-04-14 04:42:30 UTC (rev 26767)
@@ -3,10 +3,21 @@
  * http://www.gnu.org/ for further details of the GPL. */
 package freenet.node;
 
+import freenet.support.LogThresholdCallback;
 import freenet.support.Logger;
 import freenet.support.SimpleFieldSet;
 
 public class ThrottleWindowManager {
+	private static volatile boolean logMINOR;
+	
+	static {
+		Logger.registerLogThresholdCallback(new LogThresholdCallback() {
+			@Override
+			public void shouldUpdate() {
+				logMINOR = Logger.shouldLog(Logger.MINOR, this);
+			}
+		});
+	}
 
 	static final float PACKET_DROP_DECREASE_MULTIPLE = 0.97f;
 	static final float PACKET_TRANSMIT_INCREMENT = (4 * (1 - (PACKET_DROP_DECREASE_MULTIPLE * PACKET_DROP_DECREASE_MULTIPLE))) / 3;
@@ -38,14 +49,14 @@
 		_droppedPackets++;
 		_totalPackets++;
 		_simulatedWindowSize *= PACKET_DROP_DECREASE_MULTIPLE;
-        if(Logger.shouldLog(Logger.MINOR, this))
+        if(logMINOR)
         	Logger.minor(this, "request rejected overload: "+this);
 	}
 
 	public synchronized void requestCompleted() {
         _totalPackets++;
         _simulatedWindowSize += (PACKET_TRANSMIT_INCREMENT / _simulatedWindowSize);
-        if(Logger.shouldLog(Logger.MINOR, this))
+        if(logMINOR)
         	Logger.minor(this, "requestCompleted on "+this);
 	}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.