Author: toad
Date: 2009-03-18 00:21:40 +0000 (Wed, 18 Mar 2009)
New Revision: 26083

Modified:
   branches/db4o/freenet/src/freenet/client/ArchiveHandlerImpl.java
   branches/db4o/freenet/src/freenet/client/InsertException.java
   
branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerBase.java
   
branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerCore.java
   branches/db4o/freenet/src/freenet/node/fcp/ClientRequest.java
Log:
Use new logging infrastructure


Modified: branches/db4o/freenet/src/freenet/client/ArchiveHandlerImpl.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/ArchiveHandlerImpl.java    
2009-03-18 00:11:38 UTC (rev 26082)
+++ branches/db4o/freenet/src/freenet/client/ArchiveHandlerImpl.java    
2009-03-18 00:21:40 UTC (rev 26083)
@@ -10,6 +10,7 @@
 import freenet.client.async.ClientContext;
 import freenet.client.async.DBJob;
 import freenet.keys.FreenetURI;
+import freenet.support.LogThresholdCallback;
 import freenet.support.Logger;
 import freenet.support.api.Bucket;
 import freenet.support.api.BucketFactory;
@@ -19,6 +20,18 @@
 
 class ArchiveHandlerImpl implements ArchiveHandler {
 
+       private static volatile boolean logMINOR;
+       
+       static {
+               Logger.registerLogThresholdCallback(new LogThresholdCallback() {
+                       
+                       @Override
+                       public void shouldUpdate() {
+                               logMINOR = Logger.shouldLog(Logger.MINOR, this);
+                       }
+               });
+       }
+       
        private final FreenetURI key;
        private boolean forceRefetchArchive;
        ARCHIVE_TYPE archiveType;
@@ -45,7 +58,7 @@
                Bucket data;
                
                // Fetch from cache
-               if(Logger.shouldLog(Logger.MINOR, this))
+               if(logMINOR)
                        Logger.minor(this, "Checking cache: "+key+ ' ' 
+internalName);
                if((data = manager.getCached(key, internalName)) != null) {
                        return data;
@@ -108,14 +121,13 @@
        private static void runPersistentOffThread(final ArchiveExtractTag tag, 
final ClientContext context, final ArchiveManager manager, final BucketFactory 
bf) {
                final ProxyCallback proxyCallback = new ProxyCallback();
                
-               if(Logger.shouldLog(Logger.MINOR, ArchiveHandlerImpl.class))
+               if(logMINOR)
                        Logger.minor(ArchiveHandlerImpl.class, "Scheduling 
off-thread extraction: "+tag.data+" for "+tag.handler.key+" element 
"+tag.element+" for "+tag.callback, new Exception("debug"));
                
                context.mainExecutor.execute(new Runnable() {
 
                        public void run() {
                                try {
-                                       final boolean logMINOR = 
Logger.shouldLog(Logger.MINOR, this);
                                        if(logMINOR)
                                                Logger.minor(this, "Extracting 
off-thread: "+tag.data+" for "+tag.handler.key+" element "+tag.element+" for 
"+tag.callback);
                                        tag.handler.extractToCache(tag.data, 
tag.actx, tag.element, proxyCallback, manager, null, context);

Modified: branches/db4o/freenet/src/freenet/client/InsertException.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/InsertException.java       
2009-03-18 00:11:38 UTC (rev 26082)
+++ branches/db4o/freenet/src/freenet/client/InsertException.java       
2009-03-18 00:21:40 UTC (rev 26083)
@@ -7,6 +7,7 @@
 
 import freenet.keys.FreenetURI;
 import freenet.l10n.L10n;
+import freenet.support.LogThresholdCallback;
 import freenet.support.Logger;
 
 public class InsertException extends Exception {
@@ -25,11 +26,23 @@
                return mode;
        }
        
+       private static volatile boolean logMINOR;
+       
+       static {
+               Logger.registerLogThresholdCallback(new LogThresholdCallback() {
+                       
+                       @Override
+                       public void shouldUpdate() {
+                               logMINOR = Logger.shouldLog(Logger.MINOR, this);
+                       }
+               });
+       }
+       
        public InsertException(int m, String msg, FreenetURI expectedURI) {
                super(getMessage(m)+": "+msg);
                extra = msg;
                mode = m;
-               if(Logger.shouldLog(Logger.MINOR, getClass()))
+               if(logMINOR)
                        Logger.minor(this, "Creating InsertException: 
"+getMessage(mode)+": "+msg, this);
                errorCodes = null;
                this.uri = expectedURI;
@@ -39,7 +52,7 @@
                super(getMessage(m));
                extra = null;
                mode = m;
-               if(Logger.shouldLog(Logger.MINOR, getClass()))
+               if(logMINOR)
                        Logger.minor(this, "Creating InsertException: 
"+getMessage(mode), this);
                errorCodes = null;
                this.uri = expectedURI;
@@ -48,7 +61,7 @@
        public InsertException(int mode, Throwable e, FreenetURI expectedURI) {
                super(getMessage(mode)+": "+e.getMessage());
                extra = e.getMessage();
-               if(Logger.shouldLog(Logger.MINOR, getClass()))
+               if(logMINOR)
                        Logger.minor(this, "Creating InsertException: 
"+getMessage(mode)+": "+e, e);
                this.mode = mode;
                errorCodes = null;
@@ -60,7 +73,7 @@
                super(getMessage(mode));
                extra = null;
                this.mode = mode;
-               if(Logger.shouldLog(Logger.MINOR, getClass()))
+               if(logMINOR)
                        Logger.minor(this, "Creating InsertException: 
"+getMessage(mode), this);
                this.errorCodes = errorCodes;
                this.uri = expectedURI;

Modified: 
branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerBase.java
===================================================================
--- 
branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerBase.java  
    2009-03-18 00:11:38 UTC (rev 26082)
+++ 
branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerBase.java  
    2009-03-18 00:21:40 UTC (rev 26083)
@@ -23,6 +23,7 @@
 import freenet.node.SendableGet;
 import freenet.node.SendableInsert;
 import freenet.node.SendableRequest;
+import freenet.support.LogThresholdCallback;
 import freenet.support.Logger;
 import freenet.support.RandomGrabArray;
 import freenet.support.SectoredRandomGrabArrayWithInt;
@@ -37,6 +38,18 @@
  */
 abstract class ClientRequestSchedulerBase {
        
+       private static volatile boolean logMINOR;
+       
+       static {
+               Logger.registerLogThresholdCallback(new LogThresholdCallback() {
+                       
+                       @Override
+                       public void shouldUpdate() {
+                               logMINOR = Logger.shouldLog(Logger.MINOR, this);
+                       }
+               });
+       }
+       
        /** Minimum number of retries at which we start to hold it against a 
request.
         * See the comments on fixRetryCount; we don't want many untried 
requests to prevent
         * us from trying requests which have only been tried once (e.g. USK 
checkers), from 
@@ -44,8 +57,6 @@
         * the request has been tried many times already). */
        private static final int MIN_RETRY_COUNT = 3;
 
-       private static boolean logMINOR;
-       
        final boolean isInsertScheduler;
        final boolean isSSKScheduler;
        
@@ -69,7 +80,6 @@
                this.isSSKScheduler = forSSKs;
                keyListeners = new HashSet<KeyListener>();
                priorities = new 
SortedVectorByNumber[RequestStarter.NUMBER_OF_PRIORITY_CLASSES];
-               logMINOR = Logger.shouldLog(Logger.MINOR, 
ClientRequestSchedulerBase.class);
        }
        
        /**

Modified: 
branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerCore.java
===================================================================
--- 
branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerCore.java  
    2009-03-18 00:11:38 UTC (rev 26082)
+++ 
branches/db4o/freenet/src/freenet/client/async/ClientRequestSchedulerCore.java  
    2009-03-18 00:21:40 UTC (rev 26083)
@@ -23,6 +23,7 @@
 import freenet.node.SendableInsert;
 import freenet.node.SendableRequest;
 import freenet.node.SendableRequestItem;
+import freenet.support.LogThresholdCallback;
 import freenet.support.Logger;
 import freenet.support.PrioritizedSerialExecutor;
 import freenet.support.RandomGrabArray;
@@ -39,12 +40,23 @@
  */
 class ClientRequestSchedulerCore extends ClientRequestSchedulerBase implements 
KeysFetchingLocally {
        
-       private static boolean logMINOR;
        /** Identifier in the database for the node we are attached to */
        private final long nodeDBHandle;
        final PersistentCooldownQueue persistentCooldownQueue;
        private transient long initTime;
        
+       private static volatile boolean logMINOR;
+       
+       static {
+               Logger.registerLogThresholdCallback(new LogThresholdCallback() {
+                       
+                       @Override
+                       public void shouldUpdate() {
+                               logMINOR = Logger.shouldLog(Logger.MINOR, this);
+                       }
+               });
+       }
+       
        /**
         * All Key's we are currently fetching. 
         * Locally originated requests only, avoids some complications with 
HTL, 
@@ -114,7 +126,6 @@
                        selectorContainer.store(core);
                        System.err.println("Created new core...");
                }
-               logMINOR = Logger.shouldLog(Logger.MINOR, 
ClientRequestSchedulerCore.class);
                core.onStarted(selectorContainer, cooldownTime, sched, context);
                return core;
        }

Modified: branches/db4o/freenet/src/freenet/node/fcp/ClientRequest.java
===================================================================
--- branches/db4o/freenet/src/freenet/node/fcp/ClientRequest.java       
2009-03-18 00:11:38 UTC (rev 26082)
+++ branches/db4o/freenet/src/freenet/node/fcp/ClientRequest.java       
2009-03-18 00:21:40 UTC (rev 26083)
@@ -8,6 +8,7 @@
 import freenet.keys.FreenetURI;
 import freenet.node.RequestClient;
 import freenet.support.Fields;
+import freenet.support.LogThresholdCallback;
 import freenet.support.Logger;
 import freenet.support.SimpleFieldSet;
 import freenet.support.api.Bucket;
@@ -58,6 +59,18 @@
                return hashCode;
        }
 
+       private static volatile boolean logMINOR;
+       
+       static {
+               Logger.registerLogThresholdCallback(new LogThresholdCallback() {
+                       
+                       @Override
+                       public void shouldUpdate() {
+                               logMINOR = Logger.shouldLog(Logger.MINOR, this);
+                       }
+               });
+       }
+       
        public ClientRequest(FreenetURI uri2, String identifier2, int 
verbosity2, FCPConnectionHandler handler, 
                        FCPClient client, short priorityClass2, short 
persistenceType2, String clientToken2, boolean global) {
                int hash = super.hashCode();
@@ -211,7 +224,6 @@
        }
 
        public static ClientRequest readAndRegister(BufferedReader br, 
FCPServer server, ObjectContainer container, ClientContext context) throws 
IOException {
-               boolean logMINOR = Logger.shouldLog(Logger.MINOR, 
ClientRequest.class);
                Runtime rt = Runtime.getRuntime();
                if(logMINOR)
                        Logger.minor(ClientRequest.class, 
rt.maxMemory()-rt.freeMemory()+" in use before loading request");
@@ -409,7 +421,7 @@
                if(persistenceType == PERSIST_FOREVER) {
                        container.store(this);
                        container.commit(); // commit before we send the message
-                       if(Logger.shouldLog(Logger.MINOR, this)) 
Logger.minor(this, "COMMITTED");
+                       if(logMINOR) Logger.minor(this, "COMMITTED");
                }
 
                // this could become too complex with more parameters, but for 
now its ok

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

Reply via email to