Author: j16sdiz
Date: 2009-04-07 15:06:39 +0000 (Tue, 07 Apr 2009)
New Revision: 26608

Modified:
   trunk/freenet/src/freenet/client/async/ClientRequester.java
Log:
Logging

Modified: trunk/freenet/src/freenet/client/async/ClientRequester.java
===================================================================
--- trunk/freenet/src/freenet/client/async/ClientRequester.java 2009-04-07 
15:06:16 UTC (rev 26607)
+++ trunk/freenet/src/freenet/client/async/ClientRequester.java 2009-04-07 
15:06:39 UTC (rev 26608)
@@ -8,6 +8,7 @@
 import freenet.keys.FreenetURI;
 import freenet.node.RequestClient;
 import freenet.node.SendableRequest;
+import freenet.support.LogThresholdCallback;
 import freenet.support.Logger;
 
 /** A high level client request. A request (either fetch or put) started
@@ -16,6 +17,16 @@
  * retried.
  */
 public abstract class ClientRequester {
+       private static volatile boolean logMINOR;
+       
+       static {
+               Logger.registerLogThresholdCallback(new LogThresholdCallback() {
+                       @Override
+                       public void shouldUpdate() {
+                               logMINOR = Logger.shouldLog(Logger.MINOR, this);
+                       }
+               });
+       }
 
        public abstract void onTransition(ClientGetState oldState, 
ClientGetState newState, ObjectContainer container);
        
@@ -81,7 +92,7 @@
                        if(blockSetFinalized) return;
                        blockSetFinalized = true;
                }
-               if(Logger.shouldLog(Logger.MINOR, this))
+               if(logMINOR)
                        Logger.minor(this, "Finalized set of blocks for "+this, 
new Exception("debug"));
                if(persistent())
                        container.store(this);
@@ -102,7 +113,7 @@
                                Logger.error(this, "addBlock() but set 
finalized! on " + this, new Exception("error"));
                }
                
-               if(Logger.shouldLog(Logger.MINOR, this)) Logger.minor(this, 
"addBlock(): total="+totalBlocks+" successful="+successfulBlocks+" 
failed="+failedBlocks+" required="+minSuccessBlocks);
+               if(logMINOR) Logger.minor(this, "addBlock(): 
total="+totalBlocks+" successful="+successfulBlocks+" failed="+failedBlocks+" 
required="+minSuccessBlocks);
                if(persistent()) container.store(this);
        }
 
@@ -120,12 +131,12 @@
                                Logger.error(this, "addBlocks() but set 
finalized! on "+this, new Exception("error"));
                }
                
-               if(Logger.shouldLog(Logger.MINOR, this)) Logger.minor(this, 
"addBlocks("+num+"): total="+totalBlocks+" successful="+successfulBlocks+" 
failed="+failedBlocks+" required="+minSuccessBlocks); 
+               if(logMINOR) Logger.minor(this, "addBlocks("+num+"): 
total="+totalBlocks+" successful="+successfulBlocks+" failed="+failedBlocks+" 
required="+minSuccessBlocks); 
                if(persistent()) container.store(this);
        }
 
        public void completedBlock(boolean dontNotify, ObjectContainer 
container, ClientContext context) {
-               if(Logger.shouldLog(Logger.MINOR, this))
+               if(logMINOR)
                        Logger.minor(this, "Completed block ("+dontNotify+ "): 
total="+totalBlocks+" success="+successfulBlocks+" failed="+failedBlocks+" 
fatally="+fatallyFailedBlocks+" finalised="+blockSetFinalized+" 
required="+minSuccessBlocks+" on "+this);
                synchronized(this) {
                        if(cancelled) return;
@@ -155,7 +166,7 @@
        public synchronized void addMustSucceedBlocks(int blocks, 
ObjectContainer container) {
                minSuccessBlocks += blocks;
                if(persistent()) container.store(this);
-               if(Logger.shouldLog(Logger.MINOR, this)) Logger.minor(this, 
"addMustSucceedBlocks("+blocks+"): total="+totalBlocks+" 
successful="+successfulBlocks+" failed="+failedBlocks+" 
required="+minSuccessBlocks); 
+               if(logMINOR) Logger.minor(this, 
"addMustSucceedBlocks("+blocks+"): total="+totalBlocks+" 
successful="+successfulBlocks+" failed="+failedBlocks+" 
required="+minSuccessBlocks); 
        }
 
        public abstract void notifyClients(ObjectContainer container, 
ClientContext context);

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to