Author: toad
Date: 2006-08-24 04:41:42 +0000 (Thu, 24 Aug 2006)
New Revision: 10251
Modified:
trunk/freenet/src/freenet/client/ArchiveManager.java
trunk/freenet/src/freenet/client/ArchiveStoreContext.java
trunk/freenet/src/freenet/client/FetchException.java
trunk/freenet/src/freenet/client/InserterException.java
trunk/freenet/src/freenet/client/Metadata.java
trunk/freenet/src/freenet/client/PutWaiter.java
trunk/freenet/src/freenet/client/StandardOnionFECCodec.java
trunk/freenet/src/freenet/client/async/BaseSingleFileFetcher.java
trunk/freenet/src/freenet/client/async/ClientGetter.java
trunk/freenet/src/freenet/client/async/ClientPutter.java
trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
trunk/freenet/src/freenet/client/async/ClientRequester.java
trunk/freenet/src/freenet/client/async/SimpleHealingQueue.java
trunk/freenet/src/freenet/client/async/SimpleManifestPutter.java
trunk/freenet/src/freenet/client/async/SingleBlockInserter.java
trunk/freenet/src/freenet/client/async/SingleFileFetcher.java
trunk/freenet/src/freenet/client/async/SingleFileInserter.java
trunk/freenet/src/freenet/client/async/SplitFileFetcher.java
trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
trunk/freenet/src/freenet/client/async/SplitFileInserter.java
trunk/freenet/src/freenet/client/async/SplitFileInserterSegment.java
trunk/freenet/src/freenet/client/async/USKChecker.java
trunk/freenet/src/freenet/client/async/USKFetcher.java
trunk/freenet/src/freenet/client/async/USKInserter.java
trunk/freenet/src/freenet/client/async/USKManager.java
trunk/freenet/src/freenet/clients/http/ConfigToadlet.java
trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
trunk/freenet/src/freenet/clients/http/FProxyToadlet.java
trunk/freenet/src/freenet/clients/http/HTTPRequest.java
trunk/freenet/src/freenet/clients/http/NinjaSpider.java
trunk/freenet/src/freenet/clients/http/PproxyToadlet.java
trunk/freenet/src/freenet/clients/http/QueueToadlet.java
trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
trunk/freenet/src/freenet/clients/http/filter/CSSReadFilter.java
trunk/freenet/src/freenet/clients/http/filter/ContentFilter.java
trunk/freenet/src/freenet/clients/http/filter/GenericReadFilterCallback.java
trunk/freenet/src/freenet/clients/http/filter/HTMLFilter.java
trunk/freenet/src/freenet/config/FilePersistentConfig.java
trunk/freenet/src/freenet/crypt/Yarrow.java
trunk/freenet/src/freenet/io/NetworkInterface.java
trunk/freenet/src/freenet/io/comm/FreenetInetAddress.java
trunk/freenet/src/freenet/io/comm/Message.java
trunk/freenet/src/freenet/io/comm/UdpSocketManager.java
trunk/freenet/src/freenet/io/xfer/BlockReceiver.java
trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java
trunk/freenet/src/freenet/io/xfer/PacketThrottle.java
trunk/freenet/src/freenet/keys/FreenetURI.java
trunk/freenet/src/freenet/keys/Key.java
trunk/freenet/src/freenet/node/ARKFetchManager.java
trunk/freenet/src/freenet/node/ARKFetcher.java
trunk/freenet/src/freenet/node/CHKInsertSender.java
trunk/freenet/src/freenet/node/CPUAdjustingSwapRequestInterval.java
trunk/freenet/src/freenet/node/CPUUsageMonitor.java
trunk/freenet/src/freenet/node/DNSRequester.java
trunk/freenet/src/freenet/node/FNPPacketMangler.java
trunk/freenet/src/freenet/node/IPDetectorPluginManager.java
trunk/freenet/src/freenet/node/InsertHandler.java
trunk/freenet/src/freenet/node/KeyTracker.java
trunk/freenet/src/freenet/node/LocationManager.java
trunk/freenet/src/freenet/node/MemoryChecker.java
trunk/freenet/src/freenet/node/Node.java
trunk/freenet/src/freenet/node/NodeARKInserter.java
trunk/freenet/src/freenet/node/NodeClientCore.java
trunk/freenet/src/freenet/node/NodeDispatcher.java
trunk/freenet/src/freenet/node/NodeIPDetector.java
trunk/freenet/src/freenet/node/NodePinger.java
trunk/freenet/src/freenet/node/PacketSender.java
trunk/freenet/src/freenet/node/PeerManager.java
trunk/freenet/src/freenet/node/PeerNode.java
trunk/freenet/src/freenet/node/RequestHandler.java
trunk/freenet/src/freenet/node/RequestSender.java
trunk/freenet/src/freenet/node/RequestStarter.java
trunk/freenet/src/freenet/node/RequestStarterGroup.java
trunk/freenet/src/freenet/node/SSKInsertHandler.java
trunk/freenet/src/freenet/node/SSKInsertSender.java
trunk/freenet/src/freenet/node/SendMessageOnErrorCallback.java
trunk/freenet/src/freenet/node/SimpleSendableInsert.java
trunk/freenet/src/freenet/node/TestnetHandler.java
trunk/freenet/src/freenet/node/TextModeClientInterface.java
trunk/freenet/src/freenet/node/ThrottleWindowManager.java
trunk/freenet/src/freenet/node/Version.java
trunk/freenet/src/freenet/node/fcp/ClientGet.java
trunk/freenet/src/freenet/node/fcp/ClientGetMessage.java
trunk/freenet/src/freenet/node/fcp/ClientPut.java
trunk/freenet/src/freenet/node/fcp/ClientPutComplexDirMessage.java
trunk/freenet/src/freenet/node/fcp/ClientPutDir.java
trunk/freenet/src/freenet/node/fcp/ClientPutDiskDirMessage.java
trunk/freenet/src/freenet/node/fcp/DirPutFile.java
trunk/freenet/src/freenet/node/fcp/FCPClient.java
trunk/freenet/src/freenet/node/fcp/FCPConnectionHandler.java
trunk/freenet/src/freenet/node/fcp/FCPConnectionInputHandler.java
trunk/freenet/src/freenet/node/fcp/FCPConnectionOutputHandler.java
trunk/freenet/src/freenet/node/fcp/FCPServer.java
trunk/freenet/src/freenet/node/fcp/GetFailedMessage.java
trunk/freenet/src/freenet/node/fcp/RedirectDirPutFile.java
trunk/freenet/src/freenet/node/updater/NodeUpdater.java
trunk/freenet/src/freenet/store/BerkeleyDBFreenetStore.java
trunk/freenet/src/freenet/support/DoubleTokenBucket.java
trunk/freenet/src/freenet/support/FileLoggerHook.java
trunk/freenet/src/freenet/support/LRUHashtable.java
trunk/freenet/src/freenet/support/LimitedRangeIntByteArrayMap.java
trunk/freenet/src/freenet/support/NumberedItemComparator.java
trunk/freenet/src/freenet/support/NumberedRecentItems.java
trunk/freenet/src/freenet/support/RandomGrabArray.java
trunk/freenet/src/freenet/support/SimpleIntNumberedItemComparator.java
trunk/freenet/src/freenet/support/SortedLongSet.java
trunk/freenet/src/freenet/support/SortedVectorByNumber.java
trunk/freenet/src/freenet/support/TokenBucket.java
trunk/freenet/src/freenet/support/UpdatableSortedLinkedList.java
trunk/freenet/src/freenet/support/io/FilenameGenerator.java
trunk/freenet/src/freenet/support/io/PaddedEphemerallyEncryptedBucket.java
trunk/freenet/src/freenet/support/io/PersistentTempBucketFactory.java
trunk/freenet/src/freenet/support/io/RandomAccessFileBucket.java
trunk/freenet/src/freenet/support/io/TempFileBucket.java
trunk/freenet/src/freenet/support/math/BootstrappingDecayingRunningAverage.java
trunk/freenet/src/freenet/support/math/TimeDecayingRunningAverage.java
trunk/freenet/src/freenet/transport/IPUtil.java
Log:
Don't generate logging strings unless we actually need them.
Should significantly reduce CPU usage on normal nodes.
Modified: trunk/freenet/src/freenet/client/ArchiveManager.java
===================================================================
--- trunk/freenet/src/freenet/client/ArchiveManager.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/client/ArchiveManager.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -31,6 +31,8 @@
*/
public class ArchiveManager {
+ private static boolean logMINOR;
+
/**
* Create an ArchiveManager.
* @param maxHandlers The maximum number of cached ArchiveHandler's.
@@ -55,6 +57,7 @@
this.maxArchivedFileSize = maxArchivedFileSize;
this.random = random;
this.filenameGenerator = filenameGenerator;
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
}
final RandomSource random;
@@ -69,7 +72,7 @@
/** Add an ArchiveHandler by key */
private synchronized void putCached(FreenetURI key, ArchiveHandler zip)
{
- Logger.minor(this, "Put cached AH for "+key+" : "+zip);
+ if(logMINOR) Logger.minor(this, "Put cached AH for "+key+" :
"+zip);
archiveHandlers.push(key, zip);
while(archiveHandlers.size() > maxArchiveHandlers)
archiveHandlers.popKey(); // dump it
@@ -77,7 +80,7 @@
/** Get an ArchiveHandler by key */
public ArchiveHandler getCached(FreenetURI key) {
- Logger.minor(this, "Get cached AH for "+key);
+ if(logMINOR) Logger.minor(this, "Get cached AH for "+key);
ArchiveHandler handler = (ArchiveHandler)
archiveHandlers.get(key);
if(handler == null) return null;
archiveHandlers.push(key, handler);
@@ -128,7 +131,7 @@
* @throws ArchiveFailureException
*/
public synchronized Bucket getCached(FreenetURI key, String filename)
throws ArchiveFailureException {
- Logger.minor(this, "Fetch cached: "+key+" "+filename);
+ if(logMINOR) Logger.minor(this, "Fetch cached: "+key+"
"+filename);
ArchiveKey k = new ArchiveKey(key, filename);
ArchiveStoreItem asi = (ArchiveStoreItem) storedData.get(k);
if(asi == null) return null;
@@ -159,8 +162,10 @@
*/
public void extractToCache(FreenetURI key, short archiveType, Bucket
data, ArchiveContext archiveContext, ArchiveStoreContext ctx) throws
ArchiveFailureException, ArchiveRestartException {
- Logger.minor(this, "Extracting "+key);
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "Extracting "+key);
+
ctx.removeAllCachedItems(); // flush cache anyway
long expectedSize = ctx.getLastSize();
long archiveSize = data.size();
@@ -359,7 +364,7 @@
*/
private void addErrorElement(ArchiveStoreContext ctx, FreenetURI key,
String name, String error) {
ErrorArchiveStoreItem element = new ErrorArchiveStoreItem(ctx,
key, name, error);
- Logger.minor(this, "Adding error element: "+element+" for
"+key+" "+name);
+ if(logMINOR) Logger.minor(this, "Adding error element:
"+element+" for "+key+" "+name);
synchronized(storedData) {
storedData.push(element.key, element);
}
@@ -370,7 +375,7 @@
*/
private void addStoreElement(ArchiveStoreContext ctx, FreenetURI key,
String name, TempStoreElement temp) {
RealArchiveStoreItem element = new RealArchiveStoreItem(this,
ctx, key, name, temp);
- Logger.minor(this, "Adding store element: "+element+" ( "+key+"
"+name+" )");
+ if(logMINOR) Logger.minor(this, "Adding store element:
"+element+" ( "+key+" "+name+" )");
synchronized(storedData) {
storedData.push(element.key, element);
trimStoredData();
Modified: trunk/freenet/src/freenet/client/ArchiveStoreContext.java
===================================================================
--- trunk/freenet/src/freenet/client/ArchiveStoreContext.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/client/ArchiveStoreContext.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -51,7 +51,8 @@
Bucket data;
// Fetch from cache
- Logger.minor(this, "Checking cache: "+key+" "+internalName);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Checking cache: "+key+"
"+internalName);
if((data = manager.getCached(key, internalName)) != null) {
return data;
}
Modified: trunk/freenet/src/freenet/client/FetchException.java
===================================================================
--- trunk/freenet/src/freenet/client/FetchException.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/client/FetchException.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -46,7 +46,8 @@
errorCodes = null;
newURI = null;
expectedSize = -1;
- Logger.minor(this, "FetchException("+getMessage(mode)+")",
this);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this,
"FetchException("+getMessage(mode)+")", this);
}
public FetchException(int m, long expectedSize, boolean finalizedSize,
String expectedMimeType) {
@@ -58,8 +59,8 @@
newURI = null;
this.expectedSize = expectedSize;
this.expectedMimeType = expectedMimeType;
- Logger.minor(this, "FetchException("+getMessage(mode)+")",
this);
-
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this,
"FetchException("+getMessage(mode)+")", this);
}
public FetchException(MetadataParseException e) {
@@ -70,7 +71,8 @@
initCause(e);
newURI = null;
expectedSize = -1;
- Logger.minor(this, "FetchException("+getMessage(mode)+"):
"+e,e);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this,
"FetchException("+getMessage(mode)+"): "+e,e);
}
public FetchException(ArchiveFailureException e) {
@@ -81,7 +83,8 @@
newURI = null;
initCause(e);
expectedSize = -1;
- Logger.minor(this, "FetchException("+getMessage(mode)+"):
"+e,e);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this,
"FetchException("+getMessage(mode)+"): "+e,e);
}
public FetchException(ArchiveRestartException e) {
@@ -92,7 +95,8 @@
initCause(e);
newURI = null;
expectedSize = -1;
- Logger.minor(this, "FetchException("+getMessage(mode)+"):
"+e,e); }
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this,
"FetchException("+getMessage(mode)+"): "+e,e); }
public FetchException(int mode, Throwable t) {
super(getMessage(mode)+": "+t.getMessage());
@@ -102,7 +106,8 @@
initCause(t);
newURI = null;
expectedSize = -1;
- Logger.minor(this, "FetchException("+getMessage(mode)+"):
"+t.getMessage(),t);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this,
"FetchException("+getMessage(mode)+"): "+t.getMessage(),t);
}
public FetchException(int mode, FailureCodeTracker errorCodes) {
@@ -112,7 +117,8 @@
this.errorCodes = errorCodes;
newURI = null;
expectedSize = -1;
- Logger.minor(this, "FetchException("+getMessage(mode)+")");
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this,
"FetchException("+getMessage(mode)+")");
}
public FetchException(int mode, String msg) {
@@ -122,7 +128,8 @@
this.mode = mode;
newURI = null;
expectedSize = -1;
- Logger.minor(this, "FetchException("+getMessage(mode)+"):
"+msg,this);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this,
"FetchException("+getMessage(mode)+"): "+msg,this);
}
public FetchException(int mode, FreenetURI newURI) {
@@ -132,7 +139,8 @@
errorCodes = null;
this.newURI = newURI;
expectedSize = -1;
- Logger.minor(this, "FetchException("+getMessage(mode)+") ->
"+newURI, this);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this,
"FetchException("+getMessage(mode)+") -> "+newURI, this);
}
public static String getShortMessage(int mode) {
Modified: trunk/freenet/src/freenet/client/InserterException.java
===================================================================
--- trunk/freenet/src/freenet/client/InserterException.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/client/InserterException.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -23,7 +23,8 @@
super(getMessage(m)+": "+msg);
extra = msg;
mode = m;
- Logger.minor(this, "Creating InserterException:
"+getMessage(mode)+": "+msg, this);
+ if(Logger.shouldLog(Logger.MINOR, getClass()))
+ Logger.minor(this, "Creating InserterException:
"+getMessage(mode)+": "+msg, this);
errorCodes = null;
this.uri = expectedURI;
}
@@ -32,7 +33,8 @@
super(getMessage(m));
extra = null;
mode = m;
- Logger.minor(this, "Creating InserterException:
"+getMessage(mode), this);
+ if(Logger.shouldLog(Logger.MINOR, getClass()))
+ Logger.minor(this, "Creating InserterException:
"+getMessage(mode), this);
errorCodes = null;
this.uri = expectedURI;
}
@@ -40,7 +42,8 @@
public InserterException(int mode, Throwable e, FreenetURI expectedURI)
{
super(getMessage(mode)+": "+e.getMessage());
extra = e.getMessage();
- Logger.minor(this, "Creating InserterException:
"+getMessage(mode)+": "+e, e);
+ if(Logger.shouldLog(Logger.MINOR, getClass()))
+ Logger.minor(this, "Creating InserterException:
"+getMessage(mode)+": "+e, e);
this.mode = mode;
errorCodes = null;
initCause(e);
@@ -51,7 +54,8 @@
super(getMessage(mode));
extra = null;
this.mode = mode;
- Logger.minor(this, "Creating InserterException:
"+getMessage(mode), this);
+ if(Logger.shouldLog(Logger.MINOR, getClass()))
+ Logger.minor(this, "Creating InserterException:
"+getMessage(mode), this);
this.errorCodes = errorCodes;
this.uri = expectedURI;
}
Modified: trunk/freenet/src/freenet/client/Metadata.java
===================================================================
--- trunk/freenet/src/freenet/client/Metadata.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/client/Metadata.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -171,7 +171,8 @@
documentType = dis.readByte();
if((documentType < 0) || (documentType > 5))
throw new MetadataParseException("Unsupported document
type: "+documentType);
- Logger.minor(this, "Document type: "+documentType);
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "Document type: "+documentType);
boolean compressed = false;
if((documentType == SIMPLE_REDIRECT) || (documentType ==
MULTI_LEVEL_METADATA)
@@ -188,14 +189,14 @@
}
if(documentType == ZIP_MANIFEST) {
- Logger.minor(this, "Zip manifest");
+ if(logMINOR) Logger.minor(this, "Zip manifest");
archiveType = dis.readShort();
if(archiveType != ARCHIVE_ZIP)
throw new MetadataParseException("Unrecognized
archive type "+archiveType);
}
if(splitfile) {
- Logger.minor(this, "Splitfile");
+ if(logMINOR) Logger.minor(this, "Splitfile");
dataLength = dis.readLong();
if(dataLength < -1)
throw new MetadataParseException("Invalid real
content length "+dataLength);
@@ -216,10 +217,10 @@
if(noMIME) {
mimeType = null;
- Logger.minor(this, "noMIME enabled");
+ if(logMINOR) Logger.minor(this, "noMIME enabled");
} else {
if(compressedMIME) {
- Logger.minor(this, "Compressed MIME");
+ if(logMINOR) Logger.minor(this, "Compressed
MIME");
short x = dis.readShort();
compressedMIMEValue = (short) (x & 32767); //
chop off last bit
hasCompressedMIMEParams = (compressedMIMEValue
& 32768) == 32768;
@@ -238,9 +239,9 @@
dis.readFully(toRead);
// Use UTF-8 for everything, for simplicity
mimeType = new String(toRead, "UTF-8");
- Logger.minor(this, "Raw MIME");
+ if(logMINOR) Logger.minor(this, "Raw MIME");
}
- Logger.minor(this, "MIME = "+mimeType);
+ if(logMINOR) Logger.minor(this, "MIME = "+mimeType);
}
if(dbr) {
@@ -317,7 +318,7 @@
byte[] buf = new byte[nameLength];
dis.readFully(buf);
String name = new String(buf, "UTF-8");
- Logger.minor(this, "Entry "+i+" name "+name);
+ if(logMINOR) Logger.minor(this, "Entry "+i+"
name "+name);
short len = dis.readShort();
if(len < 0)
throw new
MetadataParseException("Invalid manifest entry size: "+len);
@@ -336,11 +337,11 @@
if(documentType == ZIP_INTERNAL_REDIRECT) {
int len = dis.readShort();
- Logger.minor(this, "Reading zip internal redirect
length "+len);
+ if(logMINOR) Logger.minor(this, "Reading zip internal
redirect length "+len);
byte[] buf = new byte[len];
dis.readFully(buf);
nameInArchive = new String(buf, "UTF-8");
- Logger.minor(this, "Zip internal redirect:
"+nameInArchive+" ("+len+")");
+ if(logMINOR) Logger.minor(this, "Zip internal redirect:
"+nameInArchive+" ("+len+")");
}
}
Modified: trunk/freenet/src/freenet/client/PutWaiter.java
===================================================================
--- trunk/freenet/src/freenet/client/PutWaiter.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/client/PutWaiter.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -34,7 +34,8 @@
}
public synchronized void onGeneratedURI(FreenetURI uri,
BaseClientPutter state) {
- Logger.minor(this, "URI: "+uri);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "URI: "+uri);
if(this.uri == null)
this.uri = uri;
if(uri.equals(this.uri)) return;
Modified: trunk/freenet/src/freenet/client/StandardOnionFECCodec.java
===================================================================
--- trunk/freenet/src/freenet/client/StandardOnionFECCodec.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/client/StandardOnionFECCodec.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -21,6 +21,8 @@
*/
public class StandardOnionFECCodec extends FECCodec {
+ private static boolean logMINOR;
+
public class Encoder implements Runnable {
private final Bucket[] dataBlockStatus, checkBlockStatus;
@@ -50,7 +52,8 @@
thrownError = e;
}
long endTime = System.currentTimeMillis();
- Logger.minor(this, "Splitfile encode: k="+k+", n="+n+"
encode took "+(endTime-startTime)+"ms");
+ if(logMINOR)
+ Logger.minor(this, "Splitfile encode: k="+k+",
n="+n+" encode took "+(endTime-startTime)+"ms");
finished = true;
synchronized(this) {
notify();
@@ -131,13 +134,16 @@
//decoder = new PureCode(k,n);
// Crashes are caused by bugs which cause to use 320/128 etc. -
n > 256, k < 256.
decoder = encoder;
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
}
private static Object runningDecodesSync = new Object();
private static int runningDecodes;
public void decode(SplitfileBlock[] dataBlockStatus, SplitfileBlock[]
checkBlockStatus, int blockLength, BucketFactory bf) throws IOException {
- Logger.minor(this, "Queueing decode: " + dataBlockStatus.length
+ logMINOR = Logger.shouldLog(Logger.MINOR, getClass());
+ if(logMINOR)
+ Logger.minor(this, "Queueing decode: " +
dataBlockStatus.length
+ " data blocks, " + checkBlockStatus.length
+ " check blocks, block length " + blockLength
+ " with "
+ this, new Exception("debug"));
@@ -163,10 +169,11 @@
}
public void realDecode(SplitfileBlock[] dataBlockStatus,
SplitfileBlock[] checkBlockStatus, int blockLength, BucketFactory bf) throws
IOException {
- Logger.minor(this, "Doing decode: " + dataBlockStatus.length
- + " data blocks, " + checkBlockStatus.length
- + " check blocks, block length " + blockLength
+ " with "
- + this, new Exception("debug"));
+ if(logMINOR)
+ Logger.minor(this, "Doing decode: " +
dataBlockStatus.length
+ + " data blocks, " +
checkBlockStatus.length
+ + " check blocks, block length " +
blockLength + " with "
+ + this, new Exception("debug"));
if (dataBlockStatus.length + checkBlockStatus.length != n)
throw new IllegalArgumentException();
if (dataBlockStatus.length != k)
@@ -196,7 +203,7 @@
if (buckets[i] == null) {
buckets[i] = bf.makeBucket(blockLength);
writers[i] =
buckets[i].getOutputStream();
- Logger.minor(this, "writers[" + i + "]
!= null");
+ if(logMINOR) Logger.minor(this,
"writers[" + i + "] != null");
readers[i] = null;
numberToDecode++;
} else {
@@ -216,8 +223,7 @@
throw new
IllegalArgumentException("Too big: " + sz
+ "
bigger than " + blockLength);
}
- Logger.minor(this, "writers[" + i
- + "] = null (already
filled)");
+ if(logMINOR) Logger.minor(this,
"writers[" + i + "] = null (already filled)");
writers[i] = null;
readers[i] = new
DataInputStream(buckets[i]
.getInputStream());
@@ -240,7 +246,7 @@
throw new IllegalArgumentException(
"Must have at least k packets
(k="+k+",idx="+idx+")");
- for (int i = 0; i < packetIndexes.length; i++)
+ if(logMINOR) for (int i = 0; i < packetIndexes.length;
i++)
Logger.minor(this, "[" + i + "] = " +
packetIndexes[i]);
if (numberToDecode > 0) {
@@ -292,10 +298,12 @@
}
public void encode(Bucket[] dataBlockStatus, Bucket[] checkBlockStatus,
int blockLength, BucketFactory bf) throws IOException {
- Logger.minor(this, "Queueing encode: " + dataBlockStatus.length
- + " data blocks, " + checkBlockStatus.length
- + " check blocks, block length " + blockLength
+ " with "
- + this, new Exception("debug"));
+ logMINOR = Logger.shouldLog(Logger.MINOR, getClass());
+ if(logMINOR)
+ Logger.minor(this, "Queueing encode: " +
dataBlockStatus.length
+ + " data blocks, " +
checkBlockStatus.length
+ + " check blocks, block length " +
blockLength + " with "
+ + this, new Exception("debug"));
// Encodes count as decodes.
synchronized(runningDecodesSync) {
while(runningDecodes >= PARALLEL_DECODES) {
@@ -357,11 +365,13 @@
// Runtime.getRuntime().gc();
// Runtime.getRuntime().runFinalization();
long memUsedAtStart = Runtime.getRuntime().totalMemory() -
Runtime.getRuntime().freeMemory();
- Logger.minor(this, "Memory in use at start: "+memUsedAtStart+"
max="+Runtime.getRuntime().maxMemory());
- Logger.minor(this, "Doing encode: " + dataBlockStatus.length
- + " data blocks, " + checkBlockStatus.length
- + " check blocks, block length " + blockLength
+ " with "
- + this);
+ if(logMINOR) {
+ Logger.minor(this, "Memory in use at start:
"+memUsedAtStart+" max="+Runtime.getRuntime().maxMemory());
+ Logger.minor(this, "Doing encode: " +
dataBlockStatus.length
+ + " data blocks, " +
checkBlockStatus.length
+ + " check blocks, block length " +
blockLength + " with "
+ + this);
+ }
if ((dataBlockStatus.length + checkBlockStatus.length != n) ||
(dataBlockStatus.length != k))
throw new IllegalArgumentException("Data blocks:
"+dataBlockStatus.length+", Check blocks: "+checkBlockStatus.length+", n:
"+n+", k: "+k);
@@ -417,13 +427,13 @@
// Runtime.getRuntime().gc();
// Runtime.getRuntime().runFinalization();
long memUsedBeforeEncodes =
Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
- Logger.minor(this, "Memory in use before encodes:
"+memUsedBeforeEncodes);
+ if(logMINOR) Logger.minor(this, "Memory in use before
encodes: "+memUsedBeforeEncodes);
if (numberToEncode > 0) {
// Do the (striped) encode
for (int offset = 0; offset < blockLength;
offset += STRIPE_SIZE) {
long memUsedBeforeRead =
Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
- Logger.minor(this, "Memory in use
before read: "+memUsedBeforeRead);
+ if(logMINOR) Logger.minor(this, "Memory
in use before read: "+memUsedBeforeRead);
// Read the data in first
for (int i = 0; i < k; i++) {
readers[i].readFully(realBuffer, i * STRIPE_SIZE,
@@ -437,16 +447,16 @@
// Runtime.getRuntime().gc();
// Runtime.getRuntime().runFinalization();
long memUsedBeforeStripe =
Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
- Logger.minor(this, "Memory in use
before stripe: "+memUsedBeforeStripe);
+ if(logMINOR) Logger.minor(this, "Memory
in use before stripe: "+memUsedBeforeStripe);
encoder.encode(dataPackets,
checkPackets, toEncode);
// Runtime.getRuntime().gc();
// Runtime.getRuntime().runFinalization();
// Runtime.getRuntime().gc();
// Runtime.getRuntime().runFinalization();
long memUsedAfterStripe =
Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
- Logger.minor(this, "Memory in use after
stripe: "+memUsedAfterStripe);
+ if(logMINOR) Logger.minor(this, "Memory
in use after stripe: "+memUsedAfterStripe);
long endTime =
System.currentTimeMillis();
- Logger.minor(this, "Stripe encode took "
+ if(logMINOR) Logger.minor(this, "Stripe
encode took "
+ (endTime - startTime)
+ "ms for k=" + k + ", n="
+ n + ", stripeSize=" +
STRIPE_SIZE);
// Try to limit CPU usage!!
Modified: trunk/freenet/src/freenet/client/async/BaseSingleFileFetcher.java
===================================================================
--- trunk/freenet/src/freenet/client/async/BaseSingleFileFetcher.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/client/async/BaseSingleFileFetcher.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -57,7 +57,8 @@
/** Try again - returns true if we can retry */
protected boolean retry() {
retryCount++;
- Logger.minor(this, "Attempting to retry... (max "+maxRetries+",
current "+retryCount+")");
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Attempting to retry... (max
"+maxRetries+", current "+retryCount+")");
// We want 0, 1, ... maxRetries i.e. maxRetries+1 attempts
(maxRetries=0 => try once)
if((retryCount <= maxRetries) || (maxRetries == -1)) {
schedule();
@@ -67,7 +68,8 @@
}
public void schedule() {
- Logger.minor(this, "Scheduling "+this+" for "+key);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Scheduling "+this+" for "+key);
if(key instanceof ClientCHK)
parent.chkScheduler.register(this);
else if(key instanceof ClientSSK)
Modified: trunk/freenet/src/freenet/client/async/ClientGetter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/ClientGetter.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/client/async/ClientGetter.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -86,7 +86,8 @@
Bucket from = result.asBucket();
Bucket to = returnBucket;
try {
- Logger.minor(this, "Copying - returnBucket not
respected by client.async");
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Copying -
returnBucket not respected by client.async");
BucketTools.copy(from, to);
from.free();
} catch (IOException e) {
@@ -95,7 +96,7 @@
}
result = new FetchResult(result, to);
} else {
- if(returnBucket != null)
+ if(returnBucket != null &&
Logger.shouldLog(Logger.MINOR, this))
Logger.minor(this, "client.async returned data
in returnBucket");
}
client.onSuccess(result, this);
@@ -124,14 +125,15 @@
}
public void cancel() {
- Logger.minor(this, "Cancelling "+this);
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "Cancelling "+this);
super.cancel();
ClientGetState s;
synchronized(this) {
s = currentState;
}
if(s != null) {
- Logger.minor(this, "Cancelling "+currentState);
+ if(logMINOR) Logger.minor(this, "Cancelling
"+currentState);
s.cancel();
}
}
@@ -149,7 +151,8 @@
}
public void onBlockSetFinished(ClientGetState state) {
- Logger.minor(this, "Set finished", new Exception("debug"));
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Set finished", new
Exception("debug"));
blockSetFinalized();
}
Modified: trunk/freenet/src/freenet/client/async/ClientPutter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/ClientPutter.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/client/async/ClientPutter.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -60,7 +60,8 @@
}
public void start() throws InserterException {
- Logger.minor(this, "Starting "+this);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Starting "+this);
try {
boolean cancel = false;
synchronized(this) {
@@ -107,7 +108,8 @@
this.client.onFailure(e, this);
}
}
- Logger.minor(this, "Started "+this);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Started "+this);
}
public void onSuccess(ClientPutState state) {
@@ -179,7 +181,8 @@
}
public void onBlockSetFinished(ClientPutState state) {
- Logger.minor(this, "Set finished", new Exception("debug"));
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Set finished", new
Exception("debug"));
blockSetFinalized();
}
Modified: trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
===================================================================
--- trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -28,6 +28,8 @@
*/
public class ClientRequestScheduler implements RequestScheduler {
+ private static boolean logMINOR;
+
public class PrioritySchedulerCallback implements StringCallback{
final ClientRequestScheduler cs;
@@ -138,6 +140,7 @@
sc.register(name+"_priority_policy", PRIORITY_HARD,
name.hashCode(), true, "Priority policy of the "+name+"scheduler", "Set the
priority policy scheme used by the scheduler. Could be one of
["+PRIORITY_HARD+", "+PRIORITY_SOFT+"]",
new PrioritySchedulerCallback(this));
this.choosenPriorityScheduler =
sc.getString(name+"_priority_policy");
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
}
/** Called by the config. Callback
@@ -149,7 +152,8 @@
}
public void register(SendableRequest req) {
- Logger.minor(this, "Registering "+req, new Exception("debug"));
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "Registering "+req, new
Exception("debug"));
if((!isInsertScheduler) && (req instanceof ClientPutter))
throw new IllegalArgumentException("Expected a
ClientPut: "+req);
if(req instanceof SendableGet) {
@@ -165,7 +169,7 @@
return;
}
if(block != null) {
- Logger.minor(this, "Can fulfill "+req+"
immediately from store");
+ if(logMINOR) Logger.minor(this, "Can
fulfill "+req+" immediately from store");
getter.onSuccess(block, true);
return;
}
@@ -178,7 +182,7 @@
}
private synchronized void innerRegister(SendableRequest req) {
- Logger.minor(this, "Still registering "+req+" at prio
"+req.getPriorityClass()+" retry "+req.getRetryCount());
+ if(logMINOR) Logger.minor(this, "Still registering "+req+" at
prio "+req.getPriorityClass()+" retry "+req.getRetryCount());
addToGrabArray(req.getPriorityClass(), req.getRetryCount(),
req.getClient(), req.getClientRequest(), req);
HashSet v = (HashSet)
allRequestsByClientRequest.get(req.getClientRequest());
if(v == null) {
@@ -186,7 +190,7 @@
allRequestsByClientRequest.put(req.getClientRequest(),
v);
}
v.add(req);
- Logger.minor(this, "Registered "+req+" on
prioclass="+req.getPriorityClass()+", retrycount="+req.getRetryCount());
+ if(logMINOR) Logger.minor(this, "Registered "+req+" on
prioclass="+req.getPriorityClass()+", retrycount="+req.getRetryCount());
}
private synchronized void addToGrabArray(short priorityClass, int
retryCount, Object client, ClientRequester cr, SendableRequest req) {
@@ -203,7 +207,7 @@
if(clientGrabber == null) {
clientGrabber = new
SectoredRandomGrabArrayWithInt(random, retryCount);
prio.add(clientGrabber);
- Logger.minor(this, "Registering retry count
"+retryCount+" with prioclass "+priorityClass);
+ if(logMINOR) Logger.minor(this, "Registering retry
count "+retryCount+" with prioclass "+priorityClass);
}
// Request
SectoredRandomGrabArrayWithClient requestGrabber =
(SectoredRandomGrabArrayWithClient) clientGrabber.getGrabber(client);
@@ -232,11 +236,11 @@
priority = fuzz<0 ?
tweakedPrioritySelector[random.nextInt(tweakedPrioritySelector.length)] :
prioritySelector[Math.abs(fuzz % prioritySelector.length)];
result = priorities[priority];
if((result != null) && !result.isEmpty()) {
- Logger.minor(this, "using priority :
"+priority);
+ if(logMINOR) Logger.minor(this, "using priority
: "+priority);
return result;
}
- Logger.debug(this, "Priority "+priority+" is null (fuzz
= "+fuzz+")");
+ if(logMINOR) Logger.debug(this, "Priority "+priority+"
is null (fuzz = "+fuzz+")");
fuzz++;
}
@@ -246,36 +250,36 @@
public SendableRequest removeFirst() {
// Priorities start at 0
- Logger.minor(this, "removeFirst()");
+ if(logMINOR) Logger.minor(this, "removeFirst()");
int choosenPriorityClass = Integer.MAX_VALUE;
SortedVectorByNumber s =
removeFirstAccordingToPriorities(choosenPriorityClass);
if(s != null){
while(true) {
SectoredRandomGrabArrayWithInt rga =
(SectoredRandomGrabArrayWithInt) s.getFirst();
if(rga == null) {
- Logger.minor(this, "No retrycount's
left");
+ if(logMINOR) Logger.minor(this, "No
retrycount's left");
break;
}
SendableRequest req = (SendableRequest)
rga.removeRandom();
if(rga.isEmpty()) {
- Logger.minor(this, "Removing retrycount
"+rga.getNumber());
+ if(logMINOR) Logger.minor(this,
"Removing retrycount "+rga.getNumber());
s.remove(rga.getNumber());
if(s.isEmpty()) {
- Logger.minor(this, "Should
remove priority ");
+ if(logMINOR) Logger.minor(this,
"Should remove priority ");
}
}
if(req == null) {
- Logger.minor(this, "No requests,
retrycount "+rga.getNumber()+" ("+rga+")");
+ if(logMINOR) Logger.minor(this, "No
requests, retrycount "+rga.getNumber()+" ("+rga+")");
break;
}else if(req.getPriorityClass() >
choosenPriorityClass) {
// Reinsert it : shouldn't happen if we
are calling reregisterAll,
// maybe we should ask people to report
that error if seen
- Logger.minor(this, "In wrong priority
class: "+req);
+ if(logMINOR) Logger.minor(this, "In
wrong priority class: "+req);
innerRegister(req);
continue;
}
- Logger.minor(this, "removeFirst() returning
"+req+" ("+rga.getNumber()+", prio "+req.getPriorityClass()+", retries
"+req.getRetryCount()+")");
+ if(logMINOR) Logger.minor(this, "removeFirst()
returning "+req+" ("+rga.getNumber()+", prio "+req.getPriorityClass()+",
retries "+req.getRetryCount()+")");
ClientRequester cr = req.getClientRequest();
HashSet v = (HashSet)
allRequestsByClientRequest.get(cr);
v.remove(req);
@@ -284,7 +288,7 @@
return req;
}
}
- Logger.minor(this, "No requests to run");
+ if(logMINOR) Logger.minor(this, "No requests to run");
return null;
}
Modified: trunk/freenet/src/freenet/client/async/ClientRequester.java
===================================================================
--- trunk/freenet/src/freenet/client/async/ClientRequester.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/client/async/ClientRequester.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -58,7 +58,8 @@
if(blockSetFinalized) return;
blockSetFinalized = true;
}
- Logger.minor(this, "Finalized set of blocks for "+this, new
Exception("debug"));
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Finalized set of blocks for "+this,
new Exception("debug"));
notifyClients();
}
@@ -81,7 +82,8 @@
}
public void completedBlock(boolean dontNotify) {
- Logger.minor(this, "Completed block ("+dontNotify+")");
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Completed block ("+dontNotify+")");
synchronized(this) {
successfulBlocks++;
if(dontNotify) return;
Modified: trunk/freenet/src/freenet/client/async/SimpleHealingQueue.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SimpleHealingQueue.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/client/async/SimpleHealingQueue.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -43,7 +43,8 @@
}
try {
sbi.schedule();
- Logger.minor(this, "Started healing insert "+ctr+" for
"+data);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Started healing insert
"+ctr+" for "+data);
return true;
} catch (Throwable e) {
Logger.error(this, "Caught trying to insert healing
block: "+e, e);
@@ -78,7 +79,8 @@
synchronized(this) {
runningInserters.remove(data);
}
- Logger.minor(this, "Successfully inserted healing block:
"+sbi.getURI()+" for "+data+" ("+sbi.token+")");
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Successfully inserted healing
block: "+sbi.getURI()+" for "+data+" ("+sbi.token+")");
data.free();
}
@@ -88,7 +90,8 @@
synchronized(this) {
runningInserters.remove(data);
}
- Logger.minor(this, "Failed to insert healing block:
"+sbi.getURI()+" : "+e+" for "+data+" ("+sbi.token+")", e);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Failed to insert healing block:
"+sbi.getURI()+" : "+e+" for "+data+" ("+sbi.token+")", e);
data.free();
}
Modified: trunk/freenet/src/freenet/client/async/SimpleManifestPutter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SimpleManifestPutter.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/client/async/SimpleManifestPutter.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -82,7 +82,8 @@
}
public void onSuccess(ClientPutState state) {
- Logger.minor(this, "Completed "+this);
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "Completed "+this);
SimpleManifestPutter.this.onFetchable(this);
synchronized(SimpleManifestPutter.this) {
runningPutHandlers.remove(this);
@@ -94,12 +95,13 @@
}
public void onFailure(InserterException e, ClientPutState
state) {
- Logger.minor(this, "Failed: "+this+" - "+e, e);
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "Failed: "+this+" -
"+e, e);
fail(e);
}
public void onEncode(BaseClientKey key, ClientPutState state) {
- Logger.minor(this, "onEncode("+key+") for "+this);
+ if(logMINOR) Logger.minor(this, "onEncode("+key+") for
"+this);
if(metadata == null) {
// The file was too small to have its own
metadata, we get this instead.
// So we make the key into metadata.
@@ -112,7 +114,8 @@
public void onTransition(ClientPutState oldState,
ClientPutState newState) {}
public void onMetadata(Metadata m, ClientPutState state) {
- Logger.minor(this, "Assigning metadata: "+m+" for
"+this+" from "+state,
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "Assigning metadata:
"+m+" for "+this+" from "+state,
new Exception("debug"));
if(metadata != null) {
Logger.error(this, "Reassigning metadata", new
Exception("debug"));
@@ -172,6 +175,7 @@
}
+ static boolean logMINOR;
private final HashMap putHandlersByName;
private final HashSet runningPutHandlers;
private final HashSet putHandlersWaitingForMetadata;
@@ -203,6 +207,7 @@
ClientRequestScheduler sskSched, HashMap
manifestElements, short prioClass, FreenetURI target,
String defaultName, InserterContext ctx, boolean
getCHKOnly, Object clientContext) throws InserterException {
super(prioClass, chkSched, sskSched, clientContext);
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
this.defaultName = defaultName;
this.targetURI = target;
this.cb = cb;
@@ -226,7 +231,8 @@
}
public synchronized void start() throws InserterException {
- Logger.minor(this, "Starting "+this);
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "Starting "+this);
PutHandler[] running;
running = (PutHandler[]) runningPutHandlers.toArray(new
PutHandler[runningPutHandlers.size()]);
@@ -235,7 +241,7 @@
for(int i=0;i<running.length;i++) {
running[i].start();
}
- Logger.minor(this, "Started "+running.length+"
PutHandler's for "+this);
+ if(logMINOR) Logger.minor(this, "Started
"+running.length+" PutHandler's for "+this);
if(cancelled) cancel();
if(running.length == 0) {
insertedAllFiles = true;
@@ -316,7 +322,7 @@
}
private void gotAllMetadata() {
- Logger.minor(this, "Got all metadata");
+ if(logMINOR) Logger.minor(this, "Got all metadata");
HashMap namesToByteArrays = new HashMap();
namesToByteArrays(putHandlersByName, namesToByteArrays);
if(defaultName != null) {
@@ -427,7 +433,7 @@
try {
SingleFileInserter metadataInserter =
new SingleFileInserter(this, this, block,
isMetadata, ctx, false, getCHKOnly, false, baseMetadata,
insertAsArchiveManifest, true);
- Logger.minor(this, "Inserting main metadata:
"+metadataInserter);
+ if(logMINOR) Logger.minor(this, "Inserting main
metadata: "+metadataInserter);
this.metadataPuttersByMetadata.put(baseMetadata,
metadataInserter);
metadataPuttersUnfetchable.put(baseMetadata,
metadataInserter);
metadataInserter.start(null);
@@ -452,7 +458,7 @@
InsertBlock ib = new InsertBlock(b, null,
FreenetURI.EMPTY_CHK_URI);
SingleFileInserter metadataInserter =
new SingleFileInserter(this, this, ib,
true, ctx, false, getCHKOnly, false, m, false, true);
- Logger.minor(this, "Inserting subsidiary
metadata: "+metadataInserter+" for "+m);
+ if(logMINOR) Logger.minor(this, "Inserting
subsidiary metadata: "+metadataInserter+" for "+m);
synchronized(this) {
this.metadataPuttersByMetadata.put(m,
metadataInserter);
}
@@ -483,15 +489,15 @@
}
private void insertedAllFiles() {
- Logger.minor(this, "Inserted all files");
+ if(logMINOR) Logger.minor(this, "Inserted all files");
synchronized(this) {
insertedAllFiles = true;
if(finished || cancelled) {
- Logger.minor(this, "Already
"+(finished?"finished":"cancelled"));
+ if(logMINOR) Logger.minor(this, "Already
"+(finished?"finished":"cancelled"));
return;
}
if(!insertedManifest) {
- Logger.minor(this, "Haven't inserted manifest");
+ if(logMINOR) Logger.minor(this, "Haven't
inserted manifest");
return;
}
finished = true;
@@ -528,20 +534,21 @@
}
public void onSuccess(ClientPutState state) {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
synchronized(this) {
metadataPuttersByMetadata.remove(state.getToken());
if(!metadataPuttersByMetadata.isEmpty()) {
- Logger.minor(this, "Still running metadata
putters: "+metadataPuttersByMetadata.size());
+ if(logMINOR) Logger.minor(this, "Still running
metadata putters: "+metadataPuttersByMetadata.size());
return;
}
Logger.minor(this, "Inserted manifest successfully on
"+this);
insertedManifest = true;
if(finished) {
- Logger.minor(this, "Already finished");
+ if(logMINOR) Logger.minor(this, "Already
finished");
return;
}
if(!insertedAllFiles) {
- Logger.minor(this, "Not inserted all files");
+ if(logMINOR) Logger.minor(this, "Not inserted
all files");
return;
}
finished = true;
@@ -550,26 +557,27 @@
}
public void onFailure(InserterException e, ClientPutState state) {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
fail(e);
}
public void onEncode(BaseClientKey key, ClientPutState state) {
if(state.getToken() == baseMetadata) {
this.finalURI = key.getURI();
- Logger.minor(this, "Got metadata key: "+finalURI);
+ if(logMINOR) Logger.minor(this, "Got metadata key:
"+finalURI);
cb.onGeneratedURI(finalURI, this);
} else {
// It's a sub-Metadata
Metadata m = (Metadata) state.getToken();
m.resolve(key.getURI());
- Logger.minor(this, "Resolved "+m+" : "+key.getURI());
+ if(logMINOR) Logger.minor(this, "Resolved "+m+" :
"+key.getURI());
resolveAndStartBase();
}
}
public void onTransition(ClientPutState oldState, ClientPutState
newState) {
synchronized(this) {
- Logger.minor(this, "Transition: "+oldState+" ->
"+newState);
+ if(logMINOR) Logger.minor(this, "Transition:
"+oldState+" -> "+newState);
}
}
Modified: trunk/freenet/src/freenet/client/async/SingleBlockInserter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SingleBlockInserter.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/client/async/SingleBlockInserter.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -26,6 +26,7 @@
*/
public class SingleBlockInserter implements SendableInsert, ClientPutState {
+ private static boolean logMINOR;
final Bucket sourceData;
final short compressionCodec;
final FreenetURI uri; // uses essentially no RAM in the common case of
a CHK because we use FreenetURI.EMPTY_CHK_URI
@@ -67,6 +68,7 @@
parent.addMustSucceedBlocks(1);
parent.notifyClients();
}
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
}
protected ClientKeyBlock innerEncode() throws InserterException {
@@ -157,13 +159,13 @@
if(e.code == LowLevelPutException.ROUTE_NOT_FOUND) {
consecutiveRNFs++;
if(consecutiveRNFs ==
ctx.consecutiveRNFsCountAsSuccess) {
- Logger.minor(this, "Consecutive RNFs:
"+consecutiveRNFs+" - counting as success");
+ if(logMINOR) Logger.minor(this, "Consecutive
RNFs: "+consecutiveRNFs+" - counting as success");
onSuccess();
return;
}
} else
consecutiveRNFs = 0;
- Logger.minor(this, "Failed: "+e);
+ if(logMINOR) Logger.minor(this, "Failed: "+e);
retries++;
if((retries > ctx.maxInsertRetries) && (ctx.maxInsertRetries !=
-1)) {
if(errors.isOneCodeOnly())
@@ -244,7 +246,7 @@
}
public void onSuccess() {
- Logger.minor(this, "Succeeded ("+this+"): "+token);
+ if(logMINOR) Logger.minor(this, "Succeeded ("+this+"): "+token);
synchronized(this) {
finished = true;
}
@@ -270,7 +272,7 @@
public void send(NodeClientCore core) {
try {
- Logger.minor(this, "Starting request: "+this);
+ if(logMINOR) Logger.minor(this, "Starting request:
"+this);
ClientKeyBlock b = getBlock();
if(b != null)
core.realPut(b, ctx.cacheLocalRequests);
@@ -278,10 +280,10 @@
fail(new
InserterException(InserterException.CANCELLED));
} catch (LowLevelPutException e) {
onFailure(e);
- Logger.minor(this, "Request failed: "+this+" for "+e);
+ if(logMINOR) Logger.minor(this, "Request failed:
"+this+" for "+e);
return;
}
- Logger.minor(this, "Request succeeded: "+this);
+ if(logMINOR) Logger.minor(this, "Request succeeded: "+this);
onSuccess();
}
Modified: trunk/freenet/src/freenet/client/async/SingleFileFetcher.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SingleFileFetcher.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/client/async/SingleFileFetcher.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -31,6 +31,7 @@
public class SingleFileFetcher extends BaseSingleFileFetcher implements
ClientGetState {
+ private static boolean logMINOR;
//final FreenetURI uri;
final LinkedList metaStrings;
final GetCompletionCallback rcb;
@@ -59,7 +60,8 @@
boolean dontTellClientGet, Object token, boolean
isEssential,
Bucket returnBucket) throws FetchException {
super(key, maxRetries, ctx, get);
- Logger.minor(this, "Creating SingleFileFetcher for "+key);
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "Creating SingleFileFetcher for
"+key);
this.cancelled = false;
this.returnBucket = returnBucket;
this.dontTellClientGet = dontTellClientGet;
@@ -85,7 +87,8 @@
* Used for things like slave fetchers for MultiLevelMetadata,
therefore does not remember returnBucket. */
public SingleFileFetcher(SingleFileFetcher fetcher, Metadata newMeta,
GetCompletionCallback callback, FetcherContext ctx2) throws FetchException {
super(fetcher.key, fetcher.maxRetries, ctx2, fetcher.parent);
- Logger.minor(this, "Creating SingleFileFetcher for
"+fetcher.key);
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "Creating SingleFileFetcher for
"+fetcher.key);
this.token = fetcher.token;
this.returnBucket = null;
this.dontTellClientGet = fetcher.dontTellClientGet;
@@ -188,14 +191,14 @@
private void handleMetadata() throws FetchException,
MetadataParseException, ArchiveFailureException, ArchiveRestartException {
while(true) {
if(metadata.isSimpleManifest()) {
- Logger.minor(this, "Is simple manifest");
+ if(logMINOR) Logger.minor(this, "Is simple
manifest");
String name;
if(metaStrings.isEmpty())
throw new
FetchException(FetchException.NOT_ENOUGH_METASTRINGS);
else
name = (String)
metaStrings.removeFirst();
// Since metadata is a document, we just
replace metadata here
- Logger.minor(this, "Next meta-string: "+name);
+ if(logMINOR) Logger.minor(this, "Next
meta-string: "+name);
if(name == null) {
metadata =
metadata.getDefaultDocument();
if(metadata == null)
@@ -208,7 +211,7 @@
}
continue; // loop
} else if(metadata.isArchiveManifest()) {
- Logger.minor(this, "Is archive manifest");
+ if(logMINOR) Logger.minor(this, "Is archive
manifest");
if(metaStrings.isEmpty() &&
ctx.returnZIPManifests) {
// Just return the archive, whole.
metadata.setSimpleRedirect();
@@ -235,16 +238,16 @@
}
continue;
} else if(metadata.isArchiveInternalRedirect()) {
- Logger.minor(this, "Is archive-internal
redirect");
+ if(logMINOR) Logger.minor(this, "Is
archive-internal redirect");
clientMetadata.mergeNoOverwrite(metadata.getClientMetadata());
// Fetch it from the archive
if(ah == null)
throw new
FetchException(FetchException.UNKNOWN_METADATA, "Archive redirect not in an
archive manifest");
String filename = metadata.getZIPInternalName();
- Logger.minor(this, "Fetching "+filename);
+ if(logMINOR) Logger.minor(this, "Fetching
"+filename);
Bucket dataBucket = ah.get(filename, actx,
null, recursionLevel+1, true);
if(dataBucket != null) {
- Logger.minor(this, "Returning data");
+ if(logMINOR) Logger.minor(this,
"Returning data");
// The client may free it, which is
bad, or it may hang on to it for so long that it gets
// freed by us, which is also bad.
// So copy it.
@@ -264,7 +267,7 @@
onSuccess(new
FetchResult(this.clientMetadata, out));
return;
} else {
- Logger.minor(this, "Fetching archive");
+ if(logMINOR) Logger.minor(this,
"Fetching archive");
// Metadata cannot contain pointers to
files which don't exist.
// We enforce this in ArchiveHandler.
// Therefore, the archive needs to be
fetched.
@@ -273,7 +276,7 @@
return;
}
} else if(metadata.isMultiLevelMetadata()) {
- Logger.minor(this, "Is multi-level metadata");
+ if(logMINOR) Logger.minor(this, "Is multi-level
metadata");
// Fetch on a second SingleFileFetcher, like
with archives.
Metadata newMeta = (Metadata) metadata.clone();
newMeta.setSimpleRedirect();
@@ -281,7 +284,7 @@
f.handleMetadata();
return;
} else if(metadata.isSingleFileRedirect()) {
- Logger.minor(this, "Is single-file redirect");
+ if(logMINOR) Logger.minor(this, "Is single-file
redirect");
clientMetadata.mergeNoOverwrite(metadata.getClientMetadata()); // even
splitfiles can have mime types!
// FIXME implement implicit archive support
@@ -290,7 +293,7 @@
// Which will then fetch the target URI, and
call the rcd.success
// Hopefully!
FreenetURI uri = metadata.getSingleTarget();
- Logger.minor(this, "Redirecting to "+uri);
+ if(logMINOR) Logger.minor(this, "Redirecting to
"+uri);
ClientKey key;
try {
BaseClientKey k =
BaseClientKey.getBaseKey(uri);
@@ -324,7 +327,7 @@
// All done! No longer our problem!
return;
} else if(metadata.isSplitfile()) {
- Logger.minor(this, "Fetching splitfile");
+ if(logMINOR) Logger.minor(this, "Fetching
splitfile");
// FIXME implicit archive support
clientMetadata.mergeNoOverwrite(metadata.getClientMetadata()); // even
splitfiles can have mime types!
@@ -471,7 +474,7 @@
// Real onFailure
protected void onFailure(FetchException e, boolean forceFatal) {
if(parent.isCancelled() || cancelled) {
- Logger.minor(this, "Failing: cancelled");
+ if(logMINOR) Logger.minor(this, "Failing: cancelled");
e = new FetchException(FetchException.CANCELLED);
forceFatal = true;
}
Modified: trunk/freenet/src/freenet/client/async/SingleFileInserter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SingleFileInserter.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/client/async/SingleFileInserter.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -34,6 +34,7 @@
// Config option???
private static final long COMPRESS_OFF_THREAD_LIMIT = 65536;
+ private static boolean logMINOR;
final BaseClientPutter parent;
final InsertBlock block;
final InserterContext ctx;
@@ -73,6 +74,7 @@
this.getCHKOnly = getCHKOnly;
this.insertAsArchiveManifest = insertAsArchiveManifest;
this.freeData = freeData;
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
}
public void start(SimpleFieldSet fs) throws InserterException {
@@ -96,7 +98,7 @@
// Run off thread
OffThreadCompressor otc = new OffThreadCompressor();
Thread t = new Thread(otc, "Compressor for "+this);
- Logger.minor(this, "Compressing off-thread: "+t);
+ if(logMINOR) Logger.minor(this, "Compressing
off-thread: "+t);
t.setDaemon(true);
t.start();
} else {
@@ -176,7 +178,7 @@
if(parent == cb) {
ctx.eventProducer.produceEvent(new
FinishedCompressionEvent(bestCodec == null ? -1 :
bestCodec.codecNumberForMetadata(), origSize, data.size()));
- Logger.minor(this, "Compressed "+origSize+" to
"+data.size()+" on "+this);
+ if(logMINOR) Logger.minor(this, "Compressed
"+origSize+" to "+data.size()+" on "+this);
}
// Compressed data
@@ -310,7 +312,7 @@
throw new ResumeException("No
SplitFileInserter");
ClientPutState newSFI, newMetaPutter = null;
newSFI = new SplitFileInserter(parent, this,
forceMetadata ? null : block.clientMetadata, ctx, getCHKOnly, meta, token,
insertAsArchiveManifest, sfiFS);
- Logger.minor(this, "Starting "+newSFI+" for "+this);
+ if(logMINOR) Logger.minor(this, "Starting "+newSFI+"
for "+this);
fs.removeSubset("SplitFileInserter");
SimpleFieldSet metaFS = fs.subset("MetadataPutter");
if(metaFS != null) {
@@ -330,7 +332,7 @@
// Will be reconstructed later
}
}
- Logger.minor(this, "Metadata putter "+metadataPutter+"
for "+this);
+ if(logMINOR) Logger.minor(this, "Metadata putter
"+metadataPutter+" for "+this);
fs.removeSubset("MetadataPutter");
synchronized(this) {
sfi = newSFI;
@@ -350,28 +352,29 @@
}
public void onSuccess(ClientPutState state) {
- Logger.minor(this, "onSuccess("+state+") for "+this);
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "onSuccess("+state+")
for "+this);
boolean lateStart = false;
synchronized(this) {
if(finished) return;
if(state == sfi) {
- Logger.minor(this, "Splitfile insert
succeeded for "+this+" : "+state);
+ if(logMINOR) Logger.minor(this,
"Splitfile insert succeeded for "+this+" : "+state);
splitInsertSuccess = true;
if(!metaInsertSuccess &&
!metaInsertStarted) {
Logger.error(this, "Splitfile
insert succeeded but metadata not started, starting anyway...
"+metadataPutter+" for "+this+" ( "+sfi+" )");
metaInsertStarted = true;
lateStart = true;
} else {
- Logger.minor(this, "Metadata
already started for "+this+" : success="+metaInsertSuccess+"
started="+metaInsertStarted);
+ if(logMINOR) Logger.minor(this,
"Metadata already started for "+this+" : success="+metaInsertSuccess+"
started="+metaInsertStarted);
}
} else if(state == metadataPutter) {
- Logger.minor(this, "Metadata insert
succeeded for "+this+" : "+state);
+ if(logMINOR) Logger.minor(this,
"Metadata insert succeeded for "+this+" : "+state);
metaInsertSuccess = true;
} else {
Logger.error(this, "Unknown: "+state+"
for "+this, new Exception("debug"));
}
if(splitInsertSuccess && metaInsertSuccess) {
- Logger.minor(this, "Both succeeded for
"+this);
+ if(logMINOR) Logger.minor(this, "Both
succeeded for "+this);
finished = true;
}
}
@@ -437,7 +440,7 @@
metadataPutter = new
SingleFileInserter(parent, this, newBlock, true, ctx, false, getCHKOnly, false,
token, false, true);
if(!dataFetchable) return;
}
- Logger.minor(this, "Putting metadata on
"+metadataPutter+" from "+sfi+" ("+((SplitFileInserter)sfi).getLength()+")");
+ if(logMINOR) Logger.minor(this, "Putting
metadata on "+metadataPutter+" from "+sfi+"
("+((SplitFileInserter)sfi).getLength()+")");
} catch (InserterException e1) {
cb.onFailure(e1, this);
return;
@@ -446,7 +449,7 @@
}
private void fail(InserterException e) {
- Logger.minor(this, "Failing: "+e, e);
+ if(logMINOR) Logger.minor(this, "Failing: "+e, e);
ClientPutState oldSFI = null;
ClientPutState oldMetadataPutter = null;
synchronized(this) {
@@ -524,7 +527,9 @@
}
public void onFetchable(ClientPutState state) {
-
+
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+
boolean meta;
synchronized(this) {
@@ -557,14 +562,14 @@
ClientPutState putter;
synchronized(this) {
if(metadataPutter == null) {
- Logger.minor(this, "Cannot
start metadata yet: no metadataPutter");
+ if(logMINOR) Logger.minor(this,
"Cannot start metadata yet: no metadataPutter");
return;
}
putter = metadataPutter;
}
- Logger.minor(this, "Starting metadata inserter:
"+putter+" for "+this);
+ if(logMINOR) Logger.minor(this, "Starting
metadata inserter: "+putter+" for "+this);
putter.schedule();
- Logger.minor(this, "Started metadata inserter:
"+putter+" for "+this);
+ if(logMINOR) Logger.minor(this, "Started
metadata inserter: "+putter+" for "+this);
} catch (InserterException e1) {
Logger.error(this, "Failing "+this+" : "+e1,
e1);
fail(e1);
Modified: trunk/freenet/src/freenet/client/async/SplitFileFetcher.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SplitFileFetcher.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/client/async/SplitFileFetcher.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -106,7 +106,8 @@
// Will be segmented.
} else throw new MetadataParseException("Unknown splitfile
format: "+splitfileType);
this.maxTempLength = fetchContext.maxTempLength;
- Logger.minor(this, "Algorithm: "+splitfileType+", blocks per
segment: "+blocksPerSegment+", check blocks per segment:
"+checkBlocksPerSegment+", segments: "+segmentCount);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Algorithm: "+splitfileType+",
blocks per segment: "+blocksPerSegment+", check blocks per segment:
"+checkBlocksPerSegment+", segments: "+segmentCount);
segments = new SplitFileFetcherSegment[segmentCount]; //
initially null on all entries
if(segmentCount == 1) {
segments[0] = new
SplitFileFetcherSegment(splitfileType, splitfileDataBlocks,
splitfileCheckBlocks, this, archiveContext, fetchContext, maxTempLength,
splitUseLengths, recursionLevel);
@@ -180,13 +181,14 @@
}
public void segmentFinished(SplitFileFetcherSegment segment) {
- Logger.minor(this, "Finished segment: "+segment);
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "Finished segment: "+segment);
boolean finish = false;
synchronized(this) {
boolean allDone = true;
for(int i=0;i<segments.length;i++)
if(!segments[i].isFinished()) {
- Logger.minor(this, "Segment
"+segments[i]+" is not finished");
+ if(logMINOR) Logger.minor(this,
"Segment "+segments[i]+" is not finished");
allDone = false;
}
if(allDone) {
Modified: trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/client/async/SplitFileFetcherSegment.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -23,7 +23,8 @@
* This in turn controls a large number of SingleFileFetcher's.
*/
public class SplitFileFetcherSegment implements GetCompletionCallback {
-
+
+ private static boolean logMINOR;
final short splitfileType;
final FreenetURI[] dataBlocks;
final FreenetURI[] checkBlocks;
@@ -54,6 +55,7 @@
private boolean createdFetchers;
public SplitFileFetcherSegment(short splitfileType, FreenetURI[]
splitfileDataBlocks, FreenetURI[] splitfileCheckBlocks, SplitFileFetcher
fetcher, ArchiveContext archiveContext, FetcherContext fetchContext, long
maxTempLength, boolean splitUseLengths, int recursionLevel) throws
MetadataParseException, FetchException {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
this.parentFetcher = fetcher;
this.errors = new FailureCodeTracker(false);
this.archiveContext = archiveContext;
@@ -86,7 +88,7 @@
blockFetchContext = new FetcherContext(fetcherContext,
FetcherContext.SPLITFILE_DEFAULT_BLOCK_MASK, true);
this.recursionLevel = 0;
}
- Logger.minor(this, "Created "+this+" for "+parentFetcher);
+ if(logMINOR) Logger.minor(this, "Created "+this+" for
"+parentFetcher);
}
public synchronized boolean isFinished() {
@@ -135,6 +137,7 @@
}
public synchronized void onSuccess(FetchResult result, ClientGetState
state) {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
if(finished) return;
Integer token = (Integer) ((SingleFileFetcher)state).getToken();
int blockNo = token.intValue();
@@ -184,7 +187,7 @@
public void run() {
// Now decode
- Logger.minor(this, "Decoding "+this);
+ if(logMINOR) Logger.minor(this, "Decoding "+this);
boolean[] dataBlocksSucceeded = new
boolean[dataBuckets.length];
boolean[] checkBlocksSucceeded = new
boolean[checkBuckets.length];
@@ -202,21 +205,21 @@
}
decodedData =
fetcherContext.bucketFactory.makeBucket(-1);
- Logger.minor(this, "Copying data from data
blocks");
+ if(logMINOR) Logger.minor(this, "Copying data
from data blocks");
OutputStream os = decodedData.getOutputStream();
for(int i=0;i<dataBlockStatus.length;i++) {
SplitfileBlock status = dataBuckets[i];
Bucket data = status.getData();
BucketTools.copyTo(data, os,
Long.MAX_VALUE);
}
- Logger.minor(this, "Copied data");
+ if(logMINOR) Logger.minor(this, "Copied data");
os.close();
// Must set finished BEFORE calling
parentFetcher.
// Otherwise a race is possible that might
result in it not seeing our finishing.
finished = true;
parentFetcher.segmentFinished(SplitFileFetcherSegment.this);
} catch (IOException e) {
- Logger.minor(this, "Caught bucket error?: "+e,
e);
+ Logger.normal(this, "Caught bucket error?: "+e,
e);
finished = true;
failureException = new
FetchException(FetchException.BUCKET_ERROR);
parentFetcher.segmentFinished(SplitFileFetcherSegment.this);
@@ -278,12 +281,13 @@
}
private void queueHeal(Bucket data) {
- Logger.minor(this, "Queueing healing insert");
+ if(logMINOR) Logger.minor(this, "Queueing healing insert");
fetcherContext.healingQueue.queue(data);
}
/** This is after any retries and therefore is either out-of-retries or
fatal */
public synchronized void onFailure(FetchException e, ClientGetState
state) {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
Integer token = (Integer) ((SingleFileFetcher)state).getToken();
int blockNo = token.intValue();
if(blockNo < dataBlocks.length) {
@@ -302,7 +306,7 @@
} else
Logger.error(this, "Unrecognized block number:
"+blockNo, new Exception("error"));
// :(
- Logger.minor(this, "Permanently failed block: "+state+" on
"+this);
+ if(logMINOR) Logger.minor(this, "Permanently failed block:
"+state+" on "+this);
if(e.isFatal())
fatallyFailedBlocks++;
else
Modified: trunk/freenet/src/freenet/client/async/SplitFileInserter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SplitFileInserter.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/client/async/SplitFileInserter.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -18,7 +18,8 @@
import freenet.support.io.BucketTools;
public class SplitFileInserter implements ClientPutState {
-
+
+ private static boolean logMINOR;
final BaseClientPutter parent;
final InserterContext ctx;
final PutCompletionCallback cb;
@@ -60,6 +61,7 @@
}
public SplitFileInserter(BaseClientPutter put, PutCompletionCallback
cb, Bucket data, Compressor bestCodec, ClientMetadata clientMetadata,
InserterContext ctx, boolean getCHKOnly, boolean isMetadata, Object token,
boolean insertAsArchiveManifest, boolean freeData) throws InserterException {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
this.parent = put;
this.insertAsArchiveManifest = insertAsArchiveManifest;
this.token = token;
@@ -96,6 +98,7 @@
}
public SplitFileInserter(BaseClientPutter parent, PutCompletionCallback
cb, ClientMetadata clientMetadata, InserterContext ctx, boolean getCHKOnly,
boolean metadata, Object token, boolean insertAsArchiveManifest, SimpleFieldSet
fs) throws ResumeException {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
this.parent = parent;
this.insertAsArchiveManifest = insertAsArchiveManifest;
this.token = token;
@@ -221,7 +224,7 @@
}
public void encodedSegment(SplitFileInserterSegment segment) {
- Logger.minor(this, "Encoded segment "+segment.segNo+" of
"+this);
+ if(logMINOR) Logger.minor(this, "Encoded segment
"+segment.segNo+" of "+this);
synchronized(this) {
for(int i=0;i<segments.length;i++) {
if((segments[i] == null) ||
!segments[i].isEncoded())
@@ -234,7 +237,7 @@
}
public void segmentHasURIs(SplitFileInserterSegment segment) {
- Logger.minor(this, "Segment has URIs: "+segment);
+ if(logMINOR) Logger.minor(this, "Segment has URIs: "+segment);
synchronized(this) {
if(haveSentMetadata) {
return;
@@ -242,13 +245,13 @@
for(int i=0;i<segments.length;i++) {
if(!segments[i].hasURIs()) {
- Logger.minor(this, "Segment does not
have URIs: "+segments[i]);
+ if(logMINOR) Logger.minor(this,
"Segment does not have URIs: "+segments[i]);
return;
}
}
}
- Logger.minor(this, "Have URIs from all segments");
+ if(logMINOR) Logger.minor(this, "Have URIs from all segments");
encodeMetadata();
}
@@ -260,7 +263,7 @@
FreenetURI[] dataURIs = getDataURIs();
FreenetURI[] checkURIs = getCheckURIs();
- Logger.minor(this, "Data URIs: "+dataURIs.length+",
check URIs: "+checkURIs.length);
+ if(logMINOR) Logger.minor(this, "Data URIs:
"+dataURIs.length+", check URIs: "+checkURIs.length);
missingURIs = anyNulls(dataURIs) || anyNulls(checkURIs);
@@ -271,7 +274,7 @@
haveSentMetadata = true;
}
if(missingURIs) {
- Logger.minor(this, "Missing URIs");
+ if(logMINOR) Logger.minor(this, "Missing URIs");
// Error
fail(new
InserterException(InserterException.INTERNAL_ERROR, "Missing URIs after
encoding", null));
return;
@@ -335,18 +338,18 @@
}
public void segmentFinished(SplitFileInserterSegment segment) {
- Logger.minor(this, "Segment finished: "+segment, new
Exception("debug"));
+ if(logMINOR) Logger.minor(this, "Segment finished: "+segment,
new Exception("debug"));
boolean allGone = true;
if(countDataBlocks > 32)
parent.onMajorProgress();
synchronized(this) {
if(finished) {
- Logger.minor(this, "Finished already");
+ if(logMINOR) Logger.minor(this, "Finished
already");
return;
}
for(int i=0;i<segments.length;i++) {
if(!segments[i].isFinished()) {
- Logger.minor(this, "Segment not
finished: "+i+": "+segments[i]);
+ if(logMINOR) Logger.minor(this,
"Segment not finished: "+i+": "+segments[i]);
allGone = false;
break;
}
@@ -364,13 +367,13 @@
}
public void segmentFetchable(SplitFileInserterSegment segment) {
- Logger.minor(this, "Segment fetchable: "+segment);
+ if(logMINOR) Logger.minor(this, "Segment fetchable: "+segment);
synchronized(this) {
if(finished) return;
if(fetchable) return;
for(int i=0;i<segments.length;i++) {
if(!segments[i].isFetchable()) {
- Logger.minor(this, "Segment not
fetchable: "+i+": "+segments[i]);
+ if(logMINOR) Logger.minor(this,
"Segment not fetchable: "+i+": "+segments[i]);
return;
}
}
@@ -380,7 +383,7 @@
}
private void onAllFinished() {
- Logger.minor(this, "All finished");
+ if(logMINOR) Logger.minor(this, "All finished");
try {
// Finished !!
FailureCodeTracker tracker = new
FailureCodeTracker(true);
@@ -388,7 +391,7 @@
for(int i=0;i<segments.length;i++) {
InserterException e =
segments[i].getException();
if(e == null) continue;
- Logger.minor(this, "Failure on segment "+i+" :
"+segments[i]+" : "+e, e);
+ if(logMINOR) Logger.minor(this, "Failure on
segment "+i+" : "+segments[i]+" : "+e, e);
allSucceeded = false;
if(e.errorCodes != null)
tracker.merge(e.errorCodes);
Modified: trunk/freenet/src/freenet/client/async/SplitFileInserterSegment.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SplitFileInserterSegment.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/client/async/SplitFileInserterSegment.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -21,6 +21,7 @@
public class SplitFileInserterSegment implements PutCompletionCallback {
+ private static boolean logMINOR;
final SplitFileInserter parent;
final FECCodec splitfileAlgo;
final Bucket[] dataBlocks;
@@ -42,6 +43,7 @@
private boolean started;
public SplitFileInserterSegment(SplitFileInserter parent, FECCodec
splitfileAlgo, Bucket[] origDataBlocks, InserterContext blockInsertContext,
boolean getCHKOnly, int segNo) {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
this.parent = parent;
this.getCHKOnly = getCHKOnly;
this.errors = new FailureCodeTracker(true);
@@ -251,16 +253,16 @@
Bucket data = dataBlocks[i];
if(data == null && finished) {
// Ignore
- Logger.minor(this, "Could not save to disk:
null");
+ if(logMINOR) Logger.minor(this, "Could not save
to disk: null");
} else if(data instanceof SerializableToFieldSetBucket)
{
SimpleFieldSet tmp =
((SerializableToFieldSetBucket)data).toFieldSet();
if(tmp == null) {
- Logger.minor(this, "Could not save to
disk: "+data);
+ if(logMINOR) Logger.minor(this, "Could
not save to disk: "+data);
return null;
}
block.put("Data", tmp);
} else {
- Logger.minor(this, "Could not save to disk (not
serializable to fieldset): "+data);
+ if(logMINOR) Logger.minor(this, "Could not save
to disk (not serializable to fieldset): "+data);
return null;
}
if(!block.isEmpty())
@@ -302,7 +304,7 @@
}
public void start() throws InserterException {
- Logger.minor(this, "Starting segment "+segNo+" of "+parent+"
("+parent.dataLength+"): "+this+" ( finished="+finished+" encoded="+encoded+"
hasURIs="+hasURIs+")");
+ if(logMINOR) Logger.minor(this, "Starting segment "+segNo+" of
"+parent+" ("+parent.dataLength+"): "+this+" ( finished="+finished+"
encoded="+encoded+" hasURIs="+hasURIs+")");
boolean fin = true;
for(int i=0;i<dataBlockInserters.length;i++) {
@@ -318,9 +320,9 @@
//parent.parent.notifyClients();
started = true;
if(!encoded) {
- Logger.minor(this, "Segment "+segNo+" of "+parent+"
("+parent.dataLength+") is not encoded");
+ if(logMINOR) Logger.minor(this, "Segment "+segNo+" of
"+parent+" ("+parent.dataLength+") is not encoded");
if(splitfileAlgo != null) {
- Logger.minor(this, "Encoding segment "+segNo+"
of "+parent+" ("+parent.dataLength+")");
+ if(logMINOR) Logger.minor(this, "Encoding
segment "+segNo+" of "+parent+" ("+parent.dataLength+")");
// Encode blocks
Thread t = new Thread(new
EncodeBlocksRunnable(), "Blocks encoder for "+this);
t.setDaemon(true);
@@ -409,7 +411,7 @@
}
private void finish(InserterException ex) {
- Logger.minor(this, "Finishing "+this+" with "+ex, ex);
+ if(logMINOR) Logger.minor(this, "Finishing "+this+" with "+ex,
ex);
synchronized(this) {
if(finished) return;
finished = true;
@@ -494,7 +496,7 @@
* blocks.
*/
private synchronized int innerCompleted(int x) {
- Logger.minor(this, "Completed: "+x+" on "+this+" (
completed="+blocksCompleted+",
total="+(dataBlockInserters.length+checkBlockInserters.length));
+ if(logMINOR) Logger.minor(this, "Completed: "+x+" on "+this+" (
completed="+blocksCompleted+",
total="+(dataBlockInserters.length+checkBlockInserters.length));
if(finished) return -1;
if(x >= dataBlocks.length) {
Modified: trunk/freenet/src/freenet/client/async/USKChecker.java
===================================================================
--- trunk/freenet/src/freenet/client/async/USKChecker.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/client/async/USKChecker.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -17,7 +17,8 @@
USKChecker(USKCheckerCallback cb, ClientKey key, int maxRetries,
FetcherContext ctx, ClientRequester parent) {
super(key, maxRetries, ctx, parent);
- Logger.minor(this, "Created USKChecker for "+key);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Created USKChecker for "+key);
this.cb = cb;
}
@@ -26,7 +27,8 @@
}
public void onFailure(LowLevelGetException e) {
- Logger.minor(this, "onFailure: "+e+" for "+this);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "onFailure: "+e+" for "+this);
// Firstly, can we retry?
boolean canRetry;
switch(e.code) {
Modified: trunk/freenet/src/freenet/client/async/USKFetcher.java
===================================================================
--- trunk/freenet/src/freenet/client/async/USKFetcher.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/client/async/USKFetcher.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -59,6 +59,8 @@
*/
public class USKFetcher implements ClientGetState {
+ private static boolean logMINOR;
+
/** USK manager */
private final USKManager uskManager;
@@ -212,10 +214,12 @@
this.ctx = ctx;
this.backgroundPoll = pollForever;
this.keepLastData = keepLastData;
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
}
void onDNF(USKAttempt att) {
- Logger.minor(this, "DNF: "+att);
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "DNF: "+att);
boolean finished = false;
long curLatest = uskManager.lookup(origUSK);
synchronized(this) {
@@ -223,12 +227,11 @@
lastFetchedEdition = Math.max(lastFetchedEdition,
att.number);
runningAttempts.remove(att);
if(runningAttempts.isEmpty()) {
- Logger.minor(this, "latest: "+curLatest+", last
fetched: "+lastFetchedEdition+", curLatest+MIN_FAILURES:
"+(curLatest+minFailures));
+ if(logMINOR) Logger.minor(this, "latest:
"+curLatest+", last fetched: "+lastFetchedEdition+", curLatest+MIN_FAILURES:
"+(curLatest+minFailures));
if(started) {
finished = true;
}
- } else
- Logger.minor(this, "Remaining:
"+runningAttempts.size());
+ } else if(logMINOR) Logger.minor(this, "Remaining:
"+runningAttempts.size());
}
if(finished) {
finishSuccess();
@@ -292,6 +295,7 @@
}
void onSuccess(USKAttempt att, boolean dontUpdate, ClientSSKBlock
block) {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
LinkedList l = null;
long lastEd = uskManager.lookup(origUSK);
synchronized(this) {
@@ -316,14 +320,14 @@
}
}
curLatest = Math.max(lastEd, curLatest);
- Logger.minor(this, "Latest: "+curLatest);
+ if(logMINOR) Logger.minor(this, "Latest: "+curLatest);
long addTo = curLatest + minFailures;
long addFrom = Math.max(lastAddedEdition + 1, curLatest
+ 1);
- Logger.minor(this, "Adding from "+addFrom+" to
"+addTo+" for "+origUSK);
+ if(logMINOR) Logger.minor(this, "Adding from
"+addFrom+" to "+addTo+" for "+origUSK);
if(addTo >= addFrom) {
l = new LinkedList();
for(long i=addFrom;i<=addTo;i++) {
- Logger.minor(this, "Adding checker for
edition "+i+" for "+origUSK);
+ if(logMINOR) Logger.minor(this, "Adding
checker for edition "+i+" for "+origUSK);
l.add(add(i));
}
}
@@ -388,18 +392,18 @@
*/
private synchronized USKAttempt add(long i) {
if(cancelled) return null;
- Logger.minor(this, "Adding USKAttempt for "+i+" for
"+origUSK.getURI());
+ if(logMINOR) Logger.minor(this, "Adding USKAttempt for "+i+"
for "+origUSK.getURI());
if(!runningAttempts.isEmpty()) {
USKAttempt last = (USKAttempt)
runningAttempts.lastElement();
if(last.number >= i) {
- Logger.minor(this, "Returning because
last.number="+i+" for "+origUSK.getURI());
+ if(logMINOR) Logger.minor(this, "Returning
because last.number="+i+" for "+origUSK.getURI());
return null;
}
}
USKAttempt a = new USKAttempt(i);
runningAttempts.add(a);
lastAddedEdition = i;
- Logger.minor(this, "Added "+a+" for "+origUSK);
+ if(logMINOR) Logger.minor(this, "Added "+a+" for "+origUSK);
return a;
}
Modified: trunk/freenet/src/freenet/client/async/USKInserter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/USKInserter.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/client/async/USKInserter.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -67,7 +67,8 @@
* including author errors and so on.
*/
private synchronized void scheduleFetcher() {
- Logger.minor(this, "scheduling fetcher for "+pubUSK.getURI());
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "scheduling fetcher for
"+pubUSK.getURI());
if(finished) return;
fetcher =
ctx.uskManager.getFetcherForInsertDontSchedule(pubUSK, parent.priorityClass,
this);
@@ -103,7 +104,8 @@
long edNo = Math.max(edition, ctx.uskManager.lookup(pubUSK))+1;
if(finished) return;
edition = edNo;
- Logger.minor(this, "scheduling insert for "+pubUSK.getURI()+"
"+edition);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "scheduling insert for
"+pubUSK.getURI()+" "+edition);
sbi = new SingleBlockInserter(parent, data, compressionCodec,
privUSK.getInsertableSSK(edition).getInsertURI(),
ctx, this, isMetadata, sourceLength, token,
getCHKOnly, false, true /* we don't use it */, tokenObject);
try {
@@ -123,7 +125,8 @@
if(!targetURI.equals(realURI))
Logger.error(this, "URI should be "+targetURI+"
actually is "+realURI);
else {
- Logger.minor(this, "URI should be "+targetURI+"
actually is "+realURI);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "URI should be "+targetURI+"
actually is "+realURI);
ctx.uskManager.update(pubUSK, edition);
}
// FINISHED!!!! Yay!!!
Modified: trunk/freenet/src/freenet/client/async/USKManager.java
===================================================================
--- trunk/freenet/src/freenet/client/async/USKManager.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/client/async/USKManager.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -116,7 +116,8 @@
fetcher.cancel();
backgroundFetchersByClearUSK.remove(fetcher);
} else {
- Logger.minor(this, "Allowing temporary
background fetcher to continue as it has subscribers... "+fetcher);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Allowing
temporary background fetcher to continue as it has subscribers... "+fetcher);
// It will burn itself out anyway as
it's a temp fetcher, so no big harm here.
fetcher.killOnLoseSubscribers();
}
@@ -131,16 +132,17 @@
}
void update(USK origUSK, long number) {
- Logger.minor(this, "Updating "+origUSK.getURI()+" : "+number);
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "Updating "+origUSK.getURI()+"
: "+number);
USK clear = origUSK.clearCopy();
USKCallback[] callbacks;
synchronized(this) {
Long l = (Long) latestVersionByClearUSK.get(clear);
- Logger.minor(this, "Old value: "+l);
+ if(logMINOR) Logger.minor(this, "Old value: "+l);
if((l == null) || (number > l.longValue())) {
l = new Long(number);
latestVersionByClearUSK.put(clear, l);
- Logger.minor(this, "Put "+number);
+ if(logMINOR) Logger.minor(this, "Put "+number);
} else return;
callbacks = (USKCallback[])
subscribersByClearUSK.get(clear);
}
Modified: trunk/freenet/src/freenet/clients/http/ConfigToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/ConfigToadlet.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/clients/http/ConfigToadlet.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -59,6 +59,8 @@
return;
}
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
+
for(int i=0; i<sc.length ; i++){
Option[] o = sc[i].getOptions();
String prefix = new String(sc[i].getPrefix());
@@ -66,12 +68,12 @@
for(int j=0; j<o.length; j++){
configName=o[j].getName();
- Logger.minor(this, "Setting
"+prefix+"."+configName);
+ if(logMINOR) Logger.minor(this, "Setting
"+prefix+"."+configName);
// we ignore unreconized parameters
if(request.isParameterSet(prefix+"."+configName)) {
if(!(o[j].getValueString().equals(request.getParam(prefix+"."+configName)))){
- Logger.minor(this, "Setting
"+prefix+"."+configName+" to "+request.getParam(prefix+"."+configName));
+ if(logMINOR) Logger.minor(this,
"Setting "+prefix+"."+configName+" to
"+request.getParam(prefix+"."+configName));
try{
o[j].setValue(request.getParam(prefix+"."+configName));
}catch(Exception e){
Modified: trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/clients/http/DarknetConnectionsToadlet.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -499,12 +499,14 @@
HTTPRequest request = new HTTPRequest(uri, data, ctx);
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
+
String pass = request.getPartAsString("formPassword", 32);
if((pass == null) || !pass.equals(core.formPassword)) {
MultiValueTable headers = new MultiValueTable();
headers.put("Location", "/darknet/");
ctx.sendReplyHeaders(302, "Found", headers, null, 0);
- Logger.minor(this, "No password");
+ if(logMINOR) Logger.minor(this, "No password");
return;
}
@@ -703,15 +705,15 @@
} else if (request.isPartSet("remove") ||
(request.isPartSet("submit") &&
request.getPartAsString("action",25).equals("remove"))) {
//int hashcode =
Integer.decode(request.getParam("node")).intValue();
- Logger.minor(this, "Remove node");
+ if(logMINOR) Logger.minor(this, "Remove node");
PeerNode[] peerNodes = node.getDarknetConnections();
for(int i = 0; i < peerNodes.length; i++) {
if
(request.isPartSet("node_"+peerNodes[i].hashCode())) {
this.node.removeDarknetConnection(peerNodes[i]);
- Logger.minor(this, "Removed node:
node_"+peerNodes[i].hashCode());
+ if(logMINOR) Logger.minor(this,
"Removed node: node_"+peerNodes[i].hashCode());
} else {
- Logger.minor(this, "Part not set:
node_"+peerNodes[i].hashCode());
+ if(logMINOR) Logger.minor(this, "Part
not set: node_"+peerNodes[i].hashCode());
}
}
MultiValueTable headers = new MultiValueTable();
Modified: trunk/freenet/src/freenet/clients/http/FProxyToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/FProxyToadlet.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/clients/http/FProxyToadlet.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -210,7 +210,8 @@
return;
}
try {
- Logger.minor(this, "FProxy fetching "+key+"
("+maxSize+")");
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "FProxy fetching "+key+"
("+maxSize+")");
FetchResult result = fetch(key, maxSize);
// Now, is it safe?
Modified: trunk/freenet/src/freenet/clients/http/HTTPRequest.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/HTTPRequest.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/clients/http/HTTPRequest.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -155,7 +155,8 @@
*/
private void parseRequestParameters(String queryString, boolean
doUrlDecoding) {
- Logger.minor(this, "queryString is "+queryString+",
doUrlDecoding="+doUrlDecoding);
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "queryString is
"+queryString+", doUrlDecoding="+doUrlDecoding);
// nothing to do if there was no query string in the URI
if ((queryString == null) || (queryString.length() == 0)) {
@@ -167,7 +168,7 @@
while (tokenizer.hasMoreTokens()) {
String nameValueToken = tokenizer.nextToken();
- Logger.minor(this, "Token: "+nameValueToken);
+ if(logMINOR) Logger.minor(this, "Token:
"+nameValueToken);
// a token can be either a name, or a name value pair...
String name = null;
@@ -176,17 +177,17 @@
if (indexOfEqualsChar < 0) {
// ...it's only a name, so the value stays
emptys
name = nameValueToken;
- Logger.minor(this, "Name: "+name);
+ if(logMINOR) Logger.minor(this, "Name: "+name);
} else if (indexOfEqualsChar == nameValueToken.length()
- 1) {
// ...it's a name with an empty value, so
remove the '='
// character
name = nameValueToken.substring(0,
indexOfEqualsChar);
- Logger.minor(this, "Name: "+name);
+ if(logMINOR) Logger.minor(this, "Name: "+name);
} else {
// ...it's a name value pair, split into name
and value
name = nameValueToken.substring(0,
indexOfEqualsChar);
value =
nameValueToken.substring(indexOfEqualsChar + 1);
- Logger.minor(this, "Name: "+name+" Value:
"+value);
+ if(logMINOR) Logger.minor(this, "Name: "+name+"
Value: "+value);
}
// url-decode the name and value
@@ -194,8 +195,10 @@
if (doUrlDecoding) {
name = URLDecoder.decode(name);
value = URLDecoder.decode(value);
- Logger.minor(this, "Decoded name:
"+name);
- Logger.minor(this, "Decoded value:
"+value);
+ if(logMINOR) {
+ Logger.minor(this, "Decoded
name: "+name);
+ Logger.minor(this, "Decoded
value: "+value);
+ }
}
// get the list of values for this parameter
that were parsed so
Modified: trunk/freenet/src/freenet/clients/http/NinjaSpider.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/NinjaSpider.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/clients/http/NinjaSpider.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -538,8 +538,8 @@
return;
}
-
- Logger.minor(this, "Spider: indexes regenerated.");
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Spider: indexes regenerated.");
}
/**
Modified: trunk/freenet/src/freenet/clients/http/PproxyToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/PproxyToadlet.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/clients/http/PproxyToadlet.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -139,7 +139,8 @@
if(path.startsWith("/"))
path = path.substring(1);
path = path.substring("plugins/".length());
- Logger.minor(this, "Pproxy fetching "+path);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Pproxy fetching "+path);
try {
if (path.equals("")) {
this.showPluginList(ctx, request);
Modified: trunk/freenet/src/freenet/clients/http/QueueToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/QueueToadlet.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/clients/http/QueueToadlet.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -85,9 +85,11 @@
return;
}
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
+
if(request.isParameterSet("remove_request") &&
(request.getParam("remove_request").length() > 0)) {
String identifier =
request.getParam("identifier");
- Logger.minor(this, "Removing "+identifier);
+ if(logMINOR) Logger.minor(this, "Removing
"+identifier);
try {
fcp.removeGlobalRequest(identifier);
} catch (MessageInvalidException e) {
@@ -98,11 +100,11 @@
}else if(request.isParameterSet("remove_AllRequests")
&& (request.getParam("remove_AllRequests").length() > 0)) {
ClientRequest[] reqs = fcp.getGlobalRequests();
- Logger.minor(this, "Request count:
"+reqs.length);
+ if(logMINOR) Logger.minor(this, "Request count:
"+reqs.length);
for(int i=0; i<reqs.length ; i++){
String identifier =
reqs[i].getIdentifier();
- Logger.minor(this, "Removing
"+identifier);
+ if(logMINOR) Logger.minor(this,
"Removing "+identifier);
try {
fcp.removeGlobalRequest(identifier);
} catch (MessageInvalidException e) {
@@ -312,7 +314,8 @@
LinkedList uncompletedDirUpload = new LinkedList();
ClientRequest[] reqs = fcp.getGlobalRequests();
- Logger.minor(this, "Request count: "+reqs.length);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Request count: "+reqs.length);
if(reqs.length < 1){
HTMLNode pageNode = pageMaker.getPageNode("Global queue
of " + core.getMyName());
Modified: trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -338,7 +338,8 @@
}
try {
Socket conn = networkInterface.accept();
- Logger.minor(this, "Accepted connection");
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Accepted
connection");
SocketHandler sh = new SocketHandler(conn);
sh.start();
} catch (SocketTimeoutException e) {
@@ -362,9 +363,10 @@
}
public void run() {
- Logger.minor(this, "Handling connection");
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "Handling connection");
ToadletContextImpl.handle(sock,
SimpleToadletServer.this, bf, pageMaker);
- Logger.minor(this, "Handled connection");
+ if(logMINOR) Logger.minor(this, "Handled connection");
}
}
Modified: trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/clients/http/ToadletContextImpl.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -180,7 +180,8 @@
continue;
}
- Logger.minor(ToadletContextImpl.class, "first
line: "+firstLine);
+ if(Logger.shouldLog(Logger.MINOR,
ToadletContextImpl.class))
+ Logger.minor(ToadletContextImpl.class,
"first line: "+firstLine);
String[] split = firstLine.split(" ");
Modified: trunk/freenet/src/freenet/clients/http/filter/CSSReadFilter.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/filter/CSSReadFilter.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/clients/http/filter/CSSReadFilter.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -74,7 +74,8 @@
parser.parse();
} catch (Throwable t) {
// Ignore ALL errors!
- Logger.minor(this, "Caught "+t+" trying to detect MIME
type with "+parseCharset);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Caught "+t+" trying to
detect MIME type with "+parseCharset);
}
r.close();
return parser.detectedCharset;
Modified: trunk/freenet/src/freenet/clients/http/filter/ContentFilter.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/filter/ContentFilter.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/clients/http/filter/ContentFilter.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -187,7 +187,8 @@
if(handler.defaultCharset != null) {
try {
if((charset =
handler.charsetExtractor.getCharset(data, handler.defaultCharset)) != null) {
-
Logger.minor(ContentFilter.class, "Returning charset: "+charset);
+ if(Logger.shouldLog(Logger.MINOR,
ContentFilter.class))
+
Logger.minor(ContentFilter.class, "Returning charset: "+charset);
return charset;
}
} catch (DataFilterException e) {
@@ -217,7 +218,8 @@
return charset;
} catch (UnsupportedEncodingException e) {
// Doesn't seem to be supported by prior to 1.6.
- Logger.minor(ContentFilter.class, "UTF-32 not
supported");
+ if(Logger.shouldLog(Logger.MINOR, ContentFilter.class))
+ Logger.minor(ContentFilter.class, "UTF-32 not
supported");
} catch (DataFilterException e) {
// Ignore
}
Modified:
trunk/freenet/src/freenet/clients/http/filter/GenericReadFilterCallback.java
===================================================================
---
trunk/freenet/src/freenet/clients/http/filter/GenericReadFilterCallback.java
2006-08-24 01:28:44 UTC (rev 10250)
+++
trunk/freenet/src/freenet/clients/http/filter/GenericReadFilterCallback.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -46,17 +46,18 @@
public String processURI(String u, String overrideType, boolean
noRelative) {
URI uri;
URI resolved;
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
try {
- Logger.minor(this, "Processing "+u);
+ if(logMINOR) Logger.minor(this, "Processing "+u);
uri = URIPreEncoder.encodeURI(u).normalize();
- Logger.minor(this, "Processing "+uri);
+ if(logMINOR) Logger.minor(this, "Processing "+uri);
if(!noRelative)
resolved = baseURI.resolve(uri);
else
resolved = uri;
- Logger.minor(this, "Resolved: "+resolved);
+ if(logMINOR) Logger.minor(this, "Resolved: "+resolved);
} catch (URISyntaxException e1) {
- Logger.minor(this, "Failed to parse URI: "+e1);
+ if(logMINOR) Logger.minor(this, "Failed to parse URI:
"+e1);
return null;
}
String path = uri.getPath();
@@ -80,14 +81,14 @@
String rpath = uri.getPath();
if(rpath != null) {
- Logger.minor(this, "Resolved URI: "+rpath);
+ if(logMINOR) Logger.minor(this, "Resolved URI: "+rpath);
// Valid FreenetURI?
try {
String p = rpath;
while(p.startsWith("/")) p = p.substring(1);
FreenetURI furi = new FreenetURI(p);
- Logger.minor(this, "Parsed: "+furi);
+ if(logMINOR) Logger.minor(this, "Parsed:
"+furi);
return processURI(furi, uri, overrideType,
noRelative);
} catch (MalformedURLException e) {
// Not a FreenetURI
@@ -98,14 +99,14 @@
rpath = resolved.getPath();
if(rpath == null) return null;
- Logger.minor(this, "Resolved URI: "+rpath);
+ if(logMINOR) Logger.minor(this, "Resolved URI: "+rpath);
// Valid FreenetURI?
try {
String p = rpath;
while(p.startsWith("/")) p = p.substring(1);
FreenetURI furi = new FreenetURI(p);
- Logger.minor(this, "Parsed: "+furi);
+ if(logMINOR) Logger.minor(this, "Parsed: "+furi);
return processURI(furi, uri, overrideType, noRelative);
} catch (MalformedURLException e) {
// Not a FreenetURI
Modified: trunk/freenet/src/freenet/clients/http/filter/HTMLFilter.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/filter/HTMLFilter.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/clients/http/filter/HTMLFilter.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -33,11 +33,14 @@
public class HTMLFilter implements ContentDataFilter, CharsetExtractor {
+ private static boolean logMINOR;
+
private static boolean deleteWierdStuff = true;
private static boolean deleteErrors = true;
public Bucket readFilter(Bucket bucket, BucketFactory bf, String
charset, HashMap otherParams, FilterCallback cb) throws DataFilterException,
IOException {
- Logger.minor(this, "readFilter(): charset="+charset);
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "readFilter():
charset="+charset);
InputStream strm = bucket.getInputStream();
Bucket temp = bf.makeBucket(bucket.size());
OutputStream os = temp.getOutputStream();
@@ -68,7 +71,8 @@
}
public String getCharset(Bucket bucket, String parseCharset) throws
DataFilterException, IOException {
- Logger.minor(this, "getCharset(): default="+parseCharset);
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "getCharset():
default="+parseCharset);
InputStream strm = bucket.getInputStream();
Writer w = new NullWriter();
Reader r;
@@ -78,9 +82,9 @@
pc.run(null);
} catch (Throwable t) {
// Ignore ALL errors
- Logger.minor(this, "Caught "+t+" trying to detect MIME
type with "+parseCharset);
+ if(logMINOR) Logger.minor(this, "Caught "+t+" trying to
detect MIME type with "+parseCharset);
}
- Logger.minor(this, "Returning charset "+pc.detectedCharset);
+ if(logMINOR) Logger.minor(this, "Returning charset
"+pc.detectedCharset);
return pc.detectedCharset;
}
@@ -347,7 +351,7 @@
void saveText(StringBuffer s, String tagName, Writer w,
HTMLParseContext pc)
throws IOException {
- Logger.minor(this, "Saving text: "+s.toString());
+ if(logMINOR) Logger.minor(this, "Saving text: "+s.toString());
if (pc.killText) {
return;
}
@@ -386,8 +390,10 @@
void processTag(Vector splitTag, Writer w, HTMLParseContext pc)
throws IOException, DataFilterException {
// First, check that it is a recognized tag
- for(int i=0;i<splitTag.size();i++)
- Logger.minor(this, "Tag["+i+"]="+splitTag.get(i));
+ if(logMINOR) {
+ for(int i=0;i<splitTag.size();i++)
+ Logger.minor(this,
"Tag["+i+"]="+splitTag.get(i));
+ }
ParsedTag t = new ParsedTag(splitTag);
if (!pc.killTag) {
t = t.sanitize(pc);
@@ -423,7 +429,7 @@
if(s.charAt(s.length()-1) == '-')
s.setLength(s.length()-1);
}
- Logger.minor(this, "Saving comment: "+s.toString());
+ if(logMINOR) Logger.minor(this, "Saving comment:
"+s.toString());
if (pc.expectingBadComment)
return; // ignore it
@@ -506,13 +512,13 @@
unparsedAttrs[x - 1] = (String)
v.elementAt(x);
} else
unparsedAttrs = new String[0];
- Logger.minor(this, "Element = "+element);
+ if(logMINOR) Logger.minor(this, "Element = "+element);
}
public ParsedTag sanitize(HTMLParseContext pc) throws
DataFilterException {
TagVerifier tv =
(TagVerifier)
allowedTagsVerifiers.get(element.toLowerCase());
- Logger.minor(this, "Got verifier: "+tv+" for "+element);
+ if(logMINOR) Logger.minor(this, "Got verifier: "+tv+"
for "+element);
if (tv == null) {
if (deleteWierdStuff) {
return null;
@@ -1264,7 +1270,7 @@
Hashtable h,
Hashtable hn,
HTMLParseContext pc) throws DataFilterException {
- Logger.minor(this, "Finishing script/style");
+ if(logMINOR) Logger.minor(this, "Finishing
script/style");
// Finishing
setStyle(false, pc);
pc.styleScriptRecurseCount--;
@@ -1289,7 +1295,7 @@
}
Hashtable start(Hashtable h, Hashtable hn, HTMLParseContext pc)
throws DataFilterException {
- Logger.minor(this, "Starting script/style");
+ if(logMINOR) Logger.minor(this, "Starting
script/style");
pc.styleScriptRecurseCount++;
if (pc.styleScriptRecurseCount > 1) {
if (deleteErrors)
@@ -1522,12 +1528,13 @@
type = typesplit[0];
if ((typesplit[1] != null) &&
(typesplit[1].length() > 0))
charset = typesplit[1];
- Logger.debug(
- this,
- "Processing link tag, type="
- + type
- + ", charset="
- + charset);
+ if(logMINOR)
+ Logger.debug(
+ this,
+ "Processing link tag,
type="
+ + type
+ + ", charset="
+ + charset);
}
String c = getHashString(h, "charset");
if (c != null)
@@ -1662,7 +1669,7 @@
String name = getHashString(h, "name");
String content = getHashString(h, "content");
String scheme = getHashString(h, "scheme");
- Logger.minor(this, "meta: name="+name+",
content="+content+", http-equiv="+http_equiv+", scheme="+scheme);
+ if(logMINOR) Logger.minor(this, "meta: name="+name+",
content="+content+", http-equiv="+http_equiv+", scheme="+scheme);
if (content != null) {
if ((name != null) && (http_equiv == null)) {
if (name.equalsIgnoreCase("Author")) {
@@ -1698,10 +1705,12 @@
}
// FIXME: add some more headers
- Dublin Core?
} else if
(http_equiv.equalsIgnoreCase("Content-Type")) {
- Logger.minor(this, "Found
http-equiv content-type="+content);
+ if(logMINOR) Logger.minor(this,
"Found http-equiv content-type="+content);
String[] typesplit =
splitType(content);
- for(int
i=0;i<typesplit.length;i++)
- Logger.minor(this,
"["+i+"] = "+typesplit[i]);
+ if(logMINOR) {
+ for(int
i=0;i<typesplit.length;i++)
+
Logger.minor(this, "["+i+"] = "+typesplit[i]);
+ }
if
(typesplit[0].equalsIgnoreCase("text/html")
&& ((typesplit[1] ==
null)
||
typesplit[1].equalsIgnoreCase(pc.charset))) {
@@ -1844,9 +1853,7 @@
Reader r = new StringReader(style);
Writer w = new StringWriter();
style = style.trim();
- Logger.minor(
- HTMLFilter.class,
- "Sanitizing style: " + style);
+ if(logMINOR) Logger.minor(HTMLFilter.class, "Sanitizing style:
" + style);
CSSParser pc = new CSSParser(r, w, false, cb);
try {
pc.parse();
@@ -1869,7 +1876,7 @@
if ((s == null) || (s.length() == 0))
return null;
// Core.logger.log(SaferFilter.class, "Style now:
" + s, Logger.DEBUG);
- Logger.debug(HTMLFilter.class, "Style finally: " + s);
+ if(logMINOR) Logger.debug(HTMLFilter.class, "Style finally: " +
s);
return s;
}
@@ -1961,7 +1968,8 @@
String overrideType,
String overrideCharset,
FilterCallback cb) {
- Logger.minor(HTMLFilter.class, "Sanitizing URI: "+suri+" (
override type "+overrideType +" override charset "+overrideCharset+" )");
+ if(logMINOR)
+ Logger.minor(HTMLFilter.class, "Sanitizing URI:
"+suri+" ( override type "+overrideType +" override charset "+overrideCharset+"
)");
if((overrideCharset != null) && (overrideCharset.length() > 0))
overrideType += ";charset="+overrideCharset;
return cb.processURI(suri, overrideType);
Modified: trunk/freenet/src/freenet/config/FilePersistentConfig.java
===================================================================
--- trunk/freenet/src/freenet/config/FilePersistentConfig.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/config/FilePersistentConfig.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -123,7 +123,8 @@
public void innerStore() throws IOException {
SimpleFieldSet fs = exportFieldSet();
- Logger.minor(this, "fs = "+fs);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "fs = "+fs);
FileOutputStream fos = new FileOutputStream(tempFilename);
BufferedWriter bw = new BufferedWriter(new
OutputStreamWriter(fos, "UTF-8"));
synchronized(this) {
Modified: trunk/freenet/src/freenet/crypt/Yarrow.java
===================================================================
--- trunk/freenet/src/freenet/crypt/Yarrow.java 2006-08-24 01:28:44 UTC (rev
10250)
+++ trunk/freenet/src/freenet/crypt/Yarrow.java 2006-08-24 04:41:42 UTC (rev
10251)
@@ -473,9 +473,10 @@
if (performedPoolReseed && (seedfile != null)) {
//Dont do this while synchronized on 'this' since
//opening a file seems to be suprisingly slow on windows
- Logger.minor(this, "Writing seedfile");
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "Writing seedfile");
write_seed(seedfile);
- Logger.minor(this, "Written seedfile");
+ if(logMINOR) Logger.minor(this, "Written seedfile");
}
return actualEntropy;
Modified: trunk/freenet/src/freenet/io/NetworkInterface.java
===================================================================
--- trunk/freenet/src/freenet/io/NetworkInterface.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/io/NetworkInterface.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -305,10 +305,12 @@
*/
public void run() {
while (!closed) {
+ boolean logMINOR =
Logger.shouldLog(Logger.MINOR, this);
try {
Socket clientSocket =
serverSocket.accept();
InetAddress clientAddress =
clientSocket.getInetAddress();
- Logger.minor(Acceptor.class,
"Connection from " + clientAddress);
+ if(logMINOR)
+ Logger.minor(Acceptor.class,
"Connection from " + clientAddress);
/* check if the ip address is allowed */
boolean addressMatched = false;
@@ -338,9 +340,11 @@
Logger.normal(Acceptor.class,
"Denied connection to " + clientAddress);
}
} catch (SocketTimeoutException ste1) {
- Logger.minor(this, "Timeout");
+ if(logMINOR)
+ Logger.minor(this, "Timeout");
} catch (IOException ioe1) {
- Logger.minor(this, "Caught " + ioe1);
+ if(logMINOR)
+ Logger.minor(this, "Caught " +
ioe1);
}
}
NetworkInterface.this.acceptorStopped();
Modified: trunk/freenet/src/freenet/io/comm/FreenetInetAddress.java
===================================================================
--- trunk/freenet/src/freenet/io/comm/FreenetInetAddress.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/io/comm/FreenetInetAddress.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -56,7 +56,8 @@
// if we were created with an explicit IP address, use it as such
// debugging log messages because AddressIdentifier doesn't appear to
handle all IPv6 literals correctly, such as "fe80::204:1234:dead:beef"
AddressIdentifier.AddressType addressType =
AddressIdentifier.getAddressType(host);
- Logger.debug(this, "Address type of '"+host+"' appears to be
'"+addressType+"'");
+ boolean logDEBUG = Logger.shouldLog(Logger.DEBUG, this);
+ if(logDEBUG) Logger.debug(this, "Address type of '"+host+"' appears to
be '"+addressType+"'");
if(!addressType.toString().equals("Other")) {
try {
addr = InetAddress.getByName(host);
@@ -64,16 +65,16 @@
if(!allowUnknown) throw e;
addr = null;
}
- Logger.debug(this, "host is '"+host+"' and addr.getHostAddress()
is '"+addr.getHostAddress()+"'");
+ if(logDEBUG) Logger.debug(this, "host is '"+host+"' and
addr.getHostAddress() is '"+addr.getHostAddress()+"'");
if(addr != null && addr.getHostAddress().equals(host)) {
- Logger.debug(this, "'"+host+"' looks like an IP address");
+ if(logDEBUG) Logger.debug(this, "'"+host+"' looks like an IP
address");
host = null;
} else {
addr = null;
}
}
if( addr == null ) {
- Logger.debug(this, "'"+host+"' does not look like an IP address");
+ if(logDEBUG) Logger.debug(this, "'"+host+"' does not look like
an IP address");
}
this._address = addr;
this.hostname = host;
@@ -176,11 +177,12 @@
*/
public InetAddress getHandshakeAddress() {
// Since we're handshaking, hostname-to-IP may have changed
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
if ((_address != null) && (hostname == null)) {
- Logger.minor(this, "hostname is null, returning "+_address);
+ if(logMINOR) Logger.minor(this, "hostname is null, returning
"+_address);
return _address;
} else {
- Logger.minor(this, "Looking up '"+hostname+"' in DNS");
+ if(logMINOR) Logger.minor(this, "Looking up '"+hostname+"' in
DNS");
/*
* Peers are constructed from an address once a
* handshake has been completed, so this lookup
@@ -193,7 +195,7 @@
*/
try {
InetAddress addr = InetAddress.getByName(hostname);
- Logger.minor(this, "Look up got '"+addr+"'");
+ if(logMINOR) Logger.minor(this, "Look up got
'"+addr+"'");
if( addr != null ) {
/*
* cache the answer since getHandshakeAddress()
@@ -202,11 +204,11 @@
* latest value from DNS (minus Java's caching)
*/
this._address =
InetAddress.getByAddress(addr.getAddress());
- Logger.minor(this, "Setting address to
"+_address);
+ if(logMINOR) Logger.minor(this, "Setting
address to "+_address);
}
return addr;
} catch (UnknownHostException e) {
- Logger.minor(this, "DNS said hostname '"+hostname+"' is an
unknown host, returning null");
+ if(logMINOR) Logger.minor(this, "DNS said hostname
'"+hostname+"' is an unknown host, returning null");
return null;
}
}
Modified: trunk/freenet/src/freenet/io/comm/Message.java
===================================================================
--- trunk/freenet/src/freenet/io/comm/Message.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/io/comm/Message.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -49,7 +49,8 @@
try {
mspec = MessageType.getSpec(new Integer(dis.readInt()));
} catch (IOException e1) {
- Logger.minor(Message.class,"Failed to read message type: "+e1, e1);
+ if(Logger.shouldLog(Logger.DEBUG, Message.class))
+ Logger.minor(Message.class,"Failed to read message
type: "+e1, e1);
return null;
}
if (mspec == null) {
@@ -159,7 +160,8 @@
// if (this.getSpec() != MessageTypes.ping && this.getSpec() !=
MessageTypes.pong)
// Logger.logMinor("<<<<< Send message : " + this);
- Logger.minor(this, "My spec code: "+_spec.getName().hashCode()+"
for "+_spec.getName());
+ if(Logger.shouldLog(Logger.DEBUG, Message.class))
+ Logger.minor(this, "My spec code:
"+_spec.getName().hashCode()+" for "+_spec.getName());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
try {
@@ -173,7 +175,8 @@
e.printStackTrace();
}
byte[] buf = baos.toByteArray();
- Logger.minor(this, "Length: "+buf.length+", hash:
"+Fields.hashCode(buf));
+ if(Logger.shouldLog(Logger.DEBUG, Message.class))
+ Logger.minor(this, "Length: "+buf.length+", hash:
"+Fields.hashCode(buf));
return buf;
}
Modified: trunk/freenet/src/freenet/io/comm/UdpSocketManager.java
===================================================================
--- trunk/freenet/src/freenet/io/comm/UdpSocketManager.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/io/comm/UdpSocketManager.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -35,6 +35,7 @@
public class UdpSocketManager extends Thread {
public static final String VERSION = "$Id: UdpSocketManager.java,v 1.22
2005/08/25 17:28:19 amphibian Exp $";
+ private static boolean logMINOR;
private Dispatcher _dispatcher;
private DatagramSocket _sock;
/** _filters serves as lock for both */
@@ -68,13 +69,14 @@
public class USMChecker implements Runnable {
public void run() {
while(true) {
+ logMINOR = Logger.shouldLog(Logger.MINOR,
UdpSocketManager.this);
try {
Thread.sleep(10*1000);
} catch (InterruptedException e) {
// Ignore
}
if(UdpSocketManager.this.isAlive()) {
- Logger.minor(this, "PING on
"+UdpSocketManager.this);
+ if(logMINOR) Logger.minor(this, "PING
on "+UdpSocketManager.this);
long time = System.currentTimeMillis();
int timeSecs = (int) (time / 1000);
if(timeSecs - lastTimeInSeconds > 3*60)
{
@@ -130,6 +132,7 @@
// }
// Only used for debugging, no need to seed from Yarrow
dropRandom = new Random();
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
}
public void run() { // Listen for packets
@@ -205,7 +208,7 @@
int length = packet.getLength();
if (lowLevelFilter != null) {
try {
- Logger.minor(this, "Processing packet
of length "+length+" from "+peer);
+ if(logMINOR) Logger.minor(this,
"Processing packet of length "+length+" from "+peer);
startTime = System.currentTimeMillis();
lowLevelFilter.process(data, offset,
length, peer);
endTime = System.currentTimeMillis();
@@ -215,7 +218,7 @@
else
Logger.normal(this,
"processing packet took "+(endTime-startTime)+"ms");
}
- Logger.minor(this,
+ if(logMINOR) Logger.minor(this,
"Successfully handled
packet length " + length);
} catch (Throwable t) {
Logger.error(this, "Caught " + t + "
from "
@@ -229,8 +232,7 @@
checkFilters(m);
}
}
- } else
- Logger.minor(this, "Null packet");
+ } else if(logMINOR) Logger.minor(this, "Null packet");
}
/**
@@ -274,7 +276,7 @@
} catch (IOException e2) {
throw new RuntimeException(e2);
}
- Logger.minor(this, "Received packet");
+ if(logMINOR) Logger.minor(this, "Received packet");
return packet;
}
@@ -316,8 +318,8 @@
((PeerNode)m.getSource()).addToLocalNodeReceivedMessagesFromStatistic(m);
}
boolean matched = false;
- if (!(m.getSpec().equals(DMT.packetTransmit))) {
- if (m.getSpec().equals(DMT.ping) ||
m.getSpec().equals(DMT.pong)) {
+ if ((!(m.getSpec().equals(DMT.packetTransmit))) && logMINOR) {
+ if ((m.getSpec().equals(DMT.ping) ||
m.getSpec().equals(DMT.pong)) && Logger.shouldLog(Logger.DEBUG, this)) {
Logger.debug(this, "" +
(System.currentTimeMillis() % 60000) + " " + _sock.getLocalPort() + " <- "
+ m.getSource() + " : " + m);
} else {
@@ -335,7 +337,7 @@
i.remove();
f.notify();
}
- Logger.minor(this, "Matched: "+f);
+ if(logMINOR) Logger.minor(this,
"Matched: "+f);
break; // Only one match permitted per
message
}
}
@@ -343,7 +345,7 @@
// Feed unmatched messages to the dispatcher
if ((!matched) && (_dispatcher != null)) {
try {
- Logger.minor(this, "Feeding to dispatcher: "+m);
+ if(logMINOR) Logger.minor(this, "Feeding to dispatcher:
"+m);
matched = _dispatcher.handleMessage(m);
} catch (Throwable t) {
Logger.error(this, "Dispatcher threw "+t, t);
@@ -351,7 +353,7 @@
}
// Keep the last few _unclaimed messages around in case the
intended receiver isn't receiving yet
if (!matched) {
- Logger.minor(this, "Unclaimed: "+m);
+ if(logMINOR) Logger.minor(this, "Unclaimed: "+m);
/** Check filters and then add to _unmatched is ATOMIC
* It has to be atomic, because otherwise we can get a
* race condition that results in timeouts on MFs.
@@ -374,7 +376,7 @@
* filters after we return from dispatcher, for example.
*/
synchronized (_filters) {
- Logger.minor(this, "Rechecking filters and
adding message");
+ if(logMINOR) Logger.minor(this, "Rechecking
filters and adding message");
for (ListIterator i = _filters.listIterator();
i.hasNext();) {
MessageFilter f = (MessageFilter)
i.next();
if (f.match(m)) {
@@ -384,7 +386,7 @@
i.remove();
f.notify();
}
- Logger.minor(this, "Matched:
"+f);
+ if(logMINOR) Logger.minor(this,
"Matched: "+f);
break; // Only one match
permitted per message
}
}
@@ -399,7 +401,7 @@
}
}
_unclaimed.addLast(m);
- Logger.minor(this, "Done");
+ if(logMINOR) Logger.minor(this, "Done");
}
}
}
@@ -424,7 +426,8 @@
}
public Message waitFor(MessageFilter filter, ByteCounter ctr) throws
DisconnectedException {
- Logger.debug(this, "Waiting for "+filter);
+ boolean logDEBUG = Logger.shouldLog(Logger.DEBUG, this);
+ if(logDEBUG) Logger.debug(this, "Waiting for "+filter);
long startTime = System.currentTimeMillis();
Message ret = null;
if((lowLevelFilter != null) && (filter._source != null) &&
@@ -433,31 +436,31 @@
throw new DisconnectedException();
// Check to see whether the filter matches any of the recently
_unclaimed messages
synchronized (_filters) {
- Logger.minor(this, "Checking _unclaimed");
+ if(logMINOR) Logger.minor(this, "Checking _unclaimed");
for (ListIterator i = _unclaimed.listIterator();
i.hasNext();) {
Message m = (Message) i.next();
if (filter.match(m)) {
i.remove();
ret = m;
- Logger.debug(this, "Matching from
_unclaimed");
+ if(logMINOR) Logger.debug(this,
"Matching from _unclaimed");
break;
}
}
if (ret == null) {
- Logger.minor(this, "Not in _unclaimed");
+ if(logMINOR) Logger.minor(this, "Not in
_unclaimed");
// Insert filter into filter list in order of
timeout
ListIterator i = _filters.listIterator();
while (true) {
if (!i.hasNext()) {
i.add(filter);
- Logger.minor(this, "Added at
end");
+ if(logMINOR) Logger.minor(this,
"Added at end");
break;
}
MessageFilter mf = (MessageFilter)
i.next();
if (mf.getTimeout() >
filter.getTimeout()) {
i.previous();
i.add(filter);
- Logger.minor(this, "Added in
middle - mf timeout="+mf.getTimeout()+" - my timeout="+filter.getTimeout());
+ if(logMINOR) Logger.minor(this,
"Added in middle - mf timeout="+mf.getTimeout()+" - my
timeout="+filter.getTimeout());
break;
}
}
@@ -467,7 +470,7 @@
// Waiting on the filter won't release the outer lock
// So we have to release it here
if(ret == null) {
- Logger.minor(this, "Waiting...");
+ if(logMINOR) Logger.minor(this, "Waiting...");
synchronized (filter) {
try {
// Precaution against filter getting
matched between being added to _filters and
@@ -481,13 +484,13 @@
}
if(filter.droppedConnection() != null)
throw new DisconnectedException();
- Logger.minor(this, "Matched: "+fmatched);
+ if(logMINOR) Logger.minor(this, "Matched:
"+fmatched);
} catch (InterruptedException e) {
}
ret = filter.getMessage();
filter.clearMatched();
}
- Logger.debug(this, "Returning "+ret+" from "+filter);
+ if(logDEBUG) Logger.debug(this, "Returning "+ret+" from
"+filter);
}
// Probably get rid...
// if (Dijjer.getDijjer().getDumpMessageWaitTimes() != null) {
@@ -496,7 +499,7 @@
// Dijjer.getDijjer().getDumpMessageWaitTimes().flush();
// }
long endTime = System.currentTimeMillis();
- Logger.debug(this, "Returning in "+(endTime-startTime)+"ms");
+ if(logDEBUG) Logger.debug(this, "Returning in
"+(endTime-startTime)+"ms");
if((ctr != null) && (ret != null))
ctr.receivedBytes(ret._receivedByteCount);
return ret;
@@ -511,11 +514,12 @@
Logger.error(this, "Trying to send internal-only message "+m+"
of spec "+m.getSpec(), new Exception("debug"));
return;
}
- if (m.getSpec().equals(DMT.ping) ||
m.getSpec().equals(DMT.pong)) {
- Logger.debug(this, "" + (System.currentTimeMillis() %
60000) + " " + _sock.getPort() + " -> " + destination
- + " : " + m);
+ if ((m.getSpec().equals(DMT.ping) ||
m.getSpec().equals(DMT.pong)) && logMINOR) {
+ if(Logger.shouldLog(Logger.DEBUG, this))
+ Logger.debug(this, "" +
(System.currentTimeMillis() % 60000) + " " + _sock.getPort() + " -> " +
destination
+ + " : " + m);
} else {
- Logger.minor(this, "" + (System.currentTimeMillis() %
60000) + " " + _sock.getPort() + " -> " + destination
+ if(logMINOR) Logger.minor(this, "" +
(System.currentTimeMillis() % 60000) + " " + _sock.getPort() + " -> " +
destination
+ " : " + m);
}
// byte[] blockToSend = m.encodeToPacket(lowLevelFilter,
destination);
@@ -551,7 +555,7 @@
}
if (_dropProbability > 0) {
if (dropRandom.nextInt() % _dropProbability == 0) {
- Logger.minor(this, "DROPPED: " +
_sock.getLocalPort() + " -> " + destination.getPort());
+ if(logMINOR) Logger.minor(this, "DROPPED: " +
_sock.getLocalPort() + " -> " + destination.getPort());
return;
}
}
Modified: trunk/freenet/src/freenet/io/xfer/BlockReceiver.java
===================================================================
--- trunk/freenet/src/freenet/io/xfer/BlockReceiver.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/io/xfer/BlockReceiver.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -79,7 +79,8 @@
Logger.normal(this, "Disconnected during receive: "+_uid+"
from "+_sender);
throw new
RetrievalException(RetrievalException.SENDER_DISCONNECTED);
}
- Logger.minor(this, "Received "+m1);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Received "+m1);
if ((m1 != null) && m1.getSpec().equals(DMT.sendAborted)) {
_prb.abort(m1.getInt(DMT.REASON),
m1.getString(DMT.DESCRIPTION));
throw new
RetrievalException(m1.getInt(DMT.REASON), m1.getString(DMT.DESCRIPTION));
@@ -110,7 +111,8 @@
}
}
}
- Logger.minor(this, "Missing: "+missing.size());
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Missing:
"+missing.size());
if (missing.size() > 0) {
Message mn =
DMT.createMissingPacketNotification(_uid, missing);
_usm.send(_sender, mn, _ctr);
Modified: trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java
===================================================================
--- trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -87,7 +87,8 @@
if(_unsent.size() != 0) break;
// No
unsent packets
if(getNumSent() == _prb.getNumPackets()) {
-
Logger.minor(this, "Sent all blocks, none unsent");
+
if(Logger.shouldLog(Logger.MINOR, this))
+
Logger.minor(this, "Sent all blocks, none unsent");
if(timeAllSent <= 0)
timeAllSent = System.currentTimeMillis();
}
@@ -198,7 +199,8 @@
try {
((PeerNode)_destination).sendAsync(DMT.createSendAborted(_uid, reason,
description), null, 0, _ctr);
} catch (NotConnectedException e) {
- Logger.minor(this, "Receive aborted and receiver is not
connected");
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Receive aborted and receiver is not
connected");
}
} });
}
@@ -213,17 +215,18 @@
return false;
}
Message msg;
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
try {
MessageFilter mfMissingPacketNotification =
MessageFilter.create().setType(DMT.missingPacketNotification).setField(DMT.UID,
_uid).setTimeout(SEND_TIMEOUT).setSource(_destination);
MessageFilter mfAllReceived =
MessageFilter.create().setType(DMT.allReceived).setField(DMT.UID,
_uid).setTimeout(SEND_TIMEOUT).setSource(_destination);
MessageFilter mfSendAborted =
MessageFilter.create().setType(DMT.sendAborted).setField(DMT.UID,
_uid).setTimeout(SEND_TIMEOUT).setSource(_destination);
msg =
_usm.waitFor(mfMissingPacketNotification.or(mfAllReceived.or(mfSendAborted)),
_ctr);
- Logger.minor(this, "Got "+msg);
+ if(logMINOR) Logger.minor(this, "Got "+msg);
} catch (DisconnectedException e) {
// Ignore, see below
msg = null;
}
- Logger.minor(this, "Got "+msg);
+ if(logMINOR) Logger.minor(this, "Got "+msg);
if(!_destination.isConnected()) {
Logger.normal(this, "Terminating send "+_uid+" to
"+_destination+" from "+_usm.getPortNumber()+" because node disconnected while
waiting");
synchronized(_senderThread) {
@@ -244,7 +247,7 @@
Logger.error(this, "Terminating send
"+_uid+" to "+_destination+" from "+_usm.getPortNumber()+" as we haven't heard
from receiver in "+SEND_TIMEOUT+"ms.");
return false;
} else {
- Logger.minor(this, "Ignoring timeout:
timeAllSent="+timeAllSent+" ("+(System.currentTimeMillis() - timeAllSent)+"),
getNumSent="+getNumSent()+"/"+_prb.getNumPackets());
+ if(logMINOR) Logger.minor(this,
"Ignoring timeout: timeAllSent="+timeAllSent+" ("+(System.currentTimeMillis() -
timeAllSent)+"), getNumSent="+getNumSent()+"/"+_prb.getNumPackets());
continue;
}
} else if
(msg.getSpec().equals(DMT.missingPacketNotification)) {
Modified: trunk/freenet/src/freenet/io/xfer/PacketThrottle.java
===================================================================
--- trunk/freenet/src/freenet/io/xfer/PacketThrottle.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/io/xfer/PacketThrottle.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -72,7 +72,8 @@
_totalPackets++;
_simulatedWindowSize *= PACKET_DROP_DECREASE_MULTIPLE;
slowStart = false;
- Logger.minor(this, "notifyOfPacketLost(): "+this);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "notifyOfPacketLost(): "+this);
}
public synchronized void notifyOfPacketAcknowledged() {
@@ -82,7 +83,8 @@
} else {
_simulatedWindowSize += (PACKET_TRANSMIT_INCREMENT /
_simulatedWindowSize);
}
- Logger.minor(this, "notifyOfPacketAcked(): "+this);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "notifyOfPacketAcked(): "+this);
}
public synchronized long getDelay() {
Modified: trunk/freenet/src/freenet/keys/FreenetURI.java
===================================================================
--- trunk/freenet/src/freenet/keys/FreenetURI.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/keys/FreenetURI.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -544,7 +544,8 @@
int len = dis.readShort();
byte[] buf = new byte[len];
dis.readFully(buf);
- Logger.minor(FreenetURI.class, "Read "+len+" bytes for key");
+ if(Logger.shouldLog(Logger.MINOR, FreenetURI.class))
+ Logger.minor(FreenetURI.class, "Read "+len+" bytes for
key");
return fromFullBinaryKey(buf);
}
@@ -609,7 +610,8 @@
if(data.length > Short.MAX_VALUE)
throw new MalformedURLException("Full key too long:
"+data.length+" - "+this);
dos.writeShort((short)data.length);
- Logger.minor(this, "Written "+data.length+" bytes");
+ if(Logger.shouldLog(Logger.MINOR, FreenetURI.class))
+ Logger.minor(this, "Written "+data.length+" bytes");
dos.write(data);
}
@@ -662,33 +664,34 @@
}
public String getPreferredFilename() {
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
Logger.minor(this, "Getting preferred filename for "+this);
Vector names = new Vector();
if(keyType.equals("KSK") || keyType.equals("SSK")) {
- Logger.minor(this, "Adding docName: "+docName);
+ if(logMINOR) Logger.minor(this, "Adding docName:
"+docName);
names.add(docName);
}
if(metaStr != null)
for(int i=0;i<metaStr.length;i++) {
- Logger.minor(this, "Adding metaString "+i+":
"+metaStr[i]);
+ if(logMINOR) Logger.minor(this, "Adding
metaString "+i+": "+metaStr[i]);
names.add(metaStr[i]);
}
StringBuffer out = new StringBuffer();
for(int i=0;i<names.size();i++) {
String s = (String) names.get(i);
- Logger.minor(this, "name "+i+" = "+s);
+ if(logMINOR) Logger.minor(this, "name "+i+" = "+s);
s = sanitize(s);
- Logger.minor(this, "Sanitized name "+i+" = "+s);
+ if(logMINOR) Logger.minor(this, "Sanitized name "+i+" =
"+s);
if(s.length() > 0) {
if(out.length() > 0)
out.append("-");
out.append(s);
}
}
- Logger.minor(this, "out = "+out.toString());
+ if(logMINOR) Logger.minor(this, "out = "+out.toString());
if(out.length() == 0) {
if(routingKey != null) {
- Logger.minor(this, "Returning base64 encoded
routing key");
+ if(logMINOR) Logger.minor(this, "Returning
base64 encoded routing key");
return Base64.encode(routingKey);
}
return "unknown";
Modified: trunk/freenet/src/freenet/keys/Key.java
===================================================================
--- trunk/freenet/src/freenet/keys/Key.java 2006-08-24 01:28:44 UTC (rev
10250)
+++ trunk/freenet/src/freenet/keys/Key.java 2006-08-24 04:41:42 UTC (rev
10251)
@@ -101,7 +101,8 @@
static Bucket decompress(boolean isCompressed, byte[] output,
BucketFactory bf, int maxLength, short compressionAlgorithm, boolean
shortLength) throws CHKDecodeException, IOException {
if(isCompressed) {
- Logger.minor(Key.class, "Decompressing "+output.length+" bytes
in decode with codec "+compressionAlgorithm);
+ if(Logger.shouldLog(Logger.MINOR, Key.class))
+ Logger.minor(Key.class, "Decompressing
"+output.length+" bytes in decode with codec "+compressionAlgorithm);
if(output.length < (shortLength ? 3 : 5)) throw new
CHKDecodeException("No bytes to decompress");
// Decompress
// First get the length
Modified: trunk/freenet/src/freenet/node/ARKFetchManager.java
===================================================================
--- trunk/freenet/src/freenet/node/ARKFetchManager.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/ARKFetchManager.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -57,13 +57,14 @@
}
public void maybeStartNextReadyARKFetcher() {
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
synchronized(readyARKFetchers) {
if(node.getNumARKFetchers() >= 30) {
- Logger.minor(this, "Not starting ARKFetcher in
maybeStartNextReadyARKFetcher() because there are already 30 or more ARK
Fetchers running");
+ if(logMINOR) Logger.minor(this, "Not starting
ARKFetcher in maybeStartNextReadyARKFetcher() because there are already 30 or
more ARK Fetchers running");
return;
}
if(!hasReadyARKFetchers()) {
- Logger.minor(this,
"maybeStartNextReadyARKFetcher() called with no ARKFetchers ready");
+ if(logMINOR) Logger.minor(this,
"maybeStartNextReadyARKFetcher() called with no ARKFetchers ready");
return;
}
while( true ) {
Modified: trunk/freenet/src/freenet/node/ARKFetcher.java
===================================================================
--- trunk/freenet/src/freenet/node/ARKFetcher.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/ARKFetcher.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -20,6 +20,7 @@
*/
public class ARKFetcher implements ClientCallback {
+ static boolean logMINOR;
final PeerNode peer;
final Node node;
private ClientGetter getter;
@@ -37,6 +38,7 @@
this.peer = peer;
this.node = node;
this.identity = peer.getIdentityString();
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
}
/**
@@ -63,6 +65,7 @@
* Called when the ARKFetchManager says it's our turn to start fetching.
*/
public void start() {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
if(node.arkFetchManager.hasReadyARKFetcher(this)) {
node.arkFetchManager.removeReadyARKFetcher(this);
}
@@ -77,8 +80,7 @@
if(started) { // We only need one ARKFetcher per
PeerNode
return;
}
- Logger.minor(this, "Starting ... for "+peer+" on
"+this);
- Logger.normal( this, "Starting ARK Fetcher after
"+peer.getHandshakeCount()+" failed handshakes for "+peer.getPeer()+" with
identity '"+peer.getIdentityString()+"'");
+ Logger.normal( this, "Starting ARK Fetcher after
"+peer.getHandshakeCount()+" failed handshakes for "+peer.getPeer()+" with
identity '"+peer.getIdentityString()+"' on "+this);
started = true;
// Start fetch
shouldRun = true;
@@ -90,7 +92,7 @@
FreenetURI uri = ark.getURI();
startedEdition = uri.getSuggestedEdition();
fetchingURI = uri;
- Logger.minor(this, "Fetching ARK: "+uri+" for
"+peer);
+ if(logMINOR) Logger.minor(this, "Fetching ARK:
"+uri+" for "+peer);
cg = new ClientGetter(this,
node.clientCore.requestStarters.chkFetchScheduler,
node.clientCore.requestStarters.sskFetchScheduler,
uri, node.arkFetcherContext,
RequestStarter.UPDATE_PRIORITY_CLASS,
this, new ArrayBucket());
@@ -123,23 +125,23 @@
public synchronized void stop() {
// Stop fetch
backoff = MIN_BACKOFF;
- Logger.minor(this, "Cancelling ARK fetch for "+peer);
+ if(logMINOR) Logger.minor(this, "Cancelling ARK fetch for
"+peer);
shouldRun = false;
- started = false;
- if(node.arkFetchManager.hasReadyARKFetcher(this)) {
-
node.arkFetchManager.removeReadyARKFetcher(this);
- }
- if(isFetching) {
- node.removeARKFetcher(identity,this);
- isFetching = false;
- }
+ started = false;
+ if(node.arkFetchManager.hasReadyARKFetcher(this)) {
+ node.arkFetchManager.removeReadyARKFetcher(this);
+ }
+ if(isFetching) {
+ node.removeARKFetcher(identity,this);
+ isFetching = false;
+ }
if(getter != null)
getter.cancel();
}
public void onSuccess(FetchResult result, ClientGetter state) {
- Logger.minor(this, "Fetched ARK for "+peer, new
Exception("debug"));
+ if(logMINOR) Logger.minor(this, "Fetched ARK for "+peer, new
Exception("debug"));
synchronized(this) {
started = false;
// Fetcher context specifies an upper bound on size.
@@ -168,7 +170,7 @@
SimpleFieldSet fs;
try {
fs = new SimpleFieldSet(ref, true);
- Logger.minor(this, "Got ARK for "+peer.getPeer());
+ if(logMINOR) Logger.minor(this, "Got ARK for
"+peer.getPeer());
peer.gotARK(fs, getStartedEdition());
} catch (IOException e) {
// Corrupt ref.
@@ -179,7 +181,7 @@
public void onFailure(FetchException e, ClientGetter state) {
synchronized(this) {
started = false;
- Logger.minor(this, "Failed to fetch ARK for "+peer+" :
"+e, e);
+ if(logMINOR) Logger.minor(this, "Failed to fetch ARK
for "+peer+" : "+e, e);
if(isFetching) {
node.removeARKFetcher(identity,this);
@@ -199,12 +201,14 @@
}
}
if(e.newURI != null) {
- Logger.minor(this, "Failed to fetch ARK for
"+peer.getPeer()+", "+getFetchingURI()+" gave redirect to "+e.newURI);
+ if(logMINOR)
+ Logger.minor(this, "Failed to fetch ARK for
"+peer.getPeer()+", "+getFetchingURI()+" gave redirect to "+e.newURI);
peer.updateARK(e.newURI);
queueWithBackoff();
return;
}
- Logger.minor(this, "Failed to fetch ARK for "+peer.getPeer()+",
now backing off ARK fetches for "+(getBackoff() / 1000)+" seconds");
+ if(logMINOR)
+ Logger.minor(this, "Failed to fetch ARK for
"+peer.getPeer()+", now backing off ARK fetches for "+(getBackoff() / 1000)+"
seconds");
// We may be on the PacketSender thread.
// FIXME should this be exponential backoff?
queueWithBackoff();
Modified: trunk/freenet/src/freenet/node/CHKInsertSender.java
===================================================================
--- trunk/freenet/src/freenet/node/CHKInsertSender.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/CHKInsertSender.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -128,6 +128,7 @@
this.closestLocation = closestLocation;
this.startTime = System.currentTimeMillis();
this.nodesWaitingForCompletion = new Vector();
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
}
void start() {
@@ -135,6 +136,8 @@
t.setDaemon(true);
t.start();
}
+
+ static boolean logMINOR;
// Constants
static final int ACCEPTED_TIMEOUT = 10000;
@@ -247,13 +250,13 @@
finish(ROUTE_NOT_FOUND, null);
return;
}
- Logger.minor(this, "Routing insert to "+next);
+ if(logMINOR) Logger.minor(this, "Routing insert to "+next);
nodesRoutedTo.add(next);
Message req;
synchronized (this) {
if(PeerManager.distance(target, nextValue) >
PeerManager.distance(target, closestLocation)) {
- Logger.minor(this, "Backtracking: target="+target+"
next="+nextValue+" closest="+closestLocation);
+ if(logMINOR) Logger.minor(this, "Backtracking:
target="+target+" next="+nextValue+" closest="+closestLocation);
htl = node.decrementHTL(source, htl);
}
@@ -276,7 +279,7 @@
try {
next.send(req, this);
} catch (NotConnectedException e1) {
- Logger.minor(this, "Not connected to "+next);
+ if(logMINOR) Logger.minor(this, "Not connected
to "+next);
continue;
}
synchronized (this) {
@@ -308,7 +311,7 @@
if (msg == null) {
// Terminal overload
// Try to propagate back to source
- Logger.minor(this, "Timeout");
+ if(logMINOR) Logger.minor(this,
"Timeout");
next.localRejectedOverload("Timeout3");
// Try another node.
forwardRejectedOverload();
@@ -319,7 +322,7 @@
// Non-fatal - probably still have time
left
if (msg.getBoolean(DMT.IS_LOCAL)) {
next.localRejectedOverload("ForwardRejectedOverload5");
- Logger.minor(this,
+ if(logMINOR) Logger.minor(this,
"Local RejectedOverload, moving on to next peer");
// Give up on this one, try
another
break;
@@ -346,7 +349,7 @@
if((msg == null) || (msg.getSpec() != DMT.FNPAccepted)) continue;
- Logger.minor(this, "Got Accepted on "+this);
+ if(logMINOR) Logger.minor(this, "Got Accepted on "+this);
// Send them the data.
// Which might be the new data resulting from a collision...
@@ -373,16 +376,16 @@
mf =
mfInsertReply.or(mfRouteNotFound.or(mfDataInsertRejected.or(mfTimeout.or(mfRejectedOverload))));
- Logger.minor(this, "Sending DataInsert");
+ if(logMINOR) Logger.minor(this, "Sending DataInsert");
if(receiveFailed) return;
try {
next.send(dataInsert, this);
} catch (NotConnectedException e1) {
- Logger.minor(this, "Not connected sending
DataInsert: "+next+" for "+uid);
+ if(logMINOR) Logger.minor(this, "Not connected
sending DataInsert: "+next+" for "+uid);
continue;
}
- Logger.minor(this, "Sending data");
+ if(logMINOR) Logger.minor(this, "Sending data");
if(receiveFailed) return;
AwaitingCompletion ac = new AwaitingCompletion(next, prbNow);
synchronized(nodesWaitingForCompletion) {
@@ -423,7 +426,7 @@
// Probably non-fatal, if so, we have
time left, can try next one
if (msg.getBoolean(DMT.IS_LOCAL)) {
next.localRejectedOverload("ForwardRejectedOverload6");
- Logger.minor(this,
+ if(logMINOR) Logger.minor(this,
"Local
RejectedOverload, moving on to next peer");
// Give up on this one, try
another
break;
@@ -434,7 +437,7 @@
}
if (msg.getSpec() == DMT.FNPRouteNotFound) {
- Logger.minor(this, "Rejected: RNF");
+ if(logMINOR) Logger.minor(this,
"Rejected: RNF");
short newHtl = msg.getShort(DMT.HTL);
synchronized (this) {
if (htl > newHtl)
@@ -449,7 +452,7 @@
next.successNotOverload();
short reason = msg
.getShort(DMT.DATA_INSERT_REJECTED_REASON);
- Logger.minor(this, "DataInsertRejected:
" + reason);
+ if(logMINOR) Logger.minor(this,
"DataInsertRejected: " + reason);
if (reason ==
DMT.DATA_INSERT_REJECTED_VERIFY_FAILED) {
if (fromStore) {
// That's odd...
@@ -469,8 +472,7 @@
+ " but data was valid!");
}
} catch
(CHKVerifyException e) {
- Logger
-
.normal(this,
+
Logger.normal(this,
"Verify failed because data was invalid");
} catch
(AbortedException e) {
receiveFailed =
true;
@@ -479,7 +481,7 @@
break; // What else can we do?
} else if (reason ==
DMT.DATA_INSERT_REJECTED_RECEIVE_FAILED) {
if (receiveFailed) {
- Logger.minor(this,
"Failed to receive data, so failed to send data");
+ if(logMINOR)
Logger.minor(this, "Failed to receive data, so failed to send data");
} else {
try {
if
(prb.allReceived()) {
@@ -530,7 +532,7 @@
}
private void finish(int code, PeerNode next) {
- Logger.minor(this, "Finished: "+code+" on "+this, new
Exception("debug"));
+ if(logMINOR) Logger.minor(this, "Finished: "+code+" on "+this, new
Exception("debug"));
setStatusTime = System.currentTimeMillis();
synchronized(this) {
@@ -542,7 +544,7 @@
status = code;
notifyAll();
- Logger.minor(this, "Set status code: "+getStatusString()+" on
"+uid);
+ if(logMINOR) Logger.minor(this, "Set status code:
"+getStatusString()+" on "+uid);
}
// Now wait for transfers, or for downstream transfer notifications.
if(cw != null) {
@@ -556,14 +558,14 @@
}
}
} else {
- Logger.minor(this, "No completion waiter");
+ if(logMINOR) Logger.minor(this, "No completion waiter");
// There weren't any transfers
allTransfersCompleted = true;
}
synchronized (this) {
notifyAll();
}
- Logger.minor(this, "Returning from finish()");
+ if(logMINOR) Logger.minor(this, "Returning from finish()");
}
public synchronized int getStatus() {
@@ -623,7 +625,7 @@
private class CompletionWaiter implements Runnable {
public void run() {
- Logger.minor(this, "Starting "+this);
+ if(logMINOR) Logger.minor(this, "Starting "+this);
while(true) {
AwaitingCompletion[] waiters;
synchronized(nodesWaitingForCompletion) {
@@ -664,7 +666,7 @@
mf = m;
else
mf = m.or(mf);
- Logger.minor(this, "Waiting for
"+awc.pn.getPeer());
+ if(logMINOR) Logger.minor(this,
"Waiting for "+awc.pn.getPeer());
}
}
@@ -672,12 +674,12 @@
if(status != NOT_FINISHED) {
if(nodesWaitingForCompletion.size() !=
waiters.length) {
// Added another one
- Logger.minor(this, "Looping
(mf==null): waiters="+waiters.length+" but
waiting="+nodesWaitingForCompletion.size());
+ if(logMINOR) Logger.minor(this,
"Looping (mf==null): waiters="+waiters.length+" but
waiting="+nodesWaitingForCompletion.size());
continue;
}
if(waitForCompletedTransfers(waiters,
timeout, noTimeLeft)) {
synchronized(CHKInsertSender.this) {
- Logger.minor(this, "All
transfers completed (1) on "+uid);
+ if(logMINOR)
Logger.minor(this, "All transfers completed (1) on "+uid);
allTransfersCompleted =
true;
CHKInsertSender.this.notifyAll();
}
@@ -691,7 +693,7 @@
}
}
synchronized(CHKInsertSender.this) {
- Logger.minor(this, "All
transfers completed (2) on "+uid);
+ if(logMINOR)
Logger.minor(this, "All transfers completed (2) on "+uid);
allTransfersCompleted =
true;
CHKInsertSender.this.notifyAll();
}
@@ -746,11 +748,11 @@
} else {
if(nodesWaitingForCompletion.size() >
waiters.length) {
// Added another one
- Logger.minor(this, "Looping:
waiters="+waiters.length+" but waiting="+nodesWaitingForCompletion.size());
+ if(logMINOR) Logger.minor(this,
"Looping: waiters="+waiters.length+" but
waiting="+nodesWaitingForCompletion.size());
continue;
}
if(noTimeLeft) {
- Logger.minor(this, "Overall
timeout on "+CHKInsertSender.this);
+ if(logMINOR) Logger.minor(this,
"Overall timeout on "+CHKInsertSender.this);
for(int
i=0;i<waiters.length;i++) {
if(!waiters[i].pn.isRoutable()) continue;
if(!waiters[i].receivedCompletionNotice)
@@ -759,7 +761,7 @@
waiters[i].completedTransfer(false);
}
synchronized(CHKInsertSender.this) {
- Logger.minor(this, "All
transfers completed (2) on "+uid);
+ if(logMINOR)
Logger.minor(this, "All transfers completed (2) on "+uid);
transferTimedOut = true;
allTransfersCompleted =
true;
CHKInsertSender.this.notifyAll();
@@ -786,7 +788,7 @@
if(!completedTransfers) {
try {
if(!noTimeLeft) {
- Logger.minor(this,
"Waiting for completion ("+timeout+"ms)");
+ if(logMINOR)
Logger.minor(this, "Waiting for completion ("+timeout+"ms)");
nodesWaitingForCompletion.wait(timeout);
} else {
// Timed out
@@ -806,7 +808,7 @@
}
if(completedTransfers) {
// All done!
- Logger.minor(this, "Completed,
status="+getStatusString()+", nothing left to wait for for "+uid+" .");
+ if(logMINOR) Logger.minor(this, "Completed,
status="+getStatusString()+", nothing left to wait for for "+uid+" .");
synchronized(CHKInsertSender.this) {
allTransfersCompleted = true;
CHKInsertSender.this.notifyAll();
Modified: trunk/freenet/src/freenet/node/CPUAdjustingSwapRequestInterval.java
===================================================================
--- trunk/freenet/src/freenet/node/CPUAdjustingSwapRequestInterval.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/node/CPUAdjustingSwapRequestInterval.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -59,7 +59,8 @@
}
if(currentValue < min) currentValue = min;
if(currentValue > max) currentValue = max;
- Logger.minor(this, "CPU usage: "+cpuUsage+" target
"+targetCPUUsage+" current value: "+currentValue);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "CPU usage: "+cpuUsage+" target
"+targetCPUUsage+" current value: "+currentValue);
}
} catch (Throwable t) {
Logger.error(this, "Caught "+t+" in "+this, t);
Modified: trunk/freenet/src/freenet/node/CPUUsageMonitor.java
===================================================================
--- trunk/freenet/src/freenet/node/CPUUsageMonitor.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/CPUUsageMonitor.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -139,7 +139,8 @@
tsNew = new TickStat();
} else {
if (!tsNew.read(proc)) {
- Logger.minor(this, "Failed to parse /proc");
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Failed to parse /proc");
return -1;
}
lastCPULoadEstimate = tsNew.calculate(tsOld);
Modified: trunk/freenet/src/freenet/node/DNSRequester.java
===================================================================
--- trunk/freenet/src/freenet/node/DNSRequester.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/DNSRequester.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -53,7 +53,8 @@
PeerNode[] nodes = pm.myPeers;
long now = System.currentTimeMillis();
if((now - lastLogTime) > 1000) {
- Logger.minor(this, "Processing DNS Requests (log rate-limited)");
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Processing DNS Requests (log
rate-limited)");
lastLogTime = now;
}
for(int i=0;i<nodes.length;i++) {
Modified: trunk/freenet/src/freenet/node/FNPPacketMangler.java
===================================================================
--- trunk/freenet/src/freenet/node/FNPPacketMangler.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/node/FNPPacketMangler.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -29,6 +29,7 @@
*/
public class FNPPacketMangler implements LowLevelFilter {
+ private static boolean logMINOR;
final Node node;
final PeerManager pm;
final UdpSocketManager usm;
@@ -73,7 +74,8 @@
*/
public void process(byte[] buf, int offset, int length, Peer peer) {
node.random.acceptTimerEntropy(fnpTimingSource, 0.25);
- Logger.minor(this, "Packet length "+length+" from "+peer);
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "Packet length "+length+" from
"+peer);
/**
* Look up the Peer.
@@ -85,7 +87,7 @@
PeerNode pn;
if(opn != null) {
- Logger.minor(this, "Trying exact match");
+ if(logMINOR) Logger.minor(this, "Trying exact match");
if(length > HEADERS_LENGTH_MINIMUM) {
if(tryProcess(buf, offset, length,
opn.getCurrentKeyTracker())) return;
// Try with old key
@@ -126,9 +128,9 @@
if(tryProcessAuth(buf, offset, length, pn, peer)) return;
}
}
- if((opn != null) && !opn.isConnected())
- Logger.minor(this,"Unmatchable packet from "+peer);
- else
+ if((opn != null) && !opn.isConnected()) {
+ if(logMINOR) Logger.minor(this,"Unmatchable packet from "+peer);
+ } else
Logger.error(this,"Unmatchable packet from "+peer);
}
@@ -143,14 +145,14 @@
*/
private boolean tryProcessAuth(byte[] buf, int offset, int length,
PeerNode opn, Peer peer) {
BlockCipher authKey = opn.incomingSetupCipher;
- Logger.minor(this, "Decrypt key:
"+HexUtil.bytesToHex(opn.incomingSetupKey)+" for "+peer+" : "+opn);
+ if(logMINOR) Logger.minor(this, "Decrypt key:
"+HexUtil.bytesToHex(opn.incomingSetupKey)+" for "+peer+" : "+opn);
// Does the packet match IV E( H(data) data ) ?
PCFBMode pcfb = new PCFBMode(authKey);
int ivLength = pcfb.lengthIV();
MessageDigest md = getDigest();
int digestLength = md.getDigestLength();
if(length < digestLength + ivLength + 4) {
- Logger.minor(this, "Too short: "+length+" should be at least
"+(digestLength + ivLength + 4));
+ if(logMINOR) Logger.minor(this, "Too short: "+length+" should be
at least "+(digestLength + ivLength + 4));
return false;
}
// IV at the beginning
@@ -167,9 +169,9 @@
int byte1 = ((pcfb.decipher(buf[dataStart-2])) & 0xff);
int byte2 = ((pcfb.decipher(buf[dataStart-1])) & 0xff);
int dataLength = (byte1 << 8) + byte2;
- Logger.minor(this, "Data length: "+dataLength+" (1 = "+byte1+" 2 =
"+byte2+")");
+ if(logMINOR) Logger.minor(this, "Data length: "+dataLength+" (1 =
"+byte1+" 2 = "+byte2+")");
if(dataLength > length - (ivLength+hash.length+2)) {
- Logger.minor(this, "Invalid data length "+dataLength+" ("+(length
- (ivLength+hash.length+2))+") in tryProcessAuth");
+ if(logMINOR) Logger.minor(this, "Invalid data length
"+dataLength+" ("+(length - (ivLength+hash.length+2))+") in tryProcessAuth");
return false;
}
// Decrypt the data
@@ -185,7 +187,7 @@
processDecryptedAuth(payload, opn, peer);
return true;
} else {
- Logger.minor(this, "Incorrect hash in tryProcessAuth for "+peer+"
(length="+dataLength+"): \nreal hash="+HexUtil.bytesToHex(realHash)+"\n bad
hash="+HexUtil.bytesToHex(hash));
+ if(logMINOR) Logger.minor(this, "Incorrect hash in tryProcessAuth
for "+peer+" (length="+dataLength+"): \nreal
hash="+HexUtil.bytesToHex(realHash)+"\n bad hash="+HexUtil.bytesToHex(hash));
return false;
}
}
@@ -195,7 +197,7 @@
* @param payload The packet payload, after it has been decrypted.
*/
private void processDecryptedAuth(byte[] payload, PeerNode pn, Peer
replyTo) {
- Logger.minor(this, "Processing decrypted auth packet from "+replyTo+"
for "+pn);
+ if(logMINOR) Logger.minor(this, "Processing decrypted auth packet from
"+replyTo+" for "+pn);
/* Format:
* 1 byte - version number (0)
* 1 byte - negotiation type (0 = simple DH, will not be supported
when implement JFKi)
@@ -221,7 +223,7 @@
}
long now = System.currentTimeMillis();
int delta = (int) (now - pn.lastSentPacketTime());
- Logger.minor(this, "Received auth packet for "+pn.getPeer()+"
(pt="+packetType+", v="+version+", nt="+negType+") (last packet sent
"+delta+"ms ago) from "+replyTo+"");
+ if(logMINOR) Logger.minor(this, "Received auth packet for
"+pn.getPeer()+" (pt="+packetType+", v="+version+", nt="+negType+") (last
packet sent "+delta+"ms ago) from "+replyTo+"");
// We keep one DiffieHellmanContext per node ONLY
/*
* Now, to the real meat
@@ -315,7 +317,7 @@
*/
private void sendFirstHalfDHPacket(int phase, NativeBigInteger integer,
PeerNode pn, Peer replyTo) {
long time1 = System.currentTimeMillis();
- Logger.minor(this, "Sending ("+phase+") "+integer.toHexString()+" to
"+pn.getPeer());
+ if(logMINOR) Logger.minor(this, "Sending ("+phase+")
"+integer.toHexString()+" to "+pn.getPeer());
byte[] data = integer.toByteArray();
int targetLength = DiffieHellman.modulusLengthInBytes();
if(data.length != targetLength) {
@@ -330,7 +332,7 @@
}
data = newData;
}
- Logger.minor(this, "Processed: "+HexUtil.bytesToHex(data));
+ if(logMINOR) Logger.minor(this, "Processed:
"+HexUtil.bytesToHex(data));
long time2 = System.currentTimeMillis();
if((time2 - time1) > 200) {
Logger.error(this, "sendFirstHalfDHPacket: time2 is more than 200ms
after time1 ("+(time2 - time1)+") working on "+replyTo+" of "+pn.getName());
@@ -356,7 +358,7 @@
output[1] = (byte) negType;
output[2] = (byte) phase;
System.arraycopy(data, 0, output, 3, data.length);
- Logger.minor(this, "Sending auth packet for "+pn.getPeer()+"
(ph="+phase+", v="+version+", nt="+negType+") (last packet sent "+delta+"ms
ago) to "+replyTo+" data.length="+data.length);
+ if(logMINOR) Logger.minor(this, "Sending auth packet for
"+pn.getPeer()+" (ph="+phase+", v="+version+", nt="+negType+") (last packet
sent "+delta+"ms ago) to "+replyTo+" data.length="+data.length);
sendAuthPacket(output, pn, replyTo);
}
@@ -369,19 +371,19 @@
throw new IllegalStateException("Cannot send auth packet: too
long: "+length);
}
BlockCipher cipher = pn.outgoingSetupCipher;
- Logger.minor(this, "Outgoing cipher:
"+HexUtil.bytesToHex(pn.outgoingSetupKey));
+ if(logMINOR) Logger.minor(this, "Outgoing cipher:
"+HexUtil.bytesToHex(pn.outgoingSetupKey));
PCFBMode pcfb = new PCFBMode(cipher);
byte[] iv = new byte[pcfb.lengthIV()];
node.random.nextBytes(iv);
MessageDigest md = getDigest();
byte[] hash = md.digest(output);
- Logger.minor(this, "Data hash: "+HexUtil.bytesToHex(hash));
+ if(logMINOR) Logger.minor(this, "Data hash:
"+HexUtil.bytesToHex(hash));
byte[] data = new byte[iv.length + hash.length + 2 /* length */ +
output.length];
pcfb.reset(iv);
System.arraycopy(iv, 0, data, 0, iv.length);
pcfb.blockEncipher(hash, 0, hash.length);
System.arraycopy(hash, 0, data, iv.length, hash.length);
- Logger.minor(this, "Payload length: "+length);
+ if(logMINOR) Logger.minor(this, "Payload length: "+length);
data[hash.length+iv.length] = (byte) pcfb.encipher((byte)(length>>8));
data[hash.length+iv.length+1] = (byte) pcfb.encipher((byte)length);
pcfb.blockEncipher(output, 0, output.length);
@@ -391,7 +393,7 @@
} catch (LocalAddressException e) {
Logger.error(this, "Tried to send auth packet to local
address: "+replyTo+" for "+pn);
}
- Logger.minor(this, "Sending auth packet (long) to "+replyTo+" - size
"+data.length+" data length: "+output.length);
+ if(logMINOR) Logger.minor(this, "Sending auth packet (long) to
"+replyTo+" - size "+data.length+" data length: "+output.length);
}
private void sendPacket(byte[] data, Peer replyTo, PeerNode pn, int
alreadyReportedBytes) throws LocalAddressException {
@@ -476,7 +478,7 @@
private DiffieHellmanContext processDHZeroOrOne(int phase, byte[] payload,
PeerNode pn) {
if((phase == 0) && pn.hasLiveHandshake(System.currentTimeMillis())) {
- Logger.minor(this, "Rejecting phase "+phase+" handshake on "+pn+"
- already running one");
+ if(logMINOR) Logger.minor(this, "Rejecting phase "+phase+"
handshake on "+pn+" - already running one");
return null;
}
@@ -503,7 +505,7 @@
pn.setDHContext(ctx);
}
ctx.setOtherSideExponential(a);
- Logger.minor(this, "His exponential: "+a.toHexString());
+ if(logMINOR) Logger.minor(this, "His exponential: "+a.toHexString());
// REDFLAG: This is of course easily DoS'ed if you know the node.
// We will fix this by means of JFKi.
return ctx;
@@ -528,10 +530,10 @@
private boolean tryProcess(byte[] buf, int offset, int length, KeyTracker
tracker) {
// Need to be able to call with tracker == null to simplify code above
if(tracker == null) {
- Logger.minor(this, "Tracker == null");
+ if(logMINOR) Logger.minor(this, "Tracker == null");
return false;
}
- Logger.minor(this,"Entering tryProcess:
"+Fields.hashCode(buf)+","+offset+","+length+","+tracker);
+ if(logMINOR) Logger.minor(this,"Entering tryProcess:
"+Fields.hashCode(buf)+","+offset+","+length+","+tracker);
/**
* E_pcbc_session(H(seq+random+data)) E_pcfb_session(seq+random+data)
*
@@ -541,10 +543,10 @@
*/
BlockCipher sessionCipher = tracker.sessionCipher;
if(sessionCipher == null) {
- Logger.minor(this, "No cipher");
+ if(logMINOR) Logger.minor(this, "No cipher");
return false;
}
- Logger.minor(this, "Decrypting with
"+HexUtil.bytesToHex(tracker.sessionKey));
+ if(logMINOR) Logger.minor(this, "Decrypting with
"+HexUtil.bytesToHex(tracker.sessionKey));
int blockSize = sessionCipher.getBlockSize() >> 3;
if(sessionCipher.getKeySize() != sessionCipher.getBlockSize())
throw new IllegalStateException("Block size must be equal to key
size");
@@ -576,8 +578,8 @@
(seqBuf[3] & 0xff);
int targetSeqNumber = tracker.highestReceivedIncomingSeqNumber();
- Logger.minor(this, "Target seq: "+targetSeqNumber);
- Logger.minor(this, "Sequence number:
"+seqNumber+"="+Integer.toHexString(seqNumber));
+ if(logMINOR) Logger.minor(this, "Target seq: "+targetSeqNumber);
+ if(logMINOR) Logger.minor(this, "Sequence number:
"+seqNumber+"="+Integer.toHexString(seqNumber));
if(seqNumber == -1) {
// Ack/resendreq-only packet
@@ -587,7 +589,7 @@
if((targetSeqNumber != -1) && (Math.abs(targetSeqNumber -
seqNumber) > MAX_PACKETS_IN_FLIGHT))
return false;
}
- Logger.minor(this, "Sequence number received: "+seqNumber);
+ if(logMINOR) Logger.minor(this, "Sequence number received:
"+seqNumber);
// Plausible, so lets decrypt the rest of the data
@@ -612,7 +614,7 @@
// Check the hash
if(!java.util.Arrays.equals(packetHash, realHash)) {
- Logger.minor(this, "Packet possibly from "+tracker+" hash does not
match:\npacketHash="+
+ if(logMINOR) Logger.minor(this, "Packet possibly from "+tracker+"
hash does not match:\npacketHash="+
HexUtil.bytesToHex(packetHash)+"\n
realHash="+HexUtil.bytesToHex(realHash)+" ("+(length-HASH_LENGTH)+" bytes
payload)");
return false;
}
@@ -623,9 +625,9 @@
for(int i=0;i<md.getDigestLength();i++) {
packetHash[i] ^= buf[offset+i];
}
- Logger.minor(this, "Contributing entropy");
+ if(logMINOR) Logger.minor(this, "Contributing entropy");
node.random.acceptEntropyBytes(myPacketDataSource, packetHash, 0,
md.getDigestLength(), 0.5);
- Logger.minor(this, "Contributed entropy");
+ if(logMINOR) Logger.minor(this, "Contributed entropy");
// Lots more to do yet!
processDecryptedData(plaintext, seqNumber, tracker, length -
plaintext.length);
@@ -708,10 +710,10 @@
(decrypted[ptr+2] & 0xff)) << 8) + (decrypted[ptr+3] &
0xff);
ptr+=4;
- Logger.minor(this, "Reference sequence number: "+referenceSeqNumber);
+ if(logMINOR) Logger.minor(this, "Reference sequence number:
"+referenceSeqNumber);
int ackCount = decrypted[ptr++] & 0xff;
- Logger.minor(this, "Acks: "+ackCount);
+ if(logMINOR) Logger.minor(this, "Acks: "+ackCount);
int[] acks = new int[ackCount];
for(int i=0;i<ackCount;i++) {
@@ -726,7 +728,7 @@
tracker.acknowledgedPackets(acks);
int retransmitCount = decrypted[ptr++] & 0xff;
- Logger.minor(this, "Retransmit requests: "+retransmitCount);
+ if(logMINOR) Logger.minor(this, "Retransmit requests:
"+retransmitCount);
for(int i=0;i<retransmitCount;i++) {
int offset = decrypted[ptr++] & 0xff;
@@ -734,12 +736,12 @@
Logger.error(this, "Packet not long enough at byte "+ptr+" on
"+tracker);
}
int realSeqNo = referenceSeqNumber - offset;
- Logger.minor(this, "RetransmitRequest: "+realSeqNo);
+ if(logMINOR) Logger.minor(this, "RetransmitRequest: "+realSeqNo);
tracker.resendPacket(realSeqNo);
}
int ackRequestsCount = decrypted[ptr++] & 0xff;
- Logger.minor(this, "Ack requests: "+ackRequestsCount);
+ if(logMINOR) Logger.minor(this, "Ack requests: "+ackRequestsCount);
// These two are relative to our outgoing packet number
// Because they relate to packets we have sent.
@@ -749,12 +751,12 @@
Logger.error(this, "Packet not long enough at byte "+ptr+" on
"+tracker);
}
int realSeqNo = realSeqNumber - offset;
- Logger.minor(this, "AckRequest: "+realSeqNo);
+ if(logMINOR) Logger.minor(this, "AckRequest: "+realSeqNo);
tracker.receivedAckRequest(realSeqNo);
}
int forgottenCount = decrypted[ptr++] & 0xff;
- Logger.minor(this, "Forgotten packets: "+forgottenCount);
+ if(logMINOR) Logger.minor(this, "Forgotten packets: "+forgottenCount);
for(int i=0;i<forgottenCount;i++) {
int offset = decrypted[ptr++] & 0xff;
@@ -793,7 +795,7 @@
Logger.error(this, "Message longer than remaining space:
"+length);
return;
}
- Logger.minor(this, "Message "+i+" length "+length+", hash code:
"+Fields.hashCode(decrypted, ptr, length));
+ if(logMINOR) Logger.minor(this, "Message "+i+" length "+length+",
hash code: "+Fields.hashCode(decrypted, ptr, length));
Message m = usm.decodePacket(decrypted, ptr, length, tracker.pn, 1
+ (overhead / messages));
ptr+=length;
if(m != null) {
@@ -801,7 +803,7 @@
usm.checkFilters(m);
}
}
- Logger.minor(this, "Done");
+ if(logMINOR) Logger.minor(this, "Done");
}
/**
@@ -812,7 +814,7 @@
if(!dontRequeue) {
requeueLogString = ", requeueing";
}
- Logger.minor(this, "processOutgoingOrRequeue "+messages.length+"
messages for "+pn+" ("+neverWaitForPacketNumber+")");
+ if(logMINOR) Logger.minor(this, "processOutgoingOrRequeue
"+messages.length+" messages for "+pn+" ("+neverWaitForPacketNumber+")");
byte[][] messageData = new byte[messages.length][];
int[] alreadyReported = new int[messages.length];
MessageItem[] newMsgs = new MessageItem[messages.length];
@@ -828,7 +830,7 @@
byte[] buf = mi.getData(pn);
KeyTracker kt = pn.getCurrentKeyTracker();
if(kt == null) {
- Logger.minor(this, "kt = null");
+ if(logMINOR) Logger.minor(this, "kt = null");
pn.requeueMessageItems(messages, i, messages.length-i,
false, "kt = null");
return;
}
@@ -845,7 +847,7 @@
}
return;
} catch (WouldBlockException e) {
- Logger.minor(this, "Caught "+e+" while sending messages
("+mi_name+") to "+pn.getPeer()+requeueLogString, e);
+ if(logMINOR) Logger.minor(this, "Caught "+e+" while
sending messages ("+mi_name+") to "+pn.getPeer()+requeueLogString, e);
// Requeue
if(!dontRequeue) {
pn.requeueMessageItems(messages, 0, x, false,
"WouldBlockException(1a)");
@@ -853,7 +855,7 @@
}
return;
} catch (KeyChangedException e) {
- Logger.minor(this, "Caught "+e+" while sending messages
("+mi_name+") to "+pn.getPeer()+requeueLogString, e);
+ if(logMINOR) Logger.minor(this, "Caught "+e+" while
sending messages ("+mi_name+") to "+pn.getPeer()+requeueLogString, e);
// Requeue
if(!dontRequeue) {
pn.requeueMessageItems(messages, 0, x, false,
"KeyChangedException(1a)");
@@ -876,7 +878,7 @@
alreadyReported[x] = mi.alreadyReportedBytes;
x++;
if(mi.cb != null) callbacksCount += mi.cb.length;
- Logger.minor(this, "Sending: "+mi+" length "+data.length+" cb
"+mi.cb);
+ if(logMINOR) Logger.minor(this, "Sending: "+mi+" length
"+data.length+" cb "+mi.cb);
length += (data.length + 2);
}
}
@@ -919,7 +921,7 @@
pn.requeueMessageItems(messages, 0, messages.length,
false, "NotConnectedException(2)");
return;
} catch (WouldBlockException e) {
- Logger.minor(this, "Caught "+e+" while sending messages
("+mi_name+") to "+pn.getPeer()+requeueLogString, e);
+ if(logMINOR) Logger.minor(this, "Caught "+e+" while sending
messages ("+mi_name+") to "+pn.getPeer()+requeueLogString, e);
// Requeue
if(!dontRequeue)
pn.requeueMessageItems(messages, 0, messages.length,
false, "WouldBlockException(2)");
@@ -973,7 +975,7 @@
pn.requeueMessageItems(messages, lastIndex,
messages.length - lastIndex, false, "NotConnectedException(3)");
return;
} catch (WouldBlockException e) {
- Logger.minor(this, "Caught "+e+" while sending
messages ("+mi_name+") to "+pn.getPeer()+requeueLogString, e);
+ if(logMINOR) Logger.minor(this, "Caught "+e+"
while sending messages ("+mi_name+") to "+pn.getPeer()+requeueLogString, e);
// Requeue
if(!dontRequeue)
pn.requeueMessageItems(messages, lastIndex,
messages.length - lastIndex, false, "WouldBlockException(3)");
@@ -1009,7 +1011,7 @@
*/
private void innerProcessOutgoing(byte[][] messageData, int start, int
length, int bufferLength,
PeerNode pn, boolean neverWaitForPacketNumber,
AsyncMessageCallback[] callbacks, int alreadyReportedBytes) throws
NotConnectedException, WouldBlockException, PacketSequenceException {
- Logger.minor(this,
"innerProcessOutgoing(...,"+start+","+length+","+bufferLength+")");
+ if(logMINOR) Logger.minor(this,
"innerProcessOutgoing(...,"+start+","+length+","+bufferLength+")");
byte[] buf = new byte[bufferLength];
buf[0] = (byte)length;
int loc = 1;
@@ -1031,7 +1033,7 @@
* @throws WouldBlockException
*/
public void processOutgoing(byte[] buf, int offset, int length,
PeerContext peer, int alreadyReportedBytes) throws NotConnectedException,
PacketSequenceException, WouldBlockException {
- Logger.minor(this, "processOutgoing(buf, "+offset+", "+length+",
"+peer.getPeer());
+ if(logMINOR) Logger.minor(this, "processOutgoing(buf, "+offset+",
"+length+", "+peer.getPeer());
if(!(peer instanceof PeerNode))
throw new IllegalArgumentException();
PeerNode pn = (PeerNode)peer;
@@ -1068,7 +1070,7 @@
int alreadyReportedBytes) throws NotConnectedException,
PacketSequenceException, WouldBlockException {
while(true) {
try {
- Logger.minor(this, "At beginning of processOutgoingPreformatted
loop for "+peer.getPeer());
+ if(logMINOR) Logger.minor(this, "At beginning of
processOutgoingPreformatted loop for "+peer.getPeer());
KeyTracker tracker = peer.getCurrentKeyTracker();
if(tracker == null) {
Logger.normal(this, "Dropping packet: Not connected to
"+peer.getPeer()+" yet(1)");
@@ -1146,7 +1148,7 @@
* @throws WouldBlockException If we cannot allocate a packet number
because it would block.
*/
public void processOutgoingPreformatted(byte[] buf, int offset, int
length, KeyTracker tracker, int packetNumber, AsyncMessageCallback[] callbacks,
int alreadyReportedBytes) throws KeyChangedException, NotConnectedException,
PacketSequenceException, WouldBlockException {
- if(Logger.shouldLog(Logger.MINOR, this)) {
+ if(logMINOR) {
String log =
"processOutgoingPreformatted("+Fields.hashCode(buf)+",
"+offset+","+length+","+tracker+","+packetNumber+",";
if(callbacks == null) log += "null";
else log += (""+callbacks.length+(callbacks.length >= 1 ?
String.valueOf(callbacks[0]) : ""));
@@ -1182,7 +1184,7 @@
seqNumber =
tracker.allocateOutgoingPacketNumberNeverBlock();
}
- Logger.minor(this, "Sequence number (sending): "+seqNumber+"
("+packetNumber+") to "+tracker.pn.getPeer());
+ if(logMINOR) Logger.minor(this, "Sequence number (sending):
"+seqNumber+" ("+packetNumber+") to "+tracker.pn.getPeer());
/** The last sent sequence number, so that we can refer to packets
* sent after this packet was originally sent (it may be a resend) */
@@ -1196,7 +1198,7 @@
ackRequests = tracker.grabAckRequests();
realSeqNumber = tracker.getLastOutgoingSeqNumber();
otherSideSeqNumber = tracker.highestReceivedIncomingSeqNumber();
- Logger.minor(this, "otherSideSeqNumber: "+otherSideSeqNumber);
+ if(logMINOR) Logger.minor(this, "otherSideSeqNumber:
"+otherSideSeqNumber);
}
int packetLength = acks.length + resendRequests.length +
ackRequests.length + 4 + 1 + length + 4 + 4 + RANDOM_BYTES_LENGTH;
@@ -1214,7 +1216,7 @@
plaintext[ptr++] = (byte)(seqNumber >> 8);
plaintext[ptr++] = (byte)seqNumber;
- Logger.minor(this, "Getting random junk");
+ if(logMINOR) Logger.minor(this, "Getting random junk");
node.random.nextBytes(randomJunk);
System.arraycopy(randomJunk, 0, plaintext, ptr, RANDOM_BYTES_LENGTH);
ptr += RANDOM_BYTES_LENGTH;
@@ -1238,7 +1240,7 @@
plaintext[ptr++] = (byte) acks.length;
for(int i=0;i<acks.length;i++) {
int ackSeq = acks[i];
- Logger.minor(this, "Acking "+ackSeq);
+ if(logMINOR) Logger.minor(this, "Acking "+ackSeq);
int offsetSeq = otherSideSeqNumber - ackSeq;
if((offsetSeq > 255) || (offsetSeq < 0))
throw new PacketSequenceException("bad ack offset "+offsetSeq+
@@ -1249,7 +1251,7 @@
plaintext[ptr++] = (byte) resendRequests.length;
for(int i=0;i<resendRequests.length;i++) {
int reqSeq = resendRequests[i];
- Logger.minor(this, "Resend req: "+reqSeq);
+ if(logMINOR) Logger.minor(this, "Resend req: "+reqSeq);
int offsetSeq = otherSideSeqNumber - reqSeq;
if((offsetSeq > 255) || (offsetSeq < 0))
throw new PacketSequenceException("bad resend request offset
"+offsetSeq+
@@ -1258,10 +1260,10 @@
}
plaintext[ptr++] = (byte) ackRequests.length;
- Logger.minor(this, "Ackrequests: "+ackRequests.length);
+ if(logMINOR) Logger.minor(this, "Ackrequests: "+ackRequests.length);
for(int i=0;i<ackRequests.length;i++) {
int ackReqSeq = ackRequests[i];
- Logger.minor(this, "Ack request "+i+": "+ackReqSeq);
+ if(logMINOR) Logger.minor(this, "Ack request "+i+": "+ackReqSeq);
// Relative to packetNumber - we are asking them to ack
// a packet we sent to them.
int offsetSeq = realSeqNumber - ackReqSeq;
@@ -1286,10 +1288,10 @@
tracker.sentPacket(saveable, seqNumber, callbacks);
}
- Logger.minor(this, "Sending...");
+ if(logMINOR) Logger.minor(this, "Sending...");
processOutgoingFullyFormatted(plaintext, tracker, callbacks,
alreadyReportedBytes);
- Logger.minor(this, "Sent packet");
+ if(logMINOR) Logger.minor(this, "Sent packet");
}
/**
@@ -1299,7 +1301,7 @@
*/
private void processOutgoingFullyFormatted(byte[] plaintext, KeyTracker
kt, AsyncMessageCallback[] callbacks, int alreadyReportedBytes) {
BlockCipher sessionCipher = kt.sessionCipher;
- Logger.minor(this, "Encrypting with
"+HexUtil.bytesToHex(kt.sessionKey));
+ if(logMINOR) Logger.minor(this, "Encrypting with
"+HexUtil.bytesToHex(kt.sessionKey));
if(sessionCipher == null) {
Logger.error(this, "Dropping packet send - have not handshaked
yet");
return;
@@ -1332,7 +1334,7 @@
digestTemp = md.digest();
- Logger.minor(this, "\nHash: "+HexUtil.bytesToHex(digestTemp));
+ if(logMINOR) Logger.minor(this, "\nHash:
"+HexUtil.bytesToHex(digestTemp));
// Put plaintext in output
System.arraycopy(digestTemp, 0, output, 0, digestLength);
@@ -1343,7 +1345,7 @@
System.arraycopy(digestTemp, 0, output, 0, digestLength);
// Yay, we have an encrypted hash
- Logger.minor(this, "\nEncrypted: "+HexUtil.bytesToHex(digestTemp)+"
("+plaintext.length+" bytes plaintext)");
+ if(logMINOR) Logger.minor(this, "\nEncrypted:
"+HexUtil.bytesToHex(digestTemp)+" ("+plaintext.length+" bytes plaintext)");
PCFBMode pcfb = new PCFBMode(sessionCipher, digestTemp);
pcfb.blockEncipher(output, digestLength, plaintext.length);
@@ -1353,7 +1355,7 @@
// We have a packet
// Send it
- Logger.minor(this,"Sending packet of length "+output.length+" (" +
Fields.hashCode(output) + " to "+kt.pn);
+ if(logMINOR) Logger.minor(this,"Sending packet of length
"+output.length+" (" + Fields.hashCode(output) + " to "+kt.pn);
// pn.getPeer() cannot be null
try {
@@ -1369,11 +1371,11 @@
* @param pn
*/
public void sendHandshake(PeerNode pn) {
- Logger.minor(this, "Possibly sending handshake to "+pn);
+ if(logMINOR) Logger.minor(this, "Possibly sending handshake to "+pn);
DiffieHellmanContext ctx;
Peer[] handshakeIPs;
if(!pn.shouldSendHandshake()) {
- Logger.debug(this, "Not sending handshake to "+pn.getPeer()+"
because pn.shouldSendHandshake() returned false");
+ if(logMINOR) Logger.minor(this, "Not sending handshake to
"+pn.getPeer()+" because pn.shouldSendHandshake() returned false");
return;
}
long firstTime = System.currentTimeMillis();
@@ -1403,11 +1405,11 @@
for(int i=0;i<handshakeIPs.length;i++){
long innerLoopTime1 = System.currentTimeMillis();
if(handshakeIPs[i].getAddress(false) == null) {
- Logger.minor(this, "Not sending handshake to
"+handshakeIPs[i]+" for "+pn.getPeer()+" because the DNS lookup failed or it's
a currently unsupported IPv6 address");
+ if(logMINOR) Logger.minor(this, "Not sending handshake
to "+handshakeIPs[i]+" for "+pn.getPeer()+" because the DNS lookup failed or
it's a currently unsupported IPv6 address");
continue;
}
if(!pn.allowLocalAddresses() &&
!handshakeIPs[i].isRealInternetAddress(false, false)) {
- Logger.minor(this, "Not sending handshake to
"+handshakeIPs[i]+" for "+pn.getPeer()+" because it's not a real Internet
address and metadata.allowLocalAddresses is not true");
+ if(logMINOR) Logger.minor(this, "Not sending handshake
to "+handshakeIPs[i]+" for "+pn.getPeer()+" because it's not a real Internet
address and metadata.allowLocalAddresses is not true");
continue;
}
long innerLoopTime2 = System.currentTimeMillis();
Modified: trunk/freenet/src/freenet/node/IPDetectorPluginManager.java
===================================================================
--- trunk/freenet/src/freenet/node/IPDetectorPluginManager.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/node/IPDetectorPluginManager.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -19,6 +19,7 @@
*/
public class IPDetectorPluginManager {
+ static boolean logMINOR;
private final NodeIPDetector detector;
private final Ticker ticker;
private final Node node;
@@ -30,6 +31,7 @@
private SimpleUserAlert connectedAlert;
IPDetectorPluginManager(Node node, NodeIPDetector detector) {
+ logMINOR = Logger.shouldLog(Logger.MINOR, getClass());
plugins = new FredPluginIPDetector[0];
this.node = node;
this.ticker = node.ps;
@@ -143,21 +145,22 @@
* Do we need to run a plugin?
*/
public void maybeRun() {
- Logger.minor(this, "Maybe running IP detection plugins", new
Exception("debug"));
+ logMINOR = Logger.shouldLog(Logger.MINOR, getClass());
+ if(logMINOR) Logger.minor(this, "Maybe running IP detection
plugins", new Exception("debug"));
PeerNode[] peers = node.getPeerNodes();
PeerNode[] conns = node.getConnectedPeers();
Peer[] nodeAddrs = detector.getPrimaryIPAddress();
long now = System.currentTimeMillis();
synchronized(this) {
if(runner != null) {
- Logger.minor(this, "Already running IP
detection plugins");
+ if(logMINOR) Logger.minor(this, "Already
running IP detection plugins");
return;
}
// If detect attempt failed to produce an IP in the
last 5 minutes, don't
// try again yet.
if(lastDetectAttemptFailed) {
if(now - lastDetectAttemptEndedTime <
5*60*1000) {
- Logger.minor(this, "Last detect failed
and more than 5 minutes ago");
+ if(logMINOR) Logger.minor(this, "Last
detect failed and more than 5 minutes ago");
return;
} else {
startDetect();
@@ -167,7 +170,7 @@
// We might still be firewalled?
// First, check only once per day or startup
if(now - lastDetectAttemptEndedTime <
24*60*60*1000) {
- Logger.minor(this, "Node has directly
detected IP and we have checked less than 24 hours ago");
+ if(logMINOR) Logger.minor(this, "Node
has directly detected IP and we have checked less than 24 hours ago");
return;
}
@@ -200,7 +203,7 @@
addressesConnected.add(addr);
if(addressesConnected.size() > 2) {
// 3
connected addresses, lets assume we have connectivity.
-
Logger.minor(this, "Node has directly detected IP and has connected to 3 real
IPs");
+
if(logMINOR) Logger.minor(this, "Node has directly detected IP and has
connected to 3 real IPs");
return;
}
}
@@ -213,7 +216,7 @@
}
if(!hasOldPeers) {
// No peers older than 30 minutes
- Logger.minor(this, "Not detecting as
less than 30 minutes old");
+ if(logMINOR) Logger.minor(this, "Not
detecting as less than 30 minutes old");
return;
}
}
@@ -221,7 +224,7 @@
if(peers.length == 0) {
if(now - lastDetectAttemptEndedTime <
6*60*60*1000) {
// No peers, only try every 6 hours.
- Logger.minor(this, "No peers but
detected less than 6 hours ago");
+ if(logMINOR) Logger.minor(this, "No
peers but detected less than 6 hours ago");
return;
} else {
// Must try once!
@@ -244,7 +247,7 @@
PeerNode p = peers[i];
if(!p.isDisabled()) {
maybeUrgent = true;
- Logger.minor(this, "No
connections, but have peers, may detect...");
+ if(logMINOR)
Logger.minor(this, "No connections, but have peers, may detect...");
break;
}
}
@@ -261,7 +264,7 @@
detect = true;
} else {
- Logger.minor(this, "Not urgent;
conns="+conns.length);
+ if(logMINOR) Logger.minor(this, "Not
urgent; conns="+conns.length);
firstTimeUrgent = 0;
}
@@ -287,14 +290,14 @@
}
}
if(count > 2) {
- Logger.minor(this,
"Recently connected peers count: "+count);
+ if(logMINOR)
Logger.minor(this, "Recently connected peers count: "+count);
maybeFake = true;
}
}
}
if(maybeFake) {
- Logger.minor(this, "Possible fake IPs
being fed to us, may detect...");
+ if(logMINOR) Logger.minor(this,
"Possible fake IPs being fed to us, may detect...");
if(firstTimeMaybeFakePeers <= 0)
firstTimeMaybeFakePeers = now;
@@ -304,14 +307,14 @@
}
} else {
- Logger.minor(this, "Not fake");
+ if(logMINOR) Logger.minor(this, "Not
fake");
firstTimeMaybeFakePeers = 0;
}
if(detect) {
if(now - lastDetectAttemptEndedTime <
60*60*1000) {
// Only try every hour
- Logger.minor(this, "Only trying
once per hour");
+ if(logMINOR) Logger.minor(this,
"Only trying once per hour");
return;
}
@@ -324,7 +327,7 @@
}
private void startDetect() {
- Logger.minor(this, "Detecting...");
+ if(logMINOR) Logger.minor(this, "Detecting...");
synchronized(this) {
runner = new DetectorRunner();
Thread t = new Thread(runner);
@@ -344,109 +347,109 @@
}
public void realRun() {
- Logger.minor(this, "Running STUN detection");
+ if(logMINOR) Logger.minor(this, "Running STUN
detection");
try {
- FredPluginIPDetector[] run = plugins;
- Vector v = new Vector();
- for(int i=0;i<run.length;i++) {
- DetectedIP[] detected = null;
- try {
- detected = run[i].getAddress();
- } catch (Throwable t) {
- Logger.error(this, "Caught "+t, t);
+ FredPluginIPDetector[] run = plugins;
+ Vector v = new Vector();
+ for(int i=0;i<run.length;i++) {
+ DetectedIP[] detected = null;
+ try {
+ detected = run[i].getAddress();
+ } catch (Throwable t) {
+ Logger.error(this, "Caught "+t,
t);
+ }
+ if(detected != null) {
+ for(int
j=0;j<detected.length;j++)
+ v.add(detected[j]);
+ }
}
- if(detected != null) {
- for(int j=0;j<detected.length;j++)
- v.add(detected[j]);
- }
- }
- synchronized(IPDetectorPluginManager.this) {
- lastDetectAttemptEndedTime =
System.currentTimeMillis();
- boolean failed = false;
- if(v.isEmpty()) {
- Logger.minor(this, "No IPs found");
- failed = true;
- } else {
- failed = true;
- for(int i=0;i<v.size();i++) {
- DetectedIP ip = (DetectedIP)
v.get(i);
- if(!((ip.publicAddress == null)
|| !IPUtil.checkAddress(ip.publicAddress))) {
- Logger.minor(this,
"Address checked out");
- failed = false;
+ synchronized(IPDetectorPluginManager.this) {
+ lastDetectAttemptEndedTime =
System.currentTimeMillis();
+ boolean failed = false;
+ if(v.isEmpty()) {
+ if(logMINOR) Logger.minor(this,
"No IPs found");
+ failed = true;
+ } else {
+ failed = true;
+ for(int i=0;i<v.size();i++) {
+ DetectedIP ip =
(DetectedIP) v.get(i);
+ if(!((ip.publicAddress
== null) || !IPUtil.checkAddress(ip.publicAddress))) {
+ if(logMINOR)
Logger.minor(this, "Address checked out");
+ failed = false;
+ }
}
}
+ if(failed) {
+ if(logMINOR) Logger.minor(this,
"Failed");
+ lastDetectAttemptFailed = true;
+ return;
+ }
}
- if(failed) {
- Logger.minor(this, "Failed");
- lastDetectAttemptFailed = true;
- return;
- }
- }
- // Now tell the node
- HashMap map = new HashMap();
- for(int i=0;i<v.size();i++) {
- DetectedIP d = (DetectedIP) v.get(i);
- InetAddress addr = d.publicAddress;
- if(!map.containsKey(addr)) {
- map.put(addr, d);
- } else {
- DetectedIP oldD = (DetectedIP)
map.get(addr);
- if(!oldD.equals(d)) {
- if(d.natType !=
DetectedIP.NOT_SUPPORTED) {
- if(oldD.natType <
d.natType) {
- // Higher value
= more restrictive.
- // Assume the
worst.
- map.put(addr,
d);
+ // Now tell the node
+ HashMap map = new HashMap();
+ for(int i=0;i<v.size();i++) {
+ DetectedIP d = (DetectedIP) v.get(i);
+ InetAddress addr = d.publicAddress;
+ if(!map.containsKey(addr)) {
+ map.put(addr, d);
+ } else {
+ DetectedIP oldD = (DetectedIP)
map.get(addr);
+ if(!oldD.equals(d)) {
+ if(d.natType !=
DetectedIP.NOT_SUPPORTED) {
+ if(oldD.natType
< d.natType) {
+ //
Higher value = more restrictive.
+ //
Assume the worst.
+
map.put(addr, d);
+ }
}
}
}
}
- }
- DetectedIP[] list = (DetectedIP[])
map.values().toArray(new DetectedIP[map.size()]);
- int countOpen = 0;
- int countRestricted = 0;
- int countPortRestricted = 0;
- int countSymmetric = 0;
- int countClosed = 0;
- for(int i=0;i<list.length;i++) {
- Logger.minor(this, "Detected IP:
"+list[i].publicAddress+ " : type "+list[i].natType);
- System.out.println("Detected IP:
"+list[i].publicAddress+ " : type "+list[i].natType);
- switch(list[i].natType) {
- case DetectedIP.FULL_CONE_NAT:
- case DetectedIP.FULL_INTERNET:
- countOpen++;
- break;
- case DetectedIP.NO_UDP:
- countClosed++;
- break;
- case DetectedIP.NOT_SUPPORTED:
- // Ignore
- break;
- case DetectedIP.RESTRICTED_CONE_NAT:
- countRestricted++;
- break;
- case DetectedIP.PORT_RESTRICTED_NAT:
- countPortRestricted++;
- break;
- case DetectedIP.SYMMETRIC_NAT:
- case DetectedIP.SYMMETRIC_UDP_FIREWALL:
- countSymmetric++;
- break;
+ DetectedIP[] list = (DetectedIP[])
map.values().toArray(new DetectedIP[map.size()]);
+ int countOpen = 0;
+ int countRestricted = 0;
+ int countPortRestricted = 0;
+ int countSymmetric = 0;
+ int countClosed = 0;
+ for(int i=0;i<list.length;i++) {
+ Logger.normal(this, "Detected IP:
"+list[i].publicAddress+ " : type "+list[i].natType);
+ System.out.println("Detected IP:
"+list[i].publicAddress+ " : type "+list[i].natType);
+ switch(list[i].natType) {
+ case DetectedIP.FULL_CONE_NAT:
+ case DetectedIP.FULL_INTERNET:
+ countOpen++;
+ break;
+ case DetectedIP.NO_UDP:
+ countClosed++;
+ break;
+ case DetectedIP.NOT_SUPPORTED:
+ // Ignore
+ break;
+ case DetectedIP.RESTRICTED_CONE_NAT:
+ countRestricted++;
+ break;
+ case DetectedIP.PORT_RESTRICTED_NAT:
+ countPortRestricted++;
+ break;
+ case DetectedIP.SYMMETRIC_NAT:
+ case DetectedIP.SYMMETRIC_UDP_FIREWALL:
+ countSymmetric++;
+ break;
+ }
}
- }
-
- if(countClosed > 0 && (countOpen + countRestricted +
countPortRestricted + countSymmetric) == 0) {
-
node.clientCore.alerts.register(noConnectionAlert);
- } else if(countSymmetric > 0 && (countOpen +
countRestricted + countPortRestricted == 0)) {
- node.clientCore.alerts.register(symmetricAlert);
- } else if(countPortRestricted > 0 && (countOpen +
countRestricted == 0)) {
-
node.clientCore.alerts.register(portRestrictedAlert);
- } else if(countRestricted > 0 && (countOpen == 0)) {
-
node.clientCore.alerts.register(restrictedAlert);
- } else if(countOpen > 0) {
- node.clientCore.alerts.register(connectedAlert);
- }
- detector.processDetectedIPs(list);
+
+ if(countClosed > 0 && (countOpen +
countRestricted + countPortRestricted + countSymmetric) == 0) {
+
node.clientCore.alerts.register(noConnectionAlert);
+ } else if(countSymmetric > 0 && (countOpen +
countRestricted + countPortRestricted == 0)) {
+
node.clientCore.alerts.register(symmetricAlert);
+ } else if(countPortRestricted > 0 && (countOpen
+ countRestricted == 0)) {
+
node.clientCore.alerts.register(portRestrictedAlert);
+ } else if(countRestricted > 0 && (countOpen ==
0)) {
+
node.clientCore.alerts.register(restrictedAlert);
+ } else if(countOpen > 0) {
+
node.clientCore.alerts.register(connectedAlert);
+ }
+ detector.processDetectedIPs(list);
} finally {
runner = null;
}
Modified: trunk/freenet/src/freenet/node/InsertHandler.java
===================================================================
--- trunk/freenet/src/freenet/node/InsertHandler.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/InsertHandler.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -41,6 +41,7 @@
private Thread runThread;
private final boolean resetNearestLoc;
PartiallyReceivedBlock prb;
+ private static boolean logMINOR;
InsertHandler(Message req, long id, Node node, long startTime) {
this.req = req;
@@ -58,6 +59,7 @@
htl = Node.MAX_HTL;
resetNearestLoc = true;
} else resetNearestLoc = false;
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
}
public String toString() {
@@ -70,7 +72,7 @@
} catch (Throwable t) {
Logger.error(this, "Caught "+t, t);
} finally {
- Logger.minor(this, "Exiting InsertHandler.run() for "+uid);
+ if(logMINOR) Logger.minor(this, "Exiting InsertHandler.run()
for "+uid);
node.unlockUID(uid);
}
}
@@ -84,7 +86,7 @@
try {
source.send(accepted, this);
} catch (NotConnectedException e1) {
- Logger.minor(this, "Lost connection to source");
+ if(logMINOR) Logger.minor(this, "Lost connection to
source");
return;
}
@@ -101,7 +103,7 @@
return;
}
- Logger.minor(this, "Received "+msg);
+ if(logMINOR) Logger.minor(this, "Received "+msg);
if(msg == null) {
try {
@@ -117,7 +119,7 @@
br.sendAborted(RetrievalException.NO_DATAINSERT, "No
DataInsert");
return;
} catch (NotConnectedException e) {
- Logger.minor(this, "Lost connection to source");
+ if(logMINOR) Logger.minor(this, "Lost connection to
source");
return;
}
}
@@ -198,7 +200,7 @@
try {
source.send(m, this);
} catch (NotConnectedException e) {
- Logger.minor(this, "Lost connection to
source");
+ if(logMINOR) Logger.minor(this, "Lost
connection to source");
return;
}
}
@@ -228,7 +230,7 @@
try {
source.send(msg, this);
} catch (NotConnectedException e) {
- Logger.minor(this, "Lost connection to
source");
+ if(logMINOR) Logger.minor(this, "Lost
connection to source");
return;
}
// Might as well store it anyway.
@@ -244,7 +246,7 @@
try {
source.send(msg, this);
} catch (NotConnectedException e) {
- Logger.minor(this, "Lost connection to
source");
+ if(logMINOR) Logger.minor(this, "Lost
connection to source");
return;
}
canCommit = true;
@@ -287,10 +289,10 @@
* verifies, then commit it.
*/
private void finish(int code) {
- Logger.minor(this, "Finishing");
+ if(logMINOR) Logger.minor(this, "Finishing");
maybeCommit();
- Logger.minor(this, "Waiting for completion");
+ if(logMINOR) Logger.minor(this, "Waiting for completion");
// Wait for completion
boolean sentCompletionWasSet;
synchronized(sentCompletionLock) {
@@ -315,9 +317,9 @@
Message m = DMT.createFNPInsertTransfersCompleted(uid, failed);
try {
source.send(m, this);
- Logger.minor(this, "Sent completion: "+failed+" for
"+this);
+ if(logMINOR) Logger.minor(this, "Sent completion:
"+failed+" for "+this);
} catch (NotConnectedException e1) {
- Logger.minor(this, "Not connected: "+source+" for
"+this);
+ if(logMINOR) Logger.minor(this, "Not connected:
"+source+" for "+this);
// May need to commit anyway...
}
}
@@ -331,7 +333,7 @@
totalSent += sender.getTotalSentBytes();
totalReceived += sender.getTotalReceivedBytes();
}
- Logger.minor(this, "Remote CHK insert cost
"+totalSent+"/"+totalReceived+" bytes ("+code+")");
+ if(logMINOR) Logger.minor(this, "Remote CHK insert cost
"+totalSent+"/"+totalReceived+" bytes ("+code+")");
node.remoteChkInsertBytesSentAverage.report(totalSent);
node.remoteChkInsertBytesReceivedAverage.report(totalReceived);
}
@@ -350,9 +352,9 @@
if(!prb.allReceived()) return;
CHKBlock block = new CHKBlock(prb.getBlock(), headers, key);
node.store(block);
- Logger.minor(this, "Committed");
+ if(logMINOR) Logger.minor(this, "Committed");
} catch (CHKVerifyException e) {
- Logger.error(this, "Verify failed in InsertHandler: "+e+" -
headers: "+HexUtil.bytesToHex(headers), e);
+ Logger.error(this, "Verify failed in InsertHandler: "+e+" -
headers: "+HexUtil.bytesToHex(headers), e);
toSend = DMT.createFNPDataInsertRejected(uid,
DMT.DATA_INSERT_REJECTED_VERIFY_FAILED);
} catch (AbortedException e) {
Logger.error(this, "Receive failed: "+e);
@@ -364,7 +366,7 @@
source.sendAsync(toSend, null, 0, this);
} catch (NotConnectedException e) {
// :(
- Logger.minor(this, "Lost connection in "+this+" when sending
FNPDataInsertRejected");
+ if(logMINOR) Logger.minor(this, "Lost connection in "+this+"
when sending FNPDataInsertRejected");
}
}
}
@@ -375,10 +377,10 @@
public class DataReceiver implements Runnable {
public void run() {
- Logger.minor(this, "Receiving data for "+InsertHandler.this);
+ if(logMINOR) Logger.minor(this, "Receiving data for
"+InsertHandler.this);
try {
br.receive();
- Logger.minor(this, "Received data for "+InsertHandler.this);
+ if(logMINOR) Logger.minor(this, "Received data for
"+InsertHandler.this);
maybeCommit();
} catch (RetrievalException e) {
receiveFailed = true;
@@ -389,7 +391,7 @@
} catch (NotConnectedException ex) {
Logger.error(this, "Can't send "+msg+" to "+source+":
"+ex);
}
- Logger.minor(this, "Failed to retrieve: "+e, e);
+ if(logMINOR) Logger.minor(this, "Failed to retrieve: "+e, e);
return;
} catch (Throwable t) {
Logger.error(this, "Caught "+t, t);
Modified: trunk/freenet/src/freenet/node/KeyTracker.java
===================================================================
--- trunk/freenet/src/freenet/node/KeyTracker.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/KeyTracker.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -29,6 +29,8 @@
*/
public class KeyTracker {
+ private static boolean logMINOR;
+
/** Parent PeerNode */
public final PeerNode pn;
@@ -95,6 +97,7 @@
packetNumbersReceived = new ReceivedPacketNumbers(512);
isDeprecated = false;
nextPacketNumber = pn.node.random.nextInt(100*1000);
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
}
/**
@@ -103,6 +106,7 @@
* a packet number; they can be sent with the new KT.
*/
public void deprecated() {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
isDeprecated = true;
sentPacketsContents.interrupt();
}
@@ -131,7 +135,7 @@
* @param seqNumber The number of the packet to be acked.
*/
public void queueAck(int seqNumber) {
- Logger.minor(this, "Queueing ack for "+seqNumber);
+ if(logMINOR) Logger.minor(this, "Queueing ack for "+seqNumber);
QueuedAck qa = new QueuedAck(seqNumber);
synchronized(ackQueue) {
ackQueue.push(qa);
@@ -333,7 +337,7 @@
public void onAcked() {
long t = Math.max(0, System.currentTimeMillis() -
createdTime);
pn.pingAverage.report(t);
- Logger.minor(this, "Reported round-trip time of "+t+"ms
on "+pn.getPeer()+" (avg "+pn.pingAverage.currentValue()+"ms,
#"+packetNumber+")");
+ if(logMINOR) Logger.minor(this, "Reported round-trip
time of "+t+"ms on "+pn.getPeer()+" (avg "+pn.pingAverage.currentValue()+"ms,
#"+packetNumber+")");
}
long urgentDelay() {
@@ -348,16 +352,17 @@
* the reason for the locking.
*/
public synchronized void receivedPacket(int seqNumber) {
- Logger.minor(this, "Received packet "+seqNumber);
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "Received packet "+seqNumber);
try {
pn.receivedPacket(false);
} catch (NotConnectedException e) {
- Logger.minor(this, "Ignoring, because disconnected");
+ if(logMINOR) Logger.minor(this, "Ignoring, because
disconnected");
return;
}
if(seqNumber == -1) return;
// FIXME delete this log statement
- Logger.minor(this, "Still received packet: "+seqNumber);
+ if(logMINOR) Logger.minor(this, "Still received packet: "+seqNumber);
// Received packet
receivedPacketNumber(seqNumber);
// Ack it even if it is a resend
@@ -365,7 +370,7 @@
}
protected void receivedPacketNumber(int seqNumber) {
- Logger.minor(this, "Handling received packet number "+seqNumber);
+ if(logMINOR) Logger.minor(this, "Handling received packet number
"+seqNumber);
queueResendRequests(seqNumber);
packetNumbersReceived.got(seqNumber);
try {
@@ -376,7 +381,7 @@
synchronized(this) {
highestSeenIncomingSerialNumber =
Math.max(highestSeenIncomingSerialNumber, seqNumber);
}
- Logger.minor(this, "Handled received packet number "+seqNumber);
+ if(logMINOR) Logger.minor(this, "Handled received packet number
"+seqNumber);
}
/**
@@ -400,7 +405,7 @@
if(seqNumber > max) {
try {
if((max != -1) && (seqNumber - max > 1)) {
- Logger.minor(this, "Queueing resends from "+max+" to
"+seqNumber);
+ if(logMINOR) Logger.minor(this, "Queueing resends from "+max+"
to "+seqNumber);
// Missed some packets out
for(int i=max+1;i<seqNumber;i++) {
queueResendRequest(i);
@@ -421,10 +426,10 @@
private void queueResendRequest(int packetNumber) throws
UpdatableSortedLinkedListKilledException {
synchronized(resendRequestQueue) {
if(queuedResendRequest(packetNumber)) {
- Logger.minor(this, "Not queueing resend request for
"+packetNumber+" - already queued");
+ if(logMINOR) Logger.minor(this, "Not queueing resend
request for "+packetNumber+" - already queued");
return;
}
- Logger.minor(this, "Queueing resend request for "+packetNumber);
+ if(logMINOR) Logger.minor(this, "Queueing resend request for
"+packetNumber);
QueuedResendRequest qrr = new QueuedResendRequest(packetNumber);
resendRequestQueue.add(qrr);
}
@@ -439,10 +444,10 @@
private void queueAckRequest(int packetNumber) throws
UpdatableSortedLinkedListKilledException {
synchronized(ackRequestQueue) {
if(queuedAckRequest(packetNumber)) {
- Logger.minor(this, "Not queueing ack request for
"+packetNumber+" - already queued");
+ if(logMINOR) Logger.minor(this, "Not queueing ack request for
"+packetNumber+" - already queued");
return;
}
- Logger.minor(this, "Queueing ack request for "+packetNumber+" on
"+this);
+ if(logMINOR) Logger.minor(this, "Queueing ack request for
"+packetNumber+" on "+this);
QueuedAckRequest qrr = new QueuedAckRequest(packetNumber, false);
ackRequestQueue.add(qrr);
}
@@ -473,13 +478,13 @@
AsyncMessageCallback[][] callbacks = new
AsyncMessageCallback[seqNos.length][];
for(int i=0;i<seqNos.length;i++) {
int realSeqNo = seqNos[i];
- Logger.minor(this, "Acknowledged packet: "+realSeqNo);
+ if(logMINOR) Logger.minor(this, "Acknowledged packet:
"+realSeqNo);
try {
removeAckRequest(realSeqNo);
} catch (UpdatableSortedLinkedListKilledException e) {
// Ignore, we are processing an incoming packet
}
- Logger.minor(this, "Removed ack request");
+ if(logMINOR) Logger.minor(this, "Removed ack request");
callbacks[i] = sentPacketsContents.getCallbacks(realSeqNo);
byte[] buf = sentPacketsContents.get(realSeqNo);
long timeAdded = sentPacketsContents.getTime(realSeqNo);
@@ -501,7 +506,7 @@
}
}
}
- if(cbCount > 0)
+ if(cbCount > 0 && logMINOR)
Logger.minor(this, "Executed "+cbCount+" callbacks");
}
@@ -515,14 +520,15 @@
* @param realSeqNo
*/
public void acknowledgedPacket(int realSeqNo) {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
AsyncMessageCallback[] callbacks;
- Logger.minor(this, "Acknowledged packet: "+realSeqNo);
+ if(logMINOR) Logger.minor(this, "Acknowledged packet: "+realSeqNo);
try {
removeAckRequest(realSeqNo);
} catch (UpdatableSortedLinkedListKilledException e) {
// Ignore, we are processing an incoming packet
}
- Logger.minor(this, "Removed ack request");
+ if(logMINOR) Logger.minor(this, "Removed ack request");
callbacks = sentPacketsContents.getCallbacks(realSeqNo);
byte[] buf = sentPacketsContents.get(realSeqNo);
long timeAdded = sentPacketsContents.getTime(realSeqNo);
@@ -536,7 +542,7 @@
if(callbacks != null) {
for(int i=0;i<callbacks.length;i++)
callbacks[i].acknowledged();
- Logger.minor(this, "Executed "+callbacks.length+" callbacks");
+ if(logMINOR) Logger.minor(this, "Executed "+callbacks.length+"
callbacks");
}
}
@@ -570,7 +576,7 @@
String msg = "Asking me to resend packet "+seqNumber+
" which we haven't sent yet or which they have
already acked (next="+nextPacketNumber+")";
// Probably just a bit late - caused by overload etc
- Logger.minor(this, msg);
+ if(logMINOR) Logger.minor(this, msg);
}
}
}
@@ -647,7 +653,7 @@
synchronized(this) {
if(isDeprecated) throw new KeyChangedException();
packetNumber = nextPacketNumber++;
- Logger.minor(this, "Allocated "+packetNumber+" in
allocateOutgoingPacketNumber for "+this);
+ if(logMINOR) Logger.minor(this, "Allocated "+packetNumber+" in
allocateOutgoingPacketNumber for "+this);
}
while(true) {
try {
@@ -673,7 +679,7 @@
if(isDeprecated) throw new KeyChangedException();
sentPacketsContents.lockNeverBlock(packetNumber);
nextPacketNumber = packetNumber+1;
- Logger.minor(this, "Allocated "+packetNumber+" in
allocateOutgoingPacketNumberNeverBlock for "+this);
+ if(logMINOR) Logger.minor(this, "Allocated "+packetNumber+" in
allocateOutgoingPacketNumberNeverBlock for "+this);
return packetNumber;
}
}
@@ -683,7 +689,7 @@
* @return An array of packet numbers that we need to acknowledge.
*/
public int[] grabAcks() {
- Logger.minor(this, "Grabbing acks");
+ if(logMINOR) Logger.minor(this, "Grabbing acks");
int[] acks;
synchronized(ackQueue) {
// Grab the acks and tell them they are sent
@@ -693,7 +699,7 @@
for(Enumeration e=ackQueue.elements();e.hasMoreElements();) {
QueuedAck ack = (QueuedAck)e.nextElement();
acks[i++] = ack.packetNumber;
- Logger.minor(this, "Grabbing ack "+ack.packetNumber+" from
"+this);
+ if(logMINOR) Logger.minor(this, "Grabbing ack
"+ack.packetNumber+" from "+this);
ack.sent();
}
}
@@ -719,16 +725,16 @@
for(int i=0;i<length;i++) {
QueuedResendRequest qrr = (QueuedResendRequest)items[i];
if(packetNumbersReceived.contains(qrr.packetNumber)) {
- Logger.minor(this, "Have already seen
"+qrr.packetNumber+", removing from resend list");
+ if(logMINOR) Logger.minor(this, "Have already seen
"+qrr.packetNumber+", removing from resend list");
resendRequestQueue.remove(qrr);
continue;
}
if(qrr.activeTime <= now) {
packetNumbers[realLength++] = qrr.packetNumber;
- Logger.minor(this, "Grabbing resend request:
"+qrr.packetNumber+" from "+this);
+ if(logMINOR) Logger.minor(this, "Grabbing resend request:
"+qrr.packetNumber+" from "+this);
qrr.sent();
} else {
- Logger.minor(this, "Rejecting resend request:
"+qrr.packetNumber+" - in future by "+(qrr.activeTime-now)+"ms for "+this);
+ if(logMINOR) Logger.minor(this, "Rejecting resend
request: "+qrr.packetNumber+" - in future by "+(qrr.activeTime-now)+"ms for
"+this);
}
}
}
@@ -744,7 +750,7 @@
UpdatableSortedLinkedListItem[] items;
int[] packetNumbers;
int realLength;
- Logger.minor(this, "Grabbing ack requests");
+ if(logMINOR) Logger.minor(this, "Grabbing ack requests");
try {
synchronized(ackRequestQueue) {
long now = System.currentTimeMillis();
@@ -757,25 +763,25 @@
int packetNumber = qr.packetNumber;
if(qr.activeTime <= now) {
if(sentPacketsContents.get(packetNumber) == null) {
- Logger.minor(this, "Asking to ack packet which has
already been acked: "+packetNumber+" on "+this+".grabAckRequests");
+ if(logMINOR) Logger.minor(this, "Asking to ack packet
which has already been acked: "+packetNumber+" on "+this+".grabAckRequests");
ackRequestQueue.remove(qr);
continue;
}
packetNumbers[realLength++] = packetNumber;
- Logger.minor(this, "Grabbing ack request "+packetNumber+"
("+realLength+") from "+this);
+ if(logMINOR) Logger.minor(this, "Grabbing ack request
"+packetNumber+" ("+realLength+") from "+this);
qr.sent();
} else {
- Logger.minor(this, "Ignoring ack request "+packetNumber+"
("+realLength+") - will become active in "+(qr.activeTime-now)+"ms on "+this+"
- "+qr);
+ if(logMINOR) Logger.minor(this, "Ignoring ack request
"+packetNumber+" ("+realLength+") - will become active in
"+(qr.activeTime-now)+"ms on "+this+" - "+qr);
}
}
}
} catch (UpdatableSortedLinkedListKilledException e) {
throw new NotConnectedException();
}
- Logger.minor(this, "realLength now "+realLength);
+ if(logMINOR) Logger.minor(this, "realLength now "+realLength);
int[] trimmedPacketNumbers = new int[realLength];
System.arraycopy(packetNumbers, 0, trimmedPacketNumbers, 0,
realLength);
- Logger.minor(this, "Returning "+trimmedPacketNumbers.length+"
ackRequests");
+ if(logMINOR) Logger.minor(this, "Returning
"+trimmedPacketNumbers.length+" ackRequests");
return trimmedPacketNumbers;
}
@@ -837,7 +843,7 @@
}
public void completelyDeprecated(KeyTracker newTracker) {
- Logger.minor(this, "Completely deprecated: "+this+" in favour of
"+newTracker);
+ if(logMINOR) Logger.minor(this, "Completely deprecated: "+this+" in
favour of "+newTracker);
isDeprecated = true;
LimitedRangeIntByteArrayMapElement[] elements;
synchronized(sentPacketsContents) {
@@ -850,7 +856,7 @@
byte[] buf = element.data;
AsyncMessageCallback[] callbacks = element.callbacks;
// Ignore packet#
- Logger.minor(this, "Queueing resend of what was once
"+element.packetNumber);
+ if(logMINOR) Logger.minor(this, "Queueing resend of what was once
"+element.packetNumber);
messages[i] = new MessageItem(buf, callbacks, true, 0, null);
}
pn.requeueMessageItems(messages, 0, messages.length, true);
@@ -908,7 +914,7 @@
int packetNo = numbers[i];
byte[] buf = sentPacketsContents.get(packetNo);
if(buf == null) {
- Logger.minor(this, "Contents null for "+packetNo+" in
grabResendPackets on "+this);
+ if(logMINOR) Logger.minor(this, "Contents null for "+packetNo+"
in grabResendPackets on "+this);
continue; // acked already?
}
AsyncMessageCallback[] callbacks =
sentPacketsContents.getCallbacks(packetNo);
Modified: trunk/freenet/src/freenet/node/LocationManager.java
===================================================================
--- trunk/freenet/src/freenet/node/LocationManager.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/LocationManager.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -46,6 +46,7 @@
}
static final int TIMEOUT = 60*1000;
+ private static boolean logMINOR;
final RandomSource r;
final SwapRequestSender sender;
SwapRequestInterval interval;
@@ -57,6 +58,7 @@
sender = new SwapRequestSender();
this.r = r;
recentlyForwardedIDs = new Hashtable();
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
}
Location loc;
@@ -239,7 +241,7 @@
try {
commit = node.usm.waitFor(filter, null);
} catch (DisconnectedException e) {
- Logger.minor(this, "Disconnected from "+pn+" while waiting for
SwapCommit");
+ if(logMINOR) Logger.minor(this, "Disconnected from "+pn+" while
waiting for SwapCommit");
return;
}
@@ -301,12 +303,12 @@
timeLastSuccessfullySwapped = System.currentTimeMillis();
// Swap
loc.setValue(hisLoc);
- Logger.minor(this, "Swapped: "+myLoc+" <-> "+hisLoc+" - "+uid);
+ if(logMINOR) Logger.minor(this, "Swapped: "+myLoc+" <->
"+hisLoc+" - "+uid);
swaps++;
announceLocChange();
node.writeNodeFile();
} else {
- Logger.minor(this, "Didn't swap: "+myLoc+" <-> "+hisLoc+" -
"+uid);
+ if(logMINOR) Logger.minor(this, "Didn't swap: "+myLoc+" <->
"+hisLoc+" - "+uid);
noSwaps++;
}
} catch (Throwable t) {
@@ -364,7 +366,7 @@
// Only 1 ID because we are sending; we won't receive
item = addForwardedItem(uid, uid, null, pn);
- Logger.minor(this, "Sending SwapRequest "+uid+" to "+pn);
+ if(logMINOR) Logger.minor(this, "Sending SwapRequest "+uid+"
to "+pn);
MessageFilter filter1 =
MessageFilter.create().setType(DMT.FNPSwapRejected).setField(DMT.UID,
uid).setSource(pn);
@@ -376,12 +378,12 @@
node.usm.send(pn, m, null);
- Logger.minor(this, "Waiting for SwapReply/SwapRejected on
"+uid);
+ if(logMINOR) Logger.minor(this, "Waiting for
SwapReply/SwapRejected on "+uid);
Message reply;
try {
reply = node.usm.waitFor(filter, null);
} catch (DisconnectedException e) {
- Logger.minor(this, "Disconnected while waiting for
SwapReply/SwapRejected for "+uid);
+ if(logMINOR) Logger.minor(this, "Disconnected while
waiting for SwapReply/SwapRejected for "+uid);
return;
}
@@ -395,7 +397,7 @@
if(reply.getSpec() == DMT.FNPSwapRejected) {
// Failed. Abort.
- Logger.minor(this, "Swap rejected on "+uid);
+ if(logMINOR) Logger.minor(this, "Swap rejected on
"+uid);
return;
}
@@ -411,12 +413,12 @@
node.usm.send(pn, confirm, null);
- Logger.minor(this, "Waiting for SwapComplete: uid = "+uid);
+ if(logMINOR) Logger.minor(this, "Waiting for SwapComplete: uid
= "+uid);
try {
reply = node.usm.waitFor(filter, null);
} catch (DisconnectedException e) {
- Logger.minor(this, "Disconnected waiting for SwapComplete
on "+uid);
+ if(logMINOR) Logger.minor(this, "Disconnected waiting
for SwapComplete on "+uid);
return;
}
@@ -477,12 +479,12 @@
timeLastSuccessfullySwapped = System.currentTimeMillis();
// Swap
loc.setValue(hisLoc);
- Logger.minor(this, "Swapped: "+myLoc+" <-> "+hisLoc+" -
"+uid);
+ if(logMINOR) Logger.minor(this, "Swapped: "+myLoc+" <->
"+hisLoc+" - "+uid);
swaps++;
announceLocChange();
node.writeNodeFile();
} else {
- Logger.minor(this, "Didn't swap: "+myLoc+" <-> "+hisLoc+"
- "+uid);
+ if(logMINOR) Logger.minor(this, "Didn't swap: "+myLoc+"
<-> "+hisLoc+" - "+uid);
noSwaps++;
}
} catch (Throwable t) {
@@ -524,10 +526,10 @@
*/
synchronized boolean lock() {
if(locked) {
- Logger.minor(this, "Already locked");
+ if(logMINOR) Logger.minor(this, "Already locked");
return false;
}
- Logger.minor(this, "Locking on port "+node.portNumber);
+ if(logMINOR) Logger.minor(this, "Locking on port "+node.portNumber);
locked = true;
lockedTime = System.currentTimeMillis();
return true;
@@ -538,8 +540,10 @@
throw new IllegalStateException("Unlocking when not locked!");
locked = false;
long lockTime = System.currentTimeMillis() - lockedTime;
- Logger.minor(this, "Unlocking on port "+node.portNumber);
- Logger.minor(this, "lockTime: "+lockTime);
+ if(logMINOR) {
+ Logger.minor(this, "Unlocking on port "+node.portNumber);
+ Logger.minor(this, "lockTime: "+lockTime);
+ }
}
/**
@@ -591,7 +595,7 @@
sb.append(" ");
}
- Logger.minor(this, sb.toString());
+ if(logMINOR) Logger.minor(this, sb.toString());
double A = 1.0;
for(int i=0;i<friendLocs.length;i++) {
@@ -671,43 +675,43 @@
// sent twice.
RecentlyForwardedItem item = (RecentlyForwardedItem)
recentlyForwardedIDs.get(luid);
if(item != null) {
- Logger.minor(this, "Rejecting - same ID as previous request");
+ if(logMINOR) Logger.minor(this, "Rejecting - same ID as
previous request");
// Reject
Message reject = DMT.createFNPSwapRejected(uid);
try {
pn.sendAsync(reject, null, 0, null);
} catch (NotConnectedException e) {
- Logger.minor(this, "Lost connection to "+pn+" rejecting
SwapRequest");
+ if(logMINOR) Logger.minor(this, "Lost connection to "+pn+"
rejecting SwapRequest");
}
swapsRejectedRecognizedID++;
return true;
}
if(pn.shouldRejectSwapRequest()) {
- Logger.minor(this, "Advised to reject SwapRequest by PeerNode -
rate limit");
+ if(logMINOR) Logger.minor(this, "Advised to reject SwapRequest
by PeerNode - rate limit");
// Reject
Message reject = DMT.createFNPSwapRejected(uid);
try {
pn.sendAsync(reject, null, 0, null);
} catch (NotConnectedException e) {
- Logger.minor(this, "Lost connection rejecting SwapRequest from
"+pn);
+ if(logMINOR) Logger.minor(this, "Lost connection rejecting
SwapRequest from "+pn);
}
swapsRejectedRateLimit++;
return true;
}
- Logger.minor(this, "SwapRequest from "+pn+" - uid="+uid);
+ if(logMINOR) Logger.minor(this, "SwapRequest from "+pn+" - uid="+uid);
int htl = m.getInt(DMT.HTL)-1;
// Either forward it or handle it
if(htl == 0) {
- Logger.minor(this, "Accepting?... "+uid);
+ if(logMINOR) Logger.minor(this, "Accepting?... "+uid);
// Accept - handle locally
if(!lock()) {
- Logger.minor(this, "Can't obtain lock on "+uid+" - rejecting
to "+pn);
+ if(logMINOR) Logger.minor(this, "Can't obtain lock on "+uid+" -
rejecting to "+pn);
// Reject
Message reject = DMT.createFNPSwapRejected(uid);
try {
pn.sendAsync(reject, null, 0, null);
} catch (NotConnectedException e1) {
- Logger.minor(this, "Lost connection rejecting SwapRequest
(locked) from "+pn);
+ if(logMINOR) Logger.minor(this, "Lost connection
rejecting SwapRequest (locked) from "+pn);
}
swapsRejectedAlreadyLocked++;
return true;
@@ -717,7 +721,7 @@
// Locked, do it
IncomingSwapRequestHandler isrh =
new IncomingSwapRequestHandler(m, pn, item);
- Logger.minor(this, "Handling... "+uid);
+ if(logMINOR) Logger.minor(this, "Handling... "+uid);
Thread t = new Thread(isrh, "Incoming swap request handler for
port "+node.portNumber);
t.setDaemon(true);
t.start();
@@ -732,12 +736,12 @@
} else {
m.set(DMT.HTL, htl);
m.set(DMT.UID, oid);
- Logger.minor(this, "Forwarding... "+uid);
+ if(logMINOR) Logger.minor(this, "Forwarding... "+uid);
while(true) {
// Forward
PeerNode randomPeer = node.peers.getRandomPeer(pn);
if(randomPeer == null) {
- Logger.minor(this, "Late reject "+uid);
+ if(logMINOR) Logger.minor(this, "Late reject "+uid);
Message reject = DMT.createFNPSwapRejected(uid);
try {
pn.sendAsync(reject, null, 0, null);
@@ -747,7 +751,7 @@
swapsRejectedNowhereToGo++;
return true;
}
- Logger.minor(this, "Forwarding "+uid+" to "+randomPeer);
+ if(logMINOR) Logger.minor(this, "Forwarding "+uid+" to
"+randomPeer);
item = addForwardedItem(uid, oid, pn, randomPeer);
item.successfullyForwarded = false;
try {
@@ -784,7 +788,7 @@
return false;
}
if(item.requestSender == null) {
- Logger.minor(this, "SwapReply from "+m.getSource()+" on chain
originated locally "+uid);
+ if(logMINOR) Logger.minor(this, "SwapReply from
"+m.getSource()+" on chain originated locally "+uid);
return false;
}
if(item.routedTo == null) {
@@ -799,11 +803,11 @@
item.lastMessageTime = System.currentTimeMillis();
// Returning to source - use incomingID
m.set(DMT.UID, item.incomingID);
- Logger.minor(this, "Forwarding SwapReply "+uid+" from
"+m.getSource()+" to "+item.requestSender);
+ if(logMINOR) Logger.minor(this, "Forwarding SwapReply "+uid+" from
"+m.getSource()+" to "+item.requestSender);
try {
item.requestSender.sendAsync(m, null, 0, null);
} catch (NotConnectedException e) {
- Logger.minor(this, "Lost connection forwarding SwapReply "+uid+"
to "+item.requestSender);
+ if(logMINOR) Logger.minor(this, "Lost connection forwarding
SwapReply "+uid+" to "+item.requestSender);
}
return true;
}
@@ -829,13 +833,13 @@
}
removeRecentlyForwardedItem(item);
item.lastMessageTime = System.currentTimeMillis();
- Logger.minor(this, "Forwarding SwapRejected "+uid+" from
"+m.getSource()+" to "+item.requestSender);
+ if(logMINOR) Logger.minor(this, "Forwarding SwapRejected "+uid+" from
"+m.getSource()+" to "+item.requestSender);
// Returning to source - use incomingID
m.set(DMT.UID, item.incomingID);
try {
item.requestSender.sendAsync(m, null, 0, null);
} catch (NotConnectedException e) {
- Logger.minor(this, "Lost connection forwarding SwapRejected
"+uid+" to "+item.requestSender);
+ if(logMINOR) Logger.minor(this, "Lost connection forwarding
SwapRejected "+uid+" to "+item.requestSender);
}
return true;
}
@@ -856,13 +860,13 @@
return true;
}
item.lastMessageTime = System.currentTimeMillis();
- Logger.minor(this, "Forwarding SwapCommit "+uid+","+item.outgoingID+"
from "+m.getSource()+" to "+item.routedTo);
+ if(logMINOR) Logger.minor(this, "Forwarding SwapCommit
"+uid+","+item.outgoingID+" from "+m.getSource()+" to "+item.routedTo);
// Sending onwards - use outgoing ID
m.set(DMT.UID, item.outgoingID);
try {
item.routedTo.sendAsync(m, new
SendMessageOnErrorCallback(DMT.createFNPSwapRejected(item.incomingID),
item.requestSender), 0, null);
} catch (NotConnectedException e) {
- Logger.minor(this, "Lost connection forwarding SwapCommit "+uid+"
to "+item.routedTo);
+ if(logMINOR) Logger.minor(this, "Lost connection forwarding
SwapCommit "+uid+" to "+item.routedTo);
}
return true;
}
@@ -873,15 +877,15 @@
*/
public boolean handleSwapComplete(Message m) {
long uid = m.getLong(DMT.UID);
- Logger.minor(this, "handleSwapComplete("+uid+")");
+ if(logMINOR) Logger.minor(this, "handleSwapComplete("+uid+")");
Long luid = new Long(uid);
RecentlyForwardedItem item = (RecentlyForwardedItem)
recentlyForwardedIDs.get(luid);
if(item == null) {
- Logger.minor(this, "Item not found: "+uid+": "+m);
+ if(logMINOR) Logger.minor(this, "Item not found: "+uid+": "+m);
return false;
}
if(item.requestSender == null) {
- Logger.minor(this, "Not matched "+uid+": "+m);
+ if(logMINOR) Logger.minor(this, "Not matched "+uid+": "+m);
return false;
}
if(item.routedTo == null) {
@@ -893,7 +897,7 @@
" should be "+item.routedTo+" to "+item.requestSender);
return true;
}
- Logger.minor(this, "Forwarding SwapComplete "+uid+" from
"+m.getSource()+" to "+item.requestSender);
+ if(logMINOR) Logger.minor(this, "Forwarding SwapComplete "+uid+" from
"+m.getSource()+" to "+item.requestSender);
// Returning to source - use incomingID
m.set(DMT.UID, item.incomingID);
try {
@@ -941,7 +945,7 @@
RecentlyForwardedItem item = (RecentlyForwardedItem) v.get(i);
// Just reject it to avoid locking problems etc
Message msg = DMT.createFNPSwapRejected(item.incomingID);
- Logger.minor(this, "Rejecting in lostOrRestartedNode:
"+item.incomingID+ " from "+item.requestSender);
+ if(logMINOR) Logger.minor(this, "Rejecting in lostOrRestartedNode:
"+item.incomingID+ " from "+item.requestSender);
try {
item.requestSender.sendAsync(msg, null, 0, null);
} catch (NotConnectedException e1) {
@@ -951,7 +955,7 @@
}
private void removeRecentlyForwardedItem(RecentlyForwardedItem item) {
- Logger.minor(this, "Removing: "+item);
+ if(logMINOR) Logger.minor(this, "Removing: "+item);
if(item == null) {
Logger.error(this, "removeRecentlyForwardedItem(null)", new
Exception("error"));
}
@@ -962,11 +966,11 @@
private final HashMap knownLocs = new HashMap();
void registerLocationLink(double d, double t) {
- Logger.minor(this, "Known Link: "+d+" "+t);
+ if(logMINOR) Logger.minor(this, "Known Link: "+d+" "+t);
}
void registerKnownLocation(double d) {
- Logger.minor(this, "Known Location: "+d);
+ if(logMINOR) Logger.minor(this, "Known Location: "+d);
Double dd = new Double(d);
synchronized(knownLocs) {
Date timestamp = new Date();
@@ -976,7 +980,7 @@
}
//Add the location to the map with the current
timestamp as value
knownLocs.put(dd,timestamp);
- Logger.minor(this, "Estimated net size(session):
"+knownLocs.size());
+ if(logMINOR) Logger.minor(this, "Estimated net
size(session): "+knownLocs.size());
}
}
Modified: trunk/freenet/src/freenet/node/MemoryChecker.java
===================================================================
--- trunk/freenet/src/freenet/node/MemoryChecker.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/MemoryChecker.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -11,13 +11,17 @@
if(sleeptime <= 0)
sleeptime = 250;
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
+
for(int i=0;i<120;i++) {
try {
Thread.sleep(sleeptime);
} catch (InterruptedException e) {
// Ignore
}
- Logger.minor(this, "Memory in use:
"+(r.totalMemory()-r.freeMemory()));
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR)
+ Logger.minor(this, "Memory in use:
"+(r.totalMemory()-r.freeMemory()));
}
try {
Thread.sleep(sleeptime);
@@ -33,14 +37,16 @@
// we are getting much easier.
if(Node.aggressiveGCModificator > 0) {
long beforeGCUsedMemory =
(r.totalMemory()-r.freeMemory());
- Logger.minor(this, "Memory in use before GC:
"+beforeGCUsedMemory);
+ if(logMINOR) Logger.minor(this, "Memory in use
before GC: "+beforeGCUsedMemory);
long beforeGCTime = System.currentTimeMillis();
System.gc();
System.runFinalization();
long afterGCTime = System.currentTimeMillis();
long afterGCUsedMemory =
(r.totalMemory()-r.freeMemory());
- Logger.minor(this, "Memory in use after GC:
"+afterGCUsedMemory);
- Logger.minor(this, "GC completed after
"+(afterGCTime - beforeGCTime)+"ms and \"recovered\" "+(beforeGCUsedMemory -
afterGCUsedMemory)+" bytes, leaving "+afterGCUsedMemory+" bytes used");
+ if(logMINOR) {
+ Logger.minor(this, "Memory in use after
GC: "+afterGCUsedMemory);
+ Logger.minor(this, "GC completed after
"+(afterGCTime - beforeGCTime)+"ms and \"recovered\" "+(beforeGCUsedMemory -
afterGCUsedMemory)+" bytes, leaving "+afterGCUsedMemory+" bytes used");
+ }
}
}
}
Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java 2006-08-24 01:28:44 UTC (rev
10250)
+++ trunk/freenet/src/freenet/node/Node.java 2006-08-24 04:41:42 UTC (rev
10251)
@@ -102,6 +102,8 @@
*/
public class Node {
+ private static boolean logMINOR;
+
static class NodeBindtoCallback implements StringCallback {
final Node node;
@@ -544,12 +546,12 @@
this.myPrivKey =
DSAPrivateKey.create(fs.subset("dsaPrivKey"), myCryptoGroup);
this.myPubKey =
DSAPublicKey.create(fs.subset("dsaPubKey"), myCryptoGroup);
} catch (NullPointerException e) {
- Logger.minor(this, "Caught "+e, e);
+ if(logMINOR) Logger.minor(this, "Caught "+e, e);
this.myCryptoGroup = Global.DSAgroupBigA;
this.myPrivKey = new DSAPrivateKey(myCryptoGroup, r);
this.myPubKey = new DSAPublicKey(myCryptoGroup,
myPrivKey);
} catch (IllegalBase64Exception e) {
- Logger.minor(this, "Caught "+e, e);
+ if(logMINOR) Logger.minor(this, "Caught "+e, e);
this.myCryptoGroup = Global.DSAgroupBigA;
this.myPrivKey = new DSAPrivateKey(myCryptoGroup, r);
this.myPubKey = new DSAPublicKey(myCryptoGroup,
myPrivKey);
@@ -655,7 +657,7 @@
static class NodeInitException extends Exception {
// One of the exit codes from above
public final int exitCode;
- private static final long serialVersionUID = -1;
+ private static final long serialVersionUID = -1;
NodeInitException(int exitCode, String msg) {
super(msg+" ("+exitCode+")");
@@ -689,6 +691,7 @@
*/
Node(Config config, RandomSource random, LoggingConfigHandler lc,
NodeStarter ns) throws NodeInitException {
// Easy stuff
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
Logger.normal(this, "Initializing Node using SVN
r"+Version.cvsRevision+" and freenet-ext r"+NodeStarter.extRevisionNumber);
System.out.println("Initializing Node using SVN
r"+Version.cvsRevision+" and freenet-ext r"+NodeStarter.extRevisionNumber);
pInstantRejectIncoming = new TimeDecayingRunningAverage(0,
60000, 0.0, 1.0);
@@ -1256,7 +1259,7 @@
}
}
- Logger.minor(this, "Read throttleFS:\n"+throttleFS);
+ if(logMINOR) Logger.minor(this, "Read
throttleFS:\n"+throttleFS);
// Guesstimates. Hopefully well over the reality.
localChkFetchBytesSentAverage = new
TimeDecayingRunningAverage(500, 180000, 0.0, Long.MAX_VALUE, throttleFS == null
? null : throttleFS.subset("LocalChkFetchBytesSentAverage"));
@@ -1437,7 +1440,7 @@
String osName = System.getProperty("os.name");
String osVersion = System.getProperty("os.version");
- Logger.minor(this, "JVM vendor: "+jvmVendor+", JVM version:
"+jvmVersion+", OS name: "+osName+", OS version: "+osVersion);
+ if(logMINOR) Logger.minor(this, "JVM vendor: "+jvmVendor+", JVM
version: "+jvmVersion+", OS name: "+osName+", OS version: "+osVersion);
// If we are using the wrapper, we ignore:
// Any problem should be detected by the watchdog and the node
will be restarted
@@ -1517,7 +1520,7 @@
/* return reject reason as string if should reject, otherwise return null
*/
public String shouldRejectRequest(boolean canAcceptAnyway, boolean
isInsert, boolean isSSK) {
- dumpByteCostAverages();
+ if(logMINOR) dumpByteCostAverages();
double bwlimitDelayTime =
throttledPacketSendAverage.currentValue();
@@ -1549,7 +1552,7 @@
// Round trip time
if(pingTime > MAX_PING_TIME) {
if((now - lastAcceptedRequest >
MAX_INTERREQUEST_TIME) && canAcceptAnyway) {
- Logger.minor(this, "Accepting request
anyway (take one every 10 secs to keep bwlimitDelayTime updated)");
+ if(logMINOR) Logger.minor(this,
"Accepting request anyway (take one every 10 secs to keep bwlimitDelayTime
updated)");
lastAcceptedRequest = now;
pInstantRejectIncoming.report(0.0);
return null;
@@ -1568,7 +1571,7 @@
// Bandwidth limited packets
if(bwlimitDelayTime > MAX_THROTTLE_DELAY) {
if((now - lastAcceptedRequest >
MAX_INTERREQUEST_TIME) && canAcceptAnyway) {
- Logger.minor(this, "Accepting request
anyway (take one every 10 secs to keep bwlimitDelayTime updated)");
+ if(logMINOR) Logger.minor(this,
"Accepting request anyway (take one every 10 secs to keep bwlimitDelayTime
updated)");
lastAcceptedRequest = now;
pInstantRejectIncoming.report(0.0);
return null;
@@ -1606,7 +1609,7 @@
}
synchronized(this) {
- Logger.minor(this, "Accepting request?");
+ if(logMINOR) Logger.minor(this, "Accepting request?");
lastAcceptedRequest = now;
}
@@ -1659,7 +1662,7 @@
fs.put("dsaPubKey", myPubKey.asFieldSet());
fs.put("ark.number", Long.toString(this.myARKNumber));
fs.put("ark.pubURI", this.myARK.getURI().toString(false));
- Logger.minor(this, "My reference: "+fs);
+ if(logMINOR) Logger.minor(this, "My reference: "+fs);
return fs;
}
@@ -1704,7 +1707,8 @@
* RequestSender.
*/
public Object makeRequestSender(Key key, short htl, long uid, PeerNode
source, double closestLocation, boolean resetClosestLocation, boolean
localOnly, boolean cache, boolean ignoreStore) {
- Logger.minor(this,
"makeRequestSender("+key+","+htl+","+uid+","+source+") on "+portNumber);
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this,
"makeRequestSender("+key+","+htl+","+uid+","+source+") on "+portNumber);
// In store?
KeyBlock chk = null;
if(!ignoreStore) {
@@ -1715,7 +1719,7 @@
DSAPublicKey pubKey = k.getPubKey();
if(pubKey == null) {
pubKey = getKey(k.getPubKeyHash());
- Logger.minor(this, "Fetched pubkey:
"+pubKey+" "+(pubKey == null ? "" : pubKey.writeAsField()));
+ if(logMINOR) Logger.minor(this,
"Fetched pubkey: "+pubKey+" "+(pubKey == null ? "" : pubKey.writeAsField()));
try {
k.setPubKey(pubKey);
} catch (SSKVerifyException e) {
@@ -1723,17 +1727,17 @@
}
}
if(pubKey != null) {
- Logger.minor(this, "Got pubkey:
"+pubKey+" "+pubKey.writeAsField());
+ if(logMINOR) Logger.minor(this, "Got
pubkey: "+pubKey+" "+pubKey.writeAsField());
chk = fetch((NodeSSK)key, !cache);
} else {
- Logger.minor(this, "Not found because
no pubkey: "+uid);
+ if(logMINOR) Logger.minor(this, "Not
found because no pubkey: "+uid);
}
} else
throw new IllegalStateException("Unknown key
type: "+key.getClass());
if(chk != null) return chk;
}
if(localOnly) return null;
- Logger.minor(this, "Not in store locally");
+ if(logMINOR) Logger.minor(this, "Not in store locally");
// Transfer coalescing - match key only as HTL irrelevant
RequestSender sender = null;
@@ -1741,13 +1745,13 @@
sender = (RequestSender)
transferringRequestSenders.get(key);
}
if(sender != null) {
- Logger.minor(this, "Data already being transferred:
"+sender);
+ if(logMINOR) Logger.minor(this, "Data already being
transferred: "+sender);
return sender;
}
// HTL == 0 => Don't search further
if(htl == 0) {
- Logger.minor(this, "No HTL");
+ if(logMINOR) Logger.minor(this, "No HTL");
return null;
}
@@ -1756,7 +1760,7 @@
KeyHTLPair kh = new KeyHTLPair(key, htl);
sender = (RequestSender) requestSenders.get(kh);
if(sender != null) {
- Logger.minor(this, "Found sender: "+sender+"
for "+uid);
+ if(logMINOR) Logger.minor(this, "Found sender:
"+sender+" for "+uid);
return sender;
}
@@ -1764,7 +1768,7 @@
// RequestSender adds itself to requestSenders
}
sender.start();
- Logger.minor(this, "Created new sender: "+sender);
+ if(logMINOR) Logger.minor(this, "Created new sender: "+sender);
return sender;
}
@@ -1832,7 +1836,7 @@
}
public SSKBlock fetch(NodeSSK key, boolean dontPromote) {
- dumpStoreHits();
+ if(logMINOR) dumpStoreHits();
try {
SSKBlock block = sskDatastore.fetch(key, dontPromote);
if(block != null) {
@@ -1846,7 +1850,7 @@
}
public CHKBlock fetch(NodeCHK key, boolean dontPromote) {
- dumpStoreHits();
+ if(logMINOR) dumpStoreHits();
try {
CHKBlock block = chkDatastore.fetch(key, dontPromote);
if(block != null) return block;
@@ -2025,21 +2029,22 @@
*/
public CHKInsertSender makeInsertSender(NodeCHK key, short htl, long
uid, PeerNode source,
byte[] headers, PartiallyReceivedBlock prb, boolean
fromStore, double closestLoc, boolean cache) {
- Logger.minor(this,
"makeInsertSender("+key+","+htl+","+uid+","+source+",...,"+fromStore);
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this,
"makeInsertSender("+key+","+htl+","+uid+","+source+",...,"+fromStore);
KeyHTLPair kh = new KeyHTLPair(key, htl);
CHKInsertSender is = null;
synchronized(insertSenders) {
is = (CHKInsertSender) insertSenders.get(kh);
}
if(is != null) {
- Logger.minor(this, "Found "+is+" for "+kh);
+ if(logMINOR) Logger.minor(this, "Found "+is+" for "+kh);
return is;
}
if(fromStore && !cache)
throw new IllegalArgumentException("From store = true
but cache = false !!!");
is = new CHKInsertSender(key, uid, headers, htl, source, this,
prb, fromStore, closestLoc);
is.start();
- Logger.minor(this, is.toString()+" for "+kh.toString());
+ if(logMINOR) Logger.minor(this, is.toString()+" for
"+kh.toString());
// CHKInsertSender adds itself to insertSenders
return is;
}
@@ -2083,7 +2088,7 @@
}
public boolean lockUID(long uid) {
- Logger.minor(this, "Locking "+uid);
+ if(logMINOR) Logger.minor(this, "Locking "+uid);
Long l = new Long(uid);
synchronized(runningUIDs) {
if(runningUIDs.contains(l)) return false;
@@ -2093,7 +2098,7 @@
}
public void unlockUID(long uid) {
- Logger.minor(this, "Unlocking "+uid);
+ if(logMINOR) Logger.minor(this, "Unlocking "+uid);
Long l = new Long(uid);
completed(uid);
synchronized(runningUIDs) {
@@ -2241,13 +2246,13 @@
*/
public DSAPublicKey getKey(byte[] hash) {
ImmutableByteArrayWrapper w = new
ImmutableByteArrayWrapper(hash);
- Logger.minor(this, "Getting pubkey: "+HexUtil.bytesToHex(hash));
+ if(logMINOR) Logger.minor(this, "Getting pubkey:
"+HexUtil.bytesToHex(hash));
if(USE_RAM_PUBKEYS_CACHE) {
synchronized(cachedPubKeys) {
DSAPublicKey key = (DSAPublicKey)
cachedPubKeys.get(w);
if(key != null) {
cachedPubKeys.push(w, key);
- Logger.minor(this, "Got
"+HexUtil.bytesToHex(hash)+" from cache");
+ if(logMINOR) Logger.minor(this, "Got
"+HexUtil.bytesToHex(hash)+" from cache");
return key;
}
}
@@ -2259,7 +2264,7 @@
key = pubKeyDatacache.fetchPubKey(hash, false);
if(key != null) {
cacheKey(hash, key, false);
- Logger.minor(this, "Got
"+HexUtil.bytesToHex(hash)+" from store");
+ if(logMINOR) Logger.minor(this, "Got
"+HexUtil.bytesToHex(hash)+" from store");
}
return key;
} catch (IOException e) {
@@ -2273,7 +2278,7 @@
* Cache a public key
*/
public void cacheKey(byte[] hash, DSAPublicKey key, boolean deep) {
- Logger.minor(this, "Cache key: "+HexUtil.bytesToHex(hash)+" :
"+key);
+ if(logMINOR) Logger.minor(this, "Cache key:
"+HexUtil.bytesToHex(hash)+" : "+key);
ImmutableByteArrayWrapper w = new
ImmutableByteArrayWrapper(hash);
synchronized(cachedPubKeys) {
DSAPublicKey key2 = (DSAPublicKey) cachedPubKeys.get(w);
@@ -2400,7 +2405,7 @@
}
public void onConnectedPeer() {
- Logger.minor(this, "onConnectedPeer()");
+ if(logMINOR) Logger.minor(this, "onConnectedPeer()");
ipDetector.onConnectedPeer();
}
@@ -2440,11 +2445,10 @@
ARKFetcher af = (ARKFetcher)
arkFetchers.get(identity);
if(af != fetcher)
Logger.error(this, "addARKFetcher():
identity '"+identity+"' already in arkFetcher as "+af+" and you want to
add"+fetcher);
- else
- Logger.minor(this, "Re-adding
"+identity+" : "+fetcher);
+ else if(logMINOR) Logger.minor(this, "Re-adding
"+identity+" : "+fetcher);
return;
}
- Logger.minor(this, "addARKFetcher(): adding ARK Fetcher
for "+identity);
+ if(logMINOR) Logger.minor(this, "addARKFetcher():
adding ARK Fetcher for "+identity);
arkFetchers.put(identity, fetcher);
}
}
@@ -2465,7 +2469,7 @@
Logger.error(this, "removeARKFetcher():
identity '"+identity+"' not in arkFetcher to remove");
return;
}
- Logger.minor(this, "removeARKFetcher(): removing ARK
Fetcher for "+identity);
+ if(logMINOR) Logger.minor(this, "removeARKFetcher():
removing ARK Fetcher for "+identity);
ARKFetcher af = (ARKFetcher)
arkFetchers.remove(identity);
if(af != fetcher) {
Logger.error(this, "Removed "+af+" should be
"+fetcher+" for "+identity+" in removeARKFetcher");
@@ -2490,7 +2494,7 @@
} else {
statusSet = new HashSet();
}
- Logger.minor(this, "addPeerNodeStatus(): adding
PeerNode for '"+peerNode.getIdentityString()+"' with status code
"+peerNodeStatus);
+ if(logMINOR) Logger.minor(this, "addPeerNodeStatus():
adding PeerNode for '"+peerNode.getIdentityString()+"' with status code
"+peerNodeStatus);
statusSet.add(peerNode);
peerNodeStatuses.put(peerNodeStatus, statusSet);
}
@@ -2529,7 +2533,7 @@
} else {
statusSet = new HashSet();
}
- Logger.minor(this, "removePeerNodeStatus(): removing
PeerNode for '"+peerNode.getIdentityString()+"' with status code
"+peerNodeStatus);
+ if(logMINOR) Logger.minor(this,
"removePeerNodeStatus(): removing PeerNode for
'"+peerNode.getIdentityString()+"' with status code "+peerNodeStatus);
if(statusSet.contains(peerNode)) {
statusSet.remove(peerNode);
}
@@ -2576,7 +2580,7 @@
}
}
}
- if(oldestNeverConnectedPeerAge > 0)
+ if(oldestNeverConnectedPeerAge > 0 && logMINOR)
Logger.minor(this, "Oldest never connected peer is
"+oldestNeverConnectedPeerAge+"ms old");
nextOldestNeverConnectedPeerAgeUpdateTime = now +
oldestNeverConnectedPeerAgeUpdateInterval;
}
@@ -2665,7 +2669,7 @@
} else {
reasonSet = new HashSet();
}
- Logger.minor(this, "addPeerNodeRoutingBackoffReason():
adding PeerNode for '"+peerNode.getIdentityString()+"' with status code
"+peerNodeRoutingBackoffReason);
+ if(logMINOR) Logger.minor(this,
"addPeerNodeRoutingBackoffReason(): adding PeerNode for
'"+peerNode.getIdentityString()+"' with status code
"+peerNodeRoutingBackoffReason);
reasonSet.add(peerNode);
peerNodeRoutingBackoffReasons.put(peerNodeRoutingBackoffReason, reasonSet);
}
@@ -2714,7 +2718,7 @@
} else {
reasonSet = new HashSet();
}
- Logger.minor(this,
"removePeerNodeRoutingBackoffReason(): removing PeerNode for
'"+peerNode.getIdentityString()+"' with status code
"+peerNodeRoutingBackoffReason);
+ if(logMINOR) Logger.minor(this,
"removePeerNodeRoutingBackoffReason(): removing PeerNode for
'"+peerNode.getIdentityString()+"' with status code
"+peerNodeRoutingBackoffReason);
if(reasonSet.contains(peerNode)) {
reasonSet.remove(peerNode);
}
@@ -2769,7 +2773,7 @@
} else {
nodeAveragePingAlertRelevant = false;
}
- Logger.debug(this, "mUPMUAS: "+now+":
"+getBwlimitDelayTime()+" >? "+MAX_BWLIMIT_DELAY_TIME_ALERT_THRESHOLD+" since
"+firstBwlimitDelayTimeThresholdBreak+" ("+bwlimitDelayAlertRelevant+")
"+getNodeAveragePingTime()+" >? "+MAX_NODE_AVERAGE_PING_TIME_ALERT_THRESHOLD+"
since "+firstNodeAveragePingTimeThresholdBreak+"
("+nodeAveragePingAlertRelevant+")");
+ if(logMINOR && Logger.shouldLog(Logger.DEBUG, this))
Logger.debug(this, "mUPMUAS: "+now+": "+getBwlimitDelayTime()+" >?
"+MAX_BWLIMIT_DELAY_TIME_ALERT_THRESHOLD+" since
"+firstBwlimitDelayTimeThresholdBreak+" ("+bwlimitDelayAlertRelevant+")
"+getNodeAveragePingTime()+" >? "+MAX_NODE_AVERAGE_PING_TIME_ALERT_THRESHOLD+"
since "+firstNodeAveragePingTimeThresholdBreak+"
("+nodeAveragePingAlertRelevant+")");
nextPeerManagerUserAlertStatsUpdateTime = now +
peerManagerUserAlertStatsUpdateInterval;
}
}
Modified: trunk/freenet/src/freenet/node/NodeARKInserter.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeARKInserter.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/NodeARKInserter.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -29,6 +29,7 @@
*/
private final Node node;
private final NodeIPDetector detector;
+ private static boolean logMINOR;
/**
* @param node
@@ -36,6 +37,7 @@
NodeARKInserter(Node node, NodeIPDetector detector) {
this.node = node;
this.detector = detector;
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
}
private ClientPutter inserter;
@@ -49,9 +51,10 @@
}
public void update() {
- Logger.minor(this, "update()");
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "update()");
if(!checkIPUpdated()) return;
- Logger.minor(this, "Inserting ARK because peers list changed");
+ if(logMINOR) Logger.minor(this, "Inserting ARK because peers
list changed");
if(inserter != null) {
// Already inserting.
@@ -77,7 +80,7 @@
private boolean checkIPUpdated() {
Peer[] p = detector.getPrimaryIPAddress();
if(p == null) {
- Logger.minor(this, "Not inserting because no IP
address");
+ if(logMINOR) Logger.minor(this, "Not inserting because
no IP address");
return false; // no point inserting
}
synchronized (this) {
@@ -95,13 +98,12 @@
}
private void startInserter() {
-
if(!canStart) {
- Logger.minor(this, "ARK inserter can't start yet");
+ if(logMINOR) Logger.minor(this, "ARK inserter can't
start yet");
return;
}
- Logger.minor(this, "starting inserter");
+ if(logMINOR) Logger.minor(this, "starting inserter");
SimpleFieldSet fs = this.node.exportPublicFieldSet();
@@ -125,7 +127,7 @@
FreenetURI uri =
this.node.myARK.getInsertURI().setKeyType("USK").setSuggestedEdition(this.node.myARKNumber);
- Logger.minor(this, "Inserting ARK: "+uri);
+ if(logMINOR) Logger.minor(this, "Inserting ARK: "+uri);
inserter = new ClientPutter(this, b, uri,
@@ -168,7 +170,7 @@
}
public void onSuccess(BaseClientPutter state) {
- Logger.minor(this, "ARK insert succeeded");
+ if(logMINOR) Logger.minor(this, "ARK insert succeeded");
inserter = null;
boolean myShouldInsert;
synchronized (this) {
@@ -184,7 +186,7 @@
}
public void onFailure(InserterException e, BaseClientPutter state) {
- Logger.minor(this, "ARK insert failed: "+e);
+ if(logMINOR) Logger.minor(this, "ARK insert failed: "+e);
synchronized(this) {
lastInsertedPeers = null;
}
@@ -200,12 +202,12 @@
}
public void onGeneratedURI(FreenetURI uri, BaseClientPutter state) {
- Logger.minor(this, "Generated URI for ARK: "+uri);
+ if(logMINOR) Logger.minor(this, "Generated URI for ARK: "+uri);
long l = uri.getSuggestedEdition();
if(l < this.node.myARKNumber) {
Logger.error(this, "Inserted edition # lower than
attempted: "+l+" expected "+this.node.myARKNumber);
} else if(l > this.node.myARKNumber) {
- Logger.minor(this, "ARK number moving from
"+this.node.myARKNumber+" to "+l);
+ if(logMINOR) Logger.minor(this, "ARK number moving from
"+this.node.myARKNumber+" to "+l);
this.node.myARKNumber = l;
this.node.writeNodeFile();
}
Modified: trunk/freenet/src/freenet/node/NodeClientCore.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeClientCore.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/NodeClientCore.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -52,6 +52,7 @@
*/
public class NodeClientCore {
+ private static boolean logMINOR;
public final USKManager uskManager;
final ArchiveManager archiveManager;
public final RequestStarterGroup requestStarters;
@@ -93,7 +94,8 @@
random.nextBytes(pwdBuf);
this.formPassword = Base64.encode(pwdBuf);
alerts = new UserAlertManager();
- Logger.minor(this, "Serializing RequestStarterGroup
from:\n"+throttleFS);
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "Serializing
RequestStarterGroup from:\n"+throttleFS);
requestStarters = new RequestStarterGroup(node, this,
portNumber, random, config, throttleFS);
// Temp files
@@ -244,6 +246,7 @@
}
ClientCHKBlock realGetCHK(ClientCHK key, boolean localOnly, boolean
cache, boolean ignoreStore) throws LowLevelGetException {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
long startTime = System.currentTimeMillis();
long uid = random.nextLong();
if(!node.lockUID(uid)) {
@@ -277,7 +280,7 @@
continue;
if(status != RequestSender.TIMED_OUT && status !=
RequestSender.GENERATED_REJECTED_OVERLOAD && status !=
RequestSender.INTERNAL_ERROR) {
- Logger.minor(this, "CHK fetch cost
"+rs.getTotalSentBytes()+"/"+rs.getTotalReceivedBytes()+" bytes ("+status+")");
+ if(logMINOR) Logger.minor(this, "CHK fetch cost
"+rs.getTotalSentBytes()+"/"+rs.getTotalReceivedBytes()+" bytes ("+status+")");
node.localChkFetchBytesSentAverage.report(rs.getTotalSentBytes());
node.localChkFetchBytesReceivedAverage.report(rs.getTotalReceivedBytes());
}
@@ -339,6 +342,7 @@
}
ClientSSKBlock realGetSSK(ClientSSK key, boolean localOnly, boolean
cache, boolean ignoreStore) throws LowLevelGetException {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
long startTime = System.currentTimeMillis();
long uid = random.nextLong();
if(!node.lockUID(uid)) {
@@ -373,7 +377,7 @@
continue;
if(status != RequestSender.TIMED_OUT && status !=
RequestSender.GENERATED_REJECTED_OVERLOAD && status !=
RequestSender.INTERNAL_ERROR) {
- Logger.minor(this, "SSK fetch cost
"+rs.getTotalSentBytes()+"/"+rs.getTotalReceivedBytes()+" bytes ("+status+")");
+ if(logMINOR) Logger.minor(this, "SSK fetch cost
"+rs.getTotalSentBytes()+"/"+rs.getTotalReceivedBytes()+" bytes ("+status+")");
node.localSskFetchBytesSentAverage.report(rs.getTotalSentBytes());
node.localSskFetchBytesReceivedAverage.report(rs.getTotalReceivedBytes());
}
@@ -443,6 +447,7 @@
}
public void realPutCHK(CHKBlock block, boolean cache) throws
LowLevelPutException {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
byte[] data = block.getData();
byte[] headers = block.getHeaders();
PartiallyReceivedBlock prb = new
PartiallyReceivedBlock(Node.PACKETS_IN_BLOCK, Node.PACKET_SIZE, data);
@@ -493,7 +498,7 @@
}
}
- Logger.minor(this, "Completed "+uid+"
overload="+hasReceivedRejectedOverload+" "+is.getStatusString());
+ if(logMINOR) Logger.minor(this, "Completed "+uid+"
overload="+hasReceivedRejectedOverload+" "+is.getStatusString());
// Finished?
if(!hasReceivedRejectedOverload) {
@@ -515,7 +520,7 @@
&& status != CHKInsertSender.ROUTE_REALLY_NOT_FOUND) {
int sent = is.getTotalSentBytes();
int received = is.getTotalReceivedBytes();
- Logger.minor(this, "Local CHK insert cost "+sent+"/"+received+"
bytes ("+status+")");
+ if(logMINOR) Logger.minor(this, "Local CHK insert cost
"+sent+"/"+received+" bytes ("+status+")");
node.localChkInsertBytesSentAverage.report(sent);
node.localChkInsertBytesReceivedAverage.report(received);
}
@@ -552,6 +557,7 @@
}
public void realPutSSK(SSKBlock block, boolean cache) throws
LowLevelPutException {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
SSKInsertSender is;
long uid = random.nextLong();
if(!node.lockUID(uid)) {
@@ -600,7 +606,7 @@
}
}
- Logger.minor(this, "Completed "+uid+"
overload="+hasReceivedRejectedOverload+" "+is.getStatusString());
+ if(logMINOR) Logger.minor(this, "Completed "+uid+"
overload="+hasReceivedRejectedOverload+" "+is.getStatusString());
// Finished?
if(!hasReceivedRejectedOverload) {
@@ -621,7 +627,7 @@
&& status != CHKInsertSender.ROUTE_REALLY_NOT_FOUND) {
int sent = is.getTotalSentBytes();
int received = is.getTotalReceivedBytes();
- Logger.minor(this, "Local SSK insert cost "+sent+"/"+received+"
bytes ("+status+")");
+ if(logMINOR) Logger.minor(this, "Local SSK insert cost
"+sent+"/"+received+" bytes ("+status+")");
node.localSskInsertBytesSentAverage.report(sent);
node.localSskInsertBytesReceivedAverage.report(received);
}
@@ -721,7 +727,7 @@
public void queueRandomReinsert(KeyBlock block) {
SimpleSendableInsert ssi = new SimpleSendableInsert(this,
block, RequestStarter.MAXIMUM_PRIORITY_CLASS);
- Logger.minor(this, "Queueing random reinsert for "+block+" :
"+ssi);
+ if(logMINOR) Logger.minor(this, "Queueing random reinsert for
"+block+" : "+ssi);
if(block instanceof CHKBlock)
requestStarters.chkPutScheduler.register(ssi);
else if(block instanceof SSKBlock)
Modified: trunk/freenet/src/freenet/node/NodeDispatcher.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeDispatcher.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/NodeDispatcher.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -31,15 +31,18 @@
*/
public class NodeDispatcher implements Dispatcher {
+ private static boolean logMINOR;
final Node node;
NodeDispatcher(Node node) {
this.node = node;
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
}
public boolean handleMessage(Message m) {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
PeerNode source = (PeerNode)m.getSource();
- Logger.minor(this, "Dispatching "+m);
+ if(logMINOR) Logger.minor(this, "Dispatching "+m);
MessageType spec = m.getSpec();
if(spec == DMT.FNPPing) {
// Send an FNPPong
@@ -47,7 +50,7 @@
try {
((PeerNode)m.getSource()).sendAsync(reply, null, 0, null); //
nothing we can do if can't contact source
} catch (NotConnectedException e) {
- Logger.minor(this, "Lost connection replying to "+m);
+ if(logMINOR) Logger.minor(this, "Lost connection replying to
"+m);
}
return true;
}else if(spec == DMT.FNPLinkPing) {
@@ -136,7 +139,7 @@
return true;
}
if(!node.lockUID(id)) {
- Logger.minor(this, "Could not lock ID "+id+" -> rejecting (already
running)");
+ if(logMINOR) Logger.minor(this, "Could not lock ID "+id+" ->
rejecting (already running)");
Message rejected = DMT.createFNPRejectedLoop(id);
try {
((PeerNode)(m.getSource())).sendAsync(rejected, null, 0, null);
@@ -145,7 +148,7 @@
}
return true;
} else {
- Logger.minor(this, "Locked "+id);
+ if(logMINOR) Logger.minor(this, "Locked "+id);
}
//if(!node.lockUID(id)) return false;
RequestHandler rh = new RequestHandler(m, id, node);
@@ -180,7 +183,7 @@
return true;
}
if(!node.lockUID(id)) {
- Logger.minor(this, "Could not lock ID "+id+" -> rejecting (already
running)");
+ if(logMINOR) Logger.minor(this, "Could not lock ID "+id+" ->
rejecting (already running)");
Message rejected = DMT.createFNPRejectedLoop(id);
try {
((PeerNode)(m.getSource())).sendAsync(rejected, null, 0, null);
@@ -201,7 +204,7 @@
t.setDaemon(true);
t.start();
}
- Logger.minor(this, "Started InsertHandler for "+id);
+ if(logMINOR) Logger.minor(this, "Started InsertHandler for "+id);
return true;
}
@@ -258,7 +261,7 @@
* @return False if we want the message put back on the queue.
*/
boolean handleRouted(Message m) {
- Logger.minor(this, "handleRouted("+m+")");
+ if(logMINOR) Logger.minor(this, "handleRouted("+m+")");
if((m.getSource() != null) && (!(m.getSource() instanceof PeerNode))) {
Logger.error(this, "Routed message but source "+m.getSource()+"
not a PeerNode!");
return true;
@@ -274,7 +277,7 @@
try {
((PeerNode)m.getSource()).sendAsync(DMT.createFNPRoutedRejected(id,
(short)(htl-1)), null, 0, null);
} catch (NotConnectedException e) {
- Logger.minor(this, "Lost connection rejecting "+m);
+ if(logMINOR) Logger.minor(this, "Lost connection rejecting "+m);
}
return true;
}
@@ -282,9 +285,9 @@
routedContexts.put(lid, ctx);
// pn == null => originated locally, keep full htl
double target = m.getDouble(DMT.TARGET_LOCATION);
- Logger.minor(this, "id "+id+" from "+pn+" htl "+htl+" target "+target);
+ if(logMINOR) Logger.minor(this, "id "+id+" from "+pn+" htl "+htl+"
target "+target);
if(Math.abs(node.lm.getLocation().getValue() - target) <=
Double.MIN_VALUE) {
- Logger.minor(this, "Dispatching "+m.getSpec()+" on
"+node.portNumber);
+ if(logMINOR) Logger.minor(this, "Dispatching "+m.getSpec()+" on
"+node.portNumber);
// Handle locally
// Message type specific processing
dispatchRoutedMessage(m, pn, id);
@@ -294,7 +297,7 @@
if(pn != null) try {
pn.sendAsync(reject, null, 0, null);
} catch (NotConnectedException e) {
- Logger.minor(this, "Lost connection rejecting "+m);
+ if(logMINOR) Logger.minor(this, "Lost connection rejecting "+m);
}
return true;
} else {
@@ -304,7 +307,7 @@
boolean handleRoutedReply(Message m) {
long id = m.getLong(DMT.UID);
- Logger.minor(this, "Got reply: "+m);
+ if(logMINOR) Logger.minor(this, "Got reply: "+m);
Long lid = new Long(id);
RoutedContext ctx = (RoutedContext) routedContexts.get(lid);
if(ctx == null) {
@@ -316,21 +319,21 @@
try {
pn.sendAsync(m, null, 0, null);
} catch (NotConnectedException e) {
- Logger.minor(this, "Lost connection forwarding "+m+" to "+pn);
+ if(logMINOR) Logger.minor(this, "Lost connection forwarding
"+m+" to "+pn);
}
return true;
}
private boolean forward(Message m, long id, PeerNode pn, short htl, double
target, RoutedContext ctx) {
- Logger.minor(this, "Should forward");
+ if(logMINOR) Logger.minor(this, "Should forward");
// Forward
m = preForward(m, htl);
while(true) {
PeerNode next = node.peers.closerPeer(pn, ctx.routedTo,
ctx.notIgnored, target, true, node.isAdvancedDarknetEnabled());
- Logger.minor(this, "Next: "+next+" message: "+m);
+ if(logMINOR) Logger.minor(this, "Next: "+next+" message: "+m);
if(next != null) {
// next is connected, or at least has been => next.getPeer()
CANNOT be null.
- Logger.minor(this, "Forwarding "+m.getSpec()+" to
"+next.getPeer().getPort());
+ if(logMINOR) Logger.minor(this, "Forwarding "+m.getSpec()+" to
"+next.getPeer().getPort());
ctx.addSent(next);
try {
next.sendAsync(m, null, 0, null);
@@ -338,7 +341,7 @@
continue;
}
} else {
- Logger.minor(this, "Reached dead end for "+m.getSpec()+" on
"+node.portNumber);
+ if(logMINOR) Logger.minor(this, "Reached dead end for
"+m.getSpec()+" on "+node.portNumber);
// Reached a dead end...
Message reject = DMT.createFNPRoutedRejected(id, htl);
if(pn != null) try {
@@ -373,13 +376,13 @@
*/
private boolean dispatchRoutedMessage(Message m, PeerNode src, long id) {
if(m.getSpec() == DMT.FNPRoutedPing) {
- Logger.minor(this, "RoutedPing reached other side!");
+ if(logMINOR) Logger.minor(this, "RoutedPing reached other
side!");
int x = m.getInt(DMT.COUNTER);
Message reply = DMT.createFNPRoutedPong(id, x);
try {
src.sendAsync(reply, null, 0, null);
} catch (NotConnectedException e) {
- Logger.minor(this, "Lost connection replying to "+m+" in
dispatchRoutedMessage");
+ if(logMINOR) Logger.minor(this, "Lost connection replying to
"+m+" in dispatchRoutedMessage");
}
return true;
}
Modified: trunk/freenet/src/freenet/node/NodeIPDetector.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeIPDetector.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/NodeIPDetector.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -200,7 +200,8 @@
if(addrs == null || addrs.length == 0) return false;
for(int i=0;i<addrs.length;i++) {
if(IPAddressDetector.isValidAddress(addrs[i], false)) {
- Logger.minor(this, "Has a directly detected IP:
"+addrs[i]);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Has a directly
detected IP: "+addrs[i]);
return true;
}
}
Modified: trunk/freenet/src/freenet/node/NodePinger.java
===================================================================
--- trunk/freenet/src/freenet/node/NodePinger.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/NodePinger.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -46,7 +46,8 @@
double d = calculateMedianPing(peers);
tdra.report(d);
meanPing = tdra.currentValue();
- Logger.minor(this, "Reporting ping to temporal averager: "+d+"
result "+meanPing);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Reporting ping to temporal
averager: "+d+" result "+meanPing);
}
double calculateMedianPing(PeerNode[] peers) {
Modified: trunk/freenet/src/freenet/node/PacketSender.java
===================================================================
--- trunk/freenet/src/freenet/node/PacketSender.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/PacketSender.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -22,6 +22,8 @@
*/
public class PacketSender implements Runnable, Ticker {
+ private static boolean logMINOR;
+
static final int MAX_COALESCING_DELAY = 100;
final LinkedList resendPackets;
@@ -42,6 +44,7 @@
myThread = new Thread(this, "PacketSender thread for
"+node.portNumber);
myThread.setDaemon(true);
myThread.setPriority(Thread.MAX_PRIORITY);
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
}
@@ -113,6 +116,7 @@
while(true) {
lastReceivedPacketFromAnyNode = lastReportedNoPackets;
try {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
realRun();
} catch (OutOfMemoryError e) {
Runtime r = Runtime.getRuntime();
@@ -179,7 +183,7 @@
// Any urgent notifications to send?
long urgentTime = pn.getNextUrgentTime();
// Should spam the logs, unless there is a deadlock
- if(urgentTime < Long.MAX_VALUE)
+ if(urgentTime < Long.MAX_VALUE && logMINOR)
Logger.minor(this, "Next urgent time: "+urgentTime+"
for "+pn.getDetectedPeer());
if(urgentTime <= now) {
// Send them
@@ -206,7 +210,7 @@
ResendPacketItem item = resendItems[k];
if(item == null) continue;
try {
- Logger.minor(this, "Resending
"+item.packetNumber+" to "+item.kt);
+ if(logMINOR) Logger.minor(this, "Resending
"+item.packetNumber+" to "+item.kt);
node.packetMangler.processOutgoingPreformatted(item.buf, 0, item.buf.length,
item.kt, item.packetNumber, item.callbacks, 0);
} catch (KeyChangedException e) {
Logger.error(this, "Caught "+e+" resending packets
to "+kt);
@@ -244,7 +248,7 @@
pn.requeueMessageItems(messages, 0,
messages.length, true, "TrafficCoalescing");
} else {
for(int j=0;j<messages.length;j++) {
- Logger.minor(this, "PS Sending:
"+(messages[j].msg == null ? "(not a Message)" :
messages[j].msg.getSpec().getName()));
+ if(logMINOR) Logger.minor(this, "PS
Sending: "+(messages[j].msg == null ? "(not a Message)" :
messages[j].msg.getSpec().getName()));
if (messages[j].msg != null) {
pn.addToLocalNodeSentMessagesToStatistic(messages[j].msg);
}
@@ -257,7 +261,7 @@
// Need to send a keepalive packet?
if(now - pn.lastSentPacketTime() > Node.KEEPALIVE_INTERVAL) {
- Logger.minor(this, "Sending keepalive");
+ if(logMINOR) Logger.minor(this, "Sending keepalive");
// Force packet to have a sequence number.
Message m = DMT.createFNPVoid();
pn.addToLocalNodeSentMessagesToStatistic(m);
@@ -320,7 +324,7 @@
if(jobsToRun != null) {
for(int i=0;i<jobsToRun.size();i++) {
Runnable r = (Runnable) jobsToRun.get(i);
- Logger.minor(this, "Running "+r);
+ if(logMINOR) Logger.minor(this, "Running "+r);
if(r instanceof FastRunnable) {
// Run in-line
try {
@@ -350,7 +354,7 @@
if(sleepTime > 0) {
try {
synchronized(this) {
- Logger.minor(this, "Sleeping for "+sleepTime);
+ if(logMINOR) Logger.minor(this, "Sleeping for
"+sleepTime);
wait(sleepTime);
}
} catch (InterruptedException e) {
Modified: trunk/freenet/src/freenet/node/PeerManager.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerManager.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/PeerManager.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -32,6 +32,8 @@
*/
public class PeerManager {
+ private static boolean logMINOR;
+
/** Our Node */
final Node node;
@@ -53,6 +55,7 @@
*/
public PeerManager(Node node, String filename) {
Logger.normal(this, "Creating PeerManager");
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
System.out.println("Creating PeerManager");
this.filename = filename;
ua = new PeerManagerUserAlert(node);
@@ -206,14 +209,15 @@
}
public void addConnectedPeer(PeerNode pn) {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
if(!pn.isRoutable()) {
- Logger.minor(this, "Not ReallyConnected: "+pn);
+ if(logMINOR) Logger.minor(this, "Not ReallyConnected: "+pn);
return;
}
synchronized(this) {
for(int i=0;i<connectedPeers.length;i++) {
if(connectedPeers[i] == pn) {
- Logger.minor(this, "Already connected: "+pn);
+ if(logMINOR) Logger.minor(this, "Already connected: "+pn);
return;
}
}
@@ -228,12 +232,12 @@
Logger.error(this, "Connecting to "+pn+" but not in peers!");
addPeer(pn);
}
- Logger.minor(this, "Connecting: "+pn);
+ if(logMINOR) Logger.minor(this, "Connecting: "+pn);
PeerNode[] newConnectedPeers = new PeerNode[connectedPeers.length+1];
System.arraycopy(connectedPeers, 0, newConnectedPeers, 0,
connectedPeers.length);
newConnectedPeers[connectedPeers.length] = pn;
connectedPeers = newConnectedPeers;
- Logger.minor(this, "Connected peers: "+connectedPeers.length);
+ if(logMINOR) Logger.minor(this, "Connected peers:
"+connectedPeers.length);
}
updatePMUserAlert();
}
@@ -330,13 +334,14 @@
// This is safe as they will add themselves when they
// reconnect, and they can't do it yet as we are synchronized.
Vector v = new Vector(connectedPeers.length);
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
for(int i=0;i<myPeers.length;i++) {
PeerNode pn = myPeers[i];
if(pn == exclude) continue;
if(pn.isRoutable()) {
v.add(pn);
} else {
- Logger.minor(this, "Excluding "+pn+" because is disconnected");
+ if(logMINOR) Logger.minor(this, "Excluding "+pn+" because is
disconnected");
}
}
int lengthWithoutExcluded = v.size();
@@ -344,7 +349,7 @@
v.add(exclude);
PeerNode[] newConnectedPeers = new PeerNode[v.size()];
newConnectedPeers = (PeerNode[]) v.toArray(newConnectedPeers);
- Logger.minor(this, "Connected peers (in getRandomPeer):
"+newConnectedPeers.length+" was "+connectedPeers.length);
+ if(logMINOR) Logger.minor(this, "Connected peers (in getRandomPeer):
"+newConnectedPeers.length+" was "+connectedPeers.length);
connectedPeers = newConnectedPeers;
if(lengthWithoutExcluded == 0) return null;
return connectedPeers[node.random.nextInt(lengthWithoutExcluded)];
@@ -501,7 +506,7 @@
synchronized (this) {
peers = connectedPeers;
}
- Logger.minor(this, "Choosing closest peer:
connectedPeers="+peers.length);
+ if(logMINOR) Logger.minor(this, "Choosing closest peer:
connectedPeers="+peers.length);
double bestDiff = Double.MAX_VALUE;
double maxDiff = 0.0;
if(!ignoreSelf)
@@ -512,25 +517,25 @@
for(int i=0;i<peers.length;i++) {
PeerNode p = peers[i];
if(routedTo.contains(p)) {
- Logger.minor(this, "Skipping (already routed to):
"+p.getPeer());
+ if(logMINOR) Logger.minor(this, "Skipping (already routed to):
"+p.getPeer());
continue;
}
if(p == pn) {
- Logger.minor(this, "Skipping (req came from): "+p.getPeer());
+ if(logMINOR) Logger.minor(this, "Skipping (req came from):
"+p.getPeer());
continue;
}
if(!p.isRoutable()) {
- Logger.minor(this, "Skipping (not connected): "+p.getPeer());
+ if(logMINOR) Logger.minor(this, "Skipping (not connected):
"+p.getPeer());
continue;
}
if((!ignoreBackedOff) && p.isRoutingBackedOff()) {
- Logger.minor(this, "Skipping (routing backed off):
"+p.getPeer());
+ if(logMINOR) Logger.minor(this, "Skipping (routing backed off):
"+p.getPeer());
continue;
}
count++;
any = p;
double diff = distance(p, loc);
- Logger.minor(this, "p.loc="+p.getLocation().getValue()+",
loc="+loc+", d="+distance(p.getLocation().getValue(), loc)+" usedD="+diff+" for
"+p.getPeer());
+ if(logMINOR) Logger.minor(this,
"p.loc="+p.getLocation().getValue()+", loc="+loc+",
d="+distance(p.getLocation().getValue(), loc)+" usedD="+diff+" for
"+p.getPeer());
if((!ignoreSelf) && (diff > maxDiff)) continue;
if(diff < bestDiff) {
best = p;
Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/PeerNode.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -284,6 +284,8 @@
/** Queued-to-send N2NTM extra peer data file numbers */
private Vector queuedToSendN2NTMExtraPeerDataFileNumbers;
+ private static boolean logMINOR;
+
/**
* Create a PeerNode from a SimpleFieldSet containing a
* node reference for one. This must contain the following
@@ -298,6 +300,7 @@
* @param node2 The running Node we are part of.
*/
public PeerNode(SimpleFieldSet fs, Node node2, boolean fromLocal) throws
FSParseException, PeerParseException {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
this.node = node2;
String identityString = fs.get("identity");
if(identityString == null)
@@ -378,13 +381,14 @@
outgoingSetupKey = new byte[digestLength];
for(int i=0;i<outgoingSetupKey.length;i++)
outgoingSetupKey[i] = (byte) (nodeKeyHash[i] ^ identityHash[i]);
- Logger.minor(this, "Keys:\nIdentity:
"+HexUtil.bytesToHex(node.myIdentity)+
- "\nThisIdent: "+HexUtil.bytesToHex(identity)+
- "\nNode:
"+HexUtil.bytesToHex(nodeKey)+
- "\nNode hash:
"+HexUtil.bytesToHex(nodeKeyHash)+
- "\nThis:
"+HexUtil.bytesToHex(identityHash)+
- "\nThis hash:
"+HexUtil.bytesToHex(setupKeyHash)+
- "\nFor: "+getDetectedPeer());
+ if(logMINOR)
+ Logger.minor(this, "Keys:\nIdentity:
"+HexUtil.bytesToHex(node.myIdentity)+
+ "\nThisIdent: "+HexUtil.bytesToHex(identity)+
+ "\nNode: "+HexUtil.bytesToHex(nodeKey)+
+ "\nNode hash: "+HexUtil.bytesToHex(nodeKeyHash)+
+ "\nThis:
"+HexUtil.bytesToHex(identityHash)+
+ "\nThis hash:
"+HexUtil.bytesToHex(setupKeyHash)+
+ "\nFor: "+getDetectedPeer());
try {
incomingSetupCipher = new Rijndael(256,256);
@@ -630,11 +634,13 @@
if(ignoreHostnames) {
// Don't do a DNS request on the first cycle through PeerNodes by
DNSRequest
// upon startup (I suspect the following won't do anything, but
just in case)
- Logger.debug(this, "updateHandshakeIPs: calling getAddress(false)
on Peer '"+localHandshakeIPs[i]+"' for PeerNode '"+getPeer()+"' named
'"+getName()+"' ("+ignoreHostnames+")");
+ if(logMINOR)
+ Logger.debug(this, "updateHandshakeIPs: calling
getAddress(false) on Peer '"+localHandshakeIPs[i]+"' for PeerNode
'"+getPeer()+"' named '"+getName()+"' ("+ignoreHostnames+")");
localHandshakeIPs[i].getAddress(false);
} else {
// Actually do the DNS request for the member Peer of
localHandshakeIPs
- Logger.debug(this, "updateHandshakeIPs: calling
getHandshakeAddress() on Peer '"+localHandshakeIPs[i]+"' for PeerNode
'"+getPeer()+"' named '"+getName()+"' ("+ignoreHostnames+")");
+ if(logMINOR)
+ Logger.debug(this, "updateHandshakeIPs: calling
getHandshakeAddress() on Peer '"+localHandshakeIPs[i]+"' for PeerNode
'"+getPeer()+"' named '"+getName()+"' ("+ignoreHostnames+")");
localHandshakeIPs[i].getHandshakeAddress();
}
}
@@ -659,7 +665,7 @@
lastAttemptedHandshakeIPUpdateTime = now;
}
}
- Logger.minor(this, "Updating handshake IPs for peer '"+getPeer()+"'
named '"+getName()+"' ("+ignoreHostnames+")");
+ if(logMINOR) Logger.minor(this, "Updating handshake IPs for peer
'"+getPeer()+"' named '"+getName()+"' ("+ignoreHostnames+")");
Peer[] localHandshakeIPs;
Peer[] myNominalPeer;
@@ -674,7 +680,7 @@
synchronized(this) {
handshakeIPs = localHandshakeIPs;
}
- Logger.minor(this, "1: maybeUpdateHandshakeIPs got a
result of: "+handshakeIPsToString());
+ if(logMINOR) Logger.minor(this, "1:
maybeUpdateHandshakeIPs got a result of: "+handshakeIPsToString());
return;
}
localHandshakeIPs = new Peer[] { localDetectedPeer };
@@ -682,7 +688,7 @@
synchronized(this) {
handshakeIPs = localHandshakeIPs;
}
- Logger.minor(this, "2: maybeUpdateHandshakeIPs got a result of:
"+handshakeIPsToString());
+ if(logMINOR) Logger.minor(this, "2: maybeUpdateHandshakeIPs got
a result of: "+handshakeIPsToString());
return;
}
@@ -731,8 +737,10 @@
localDetectedPeer = detectedPeer = detectedDuplicate;
}
}
- Logger.minor(this, "3: detectedPeer = "+localDetectedPeer+"
("+localDetectedPeer.getAddress(false)+")");
- Logger.minor(this, "3: maybeUpdateHandshakeIPs got a result of:
"+handshakeIPsToString());
+ if(logMINOR) {
+ Logger.minor(this, "3: detectedPeer = "+localDetectedPeer+"
("+localDetectedPeer.getAddress(false)+")");
+ Logger.minor(this, "3: maybeUpdateHandshakeIPs got a result of:
"+handshakeIPsToString());
+ }
}
/**
@@ -806,7 +814,7 @@
* throttle it).
*/
public void sendAsync(Message msg, AsyncMessageCallback cb, int
alreadyReportedBytes, ByteCounter ctr) throws NotConnectedException {
- Logger.minor(this, "Sending async: "+msg+" : "+cb+" on "+this);
+ if(logMINOR) Logger.minor(this, "Sending async: "+msg+" : "+cb+" on
"+this);
if(!isConnected()) throw new NotConnectedException();
MessageItem item = new MessageItem(msg, cb == null ? null : new
AsyncMessageCallback[] {cb}, alreadyReportedBytes, ctr);
item.getData(this);
@@ -996,7 +1004,7 @@
synchronized(this) {
c = ctx;
}
- if(c != null)
+ if(c != null && logMINOR)
Logger.minor(this, "Last used: "+(now - c.lastUsedTime()));
return !((c == null) || (now - c.lastUsedTime() >
Node.HANDSHAKE_TIMEOUT));
}
@@ -1049,7 +1057,7 @@
if(!successfulHandshakeSend) {
handshakeIPs = null;
}
- Logger.minor(this, "Next BurstOnly mode
handshake in "+(sendHandshakeTime - now)+"ms for "+getName()+" (count:
"+listeningHandshakeBurstCount+", size: "+listeningHandshakeBurstSize+")", new
Exception("double-called debug"));
+ if(logMINOR) Logger.minor(this, "Next BurstOnly
mode handshake in "+(sendHandshakeTime - now)+"ms for "+getName()+" (count:
"+listeningHandshakeBurstCount+", size: "+listeningHandshakeBurstSize+")", new
Exception("double-called debug"));
}
}
setPeerNodeStatus(now); // Because of isBursting being set
above and it can't hurt others
@@ -1069,7 +1077,7 @@
* sent.
*/
public void sentHandshake() {
- Logger.minor(this, "sentHandshake(): "+this);
+ if(logMINOR) Logger.minor(this, "sentHandshake(): "+this);
calcNextHandshake(true);
}
@@ -1078,7 +1086,7 @@
* sent.
*/
public void couldNotSendHandshake() {
- Logger.minor(this, "couldNotSendHandshake(): "+this);
+ if(logMINOR) Logger.minor(this, "couldNotSendHandshake(): "+this);
calcNextHandshake(false);
}
@@ -1144,7 +1152,8 @@
* Update the Location to a new value.
*/
public void updateLocation(double newLoc) {
- synchronized(this) {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ synchronized(this) {
currentLocation.setValue(newLoc);
}
node.peers.writePeers();
@@ -1240,7 +1249,7 @@
Logger.error(this, "Received packet
while disconnected!: "+this, new Exception("error"));
throw new NotConnectedException();
} else {
- Logger.minor(this, "Received packet
while disconnected on "+this+" - recently disconnected() ?");
+ if(logMINOR) Logger.minor(this,
"Received packet while disconnected on "+this+" - recently disconnected() ?");
}
}
}
@@ -1264,7 +1273,7 @@
public synchronized void setDHContext(DiffieHellmanContext ctx2) {
this.ctx = ctx2;
- Logger.minor(this, "setDHContext("+ctx2+") on "+this);
+ if(logMINOR) Logger.minor(this, "setDHContext("+ctx2+") on "+this);
}
/**
@@ -1280,6 +1289,7 @@
* @return True unless we rejected the handshake, or it failed to parse.
*/
public boolean completedHandshake(long thisBootID, byte[] data, int
offset, int length, BlockCipher encCipher, byte[] encKey, Peer replyTo, boolean
unverified) {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
long now = System.currentTimeMillis();
arkFetcher.stop();
synchronized(this) {
@@ -1330,7 +1340,7 @@
boolean bootIDChanged = false;
synchronized(this) {
bootIDChanged = (thisBootID != this.bootID);
- if(bootIDChanged)
+ if(bootIDChanged && logMINOR)
Logger.minor(this, "Changed boot ID from
"+bootID+" to "+thisBootID+" for "+getPeer());
this.bootID = thisBootID;
connectedTime = now;
@@ -1356,7 +1366,7 @@
unverifiedTracker = newTracker;
ctx = null;
}
- Logger.minor(this, "sentHandshake() being called for
unverifiedTracker: "+getPeer());
+ if(logMINOR) Logger.minor(this, "sentHandshake() being
called for unverifiedTracker: "+getPeer());
sentHandshake();
} else {
KeyTracker prev;
@@ -1435,7 +1445,7 @@
long now = System.currentTimeMillis();
synchronized(this) {
if(tracker == unverifiedTracker) {
- Logger.minor(this, "Promoting unverified tracker "+tracker+" for
"+getPeer());
+ if(logMINOR) Logger.minor(this, "Promoting unverified tracker
"+tracker+" for "+getPeer());
if(previousTracker != null) {
previousTracker.completelyDeprecated(tracker);
}
@@ -1504,7 +1514,7 @@
}
}
}
- Logger.minor(this, "Reference: "+new String(data, offset,
length)+"("+length+")");
+ if(logMINOR) Logger.minor(this, "Reference: "+new String(data, offset,
length)+"("+length+")");
// Now decode it
ByteArrayInputStream bais = new ByteArrayInputStream(data, offset+1,
length-1);
InputStreamReader isr;
@@ -1528,7 +1538,7 @@
* Process a new nodereference, as a SimpleFieldSet.
*/
private void processNewNoderef(SimpleFieldSet fs, boolean forARK) throws
FSParseException {
- Logger.minor(this, "Parsing: \n"+fs);
+ if(logMINOR) Logger.minor(this, "Parsing: \n"+fs);
boolean changedAnything = innerProcessNewNoderef(fs, forARK);
if(changedAnything) node.peers.writePeers();
}
@@ -1614,7 +1624,7 @@
// In future, ARKs may support automatic transition when the ARK key
is changed.
// So parse it anyway. If it fails, no big loss; it won't even log an
error.
- Logger.minor(this, "Parsed successfully; changedAnything =
"+changedAnything);
+ if(logMINOR) Logger.minor(this, "Parsed successfully; changedAnything
= "+changedAnything);
if(parseARK(fs, false))
changedAnything = true;
@@ -1630,7 +1640,7 @@
* caused by a sequence inconsistency.
*/
public void sendAnyUrgentNotifications() throws PacketSequenceException {
- Logger.minor(this, "sendAnyUrgentNotifications");
+ if(logMINOR) Logger.minor(this, "sendAnyUrgentNotifications");
long now = System.currentTimeMillis();
KeyTracker cur, prev;
synchronized(this) {
@@ -1857,7 +1867,7 @@
long now = System.currentTimeMillis();
synchronized(routingBackoffSync) {
if(now < routingBackedOffUntil) {
- Logger.minor(this, "Routing is backed off");
+ if(logMINOR) Logger.minor(this, "Routing is
backed off");
return true;
} else return false;
}
@@ -1919,7 +1929,7 @@
*/
public void localRejectedOverload(String reason) {
pRejected.report(1.0);
- Logger.minor(this, "Local rejected overload ("+reason+") on
"+this+" : pRejected="+pRejected.currentValue());
+ if(logMINOR) Logger.minor(this, "Local rejected overload
("+reason+") on "+this+" : pRejected="+pRejected.currentValue());
long now = System.currentTimeMillis();
Peer peer = getPeer();
reportBackoffStatus(now);
@@ -1938,9 +1948,9 @@
reasonWrapper = " because of
'"+reason+"'";
}
- Logger.minor(this, "Backing
off"+reasonWrapper+": routingBackoffLength="+routingBackoffLength+", until
"+x+"ms on "+peer);
+ if(logMINOR) Logger.minor(this, "Backing
off"+reasonWrapper+": routingBackoffLength="+routingBackoffLength+", until
"+x+"ms on "+peer);
} else {
- Logger.minor(this, "Ignoring
localRejectedOverload: "+(routingBackedOffUntil-now)+"ms remaining on routing
backoff on "+peer);
+ if(logMINOR) Logger.minor(this, "Ignoring
localRejectedOverload: "+(routingBackedOffUntil-now)+"ms remaining on routing
backoff on "+peer);
}
}
}
@@ -1951,7 +1961,7 @@
*/
public void successNotOverload() {
pRejected.report(0.0);
- Logger.minor(this, "Success not overload on "+this+" :
pRejected="+pRejected.currentValue());
+ if(logMINOR) Logger.minor(this, "Success not overload on
"+this+" : pRejected="+pRejected.currentValue());
Peer peer = getPeer();
long now = System.currentTimeMillis();
reportBackoffStatus(now);
@@ -1959,10 +1969,10 @@
// Don't un-backoff if still backed off
if(now > routingBackedOffUntil) {
routingBackoffLength =
INITIAL_ROUTING_BACKOFF_LENGTH;
- Logger.minor(this, "Resetting routing backoff
on "+peer);
+ if(logMINOR) Logger.minor(this, "Resetting
routing backoff on "+peer);
setPeerNodeStatus(now);
} else {
- Logger.minor(this, "Ignoring
successNotOverload: "+(routingBackedOffUntil-now)+"ms remaining on routing
backoff on "+peer);
+ if(logMINOR) Logger.minor(this, "Ignoring
successNotOverload: "+(routingBackedOffUntil-now)+"ms remaining on routing
backoff on "+peer);
}
}
}
@@ -1992,13 +2002,13 @@
lPingNo = new Long(pingNo);
Long lnow = new Long(now);
pingsSentTimes.push(lPingNo, lnow);
- Logger.minor(this, "Pushed "+lPingNo+" "+lnow);
+ if(logMINOR) Logger.minor(this, "Pushed "+lPingNo+"
"+lnow);
while(pingsSentTimes.size() > MAX_PINGS) {
Long l = (Long) pingsSentTimes.popValue();
- Logger.minor(this,
"pingsSentTimes.size()="+pingsSentTimes.size()+", l="+l);
+ if(logMINOR) Logger.minor(this,
"pingsSentTimes.size()="+pingsSentTimes.size()+", l="+l);
long tStarted = l.longValue();
pingAverage.report(now - tStarted);
- Logger.minor(this, "Reporting dumped ping time
to "+this+" : "+(now - tStarted));
+ if(logMINOR) Logger.minor(this, "Reporting
dumped ping time to "+this+" : "+(now - tStarted));
}
}
Message msg = DMT.createFNPLinkPing(pingNo);
@@ -2024,7 +2034,7 @@
startTime = s.longValue();
pingsSentTimes.removeKey(lid);
pingAverage.report(now - startTime);
- Logger.minor(this, "Reporting ping time to "+this+" :
"+(now - startTime));
+ if(logMINOR) Logger.minor(this, "Reporting ping time to
"+this+" : "+(now - startTime));
}
if(shouldDisconnectNow()){
@@ -2039,7 +2049,7 @@
public void reportThrottledPacketSendTime(long timeDiff) {
node.throttledPacketSendAverage.report(timeDiff);
- Logger.minor(this, "Reporting throttled packet send time:
"+timeDiff+" to "+getPeer());
+ if(logMINOR) Logger.minor(this, "Reporting throttled packet
send time: "+timeDiff+" to "+getPeer());
}
public void setRemoteDetectedPeer(Peer p) {
@@ -2138,10 +2148,10 @@
} else if(myARK.suggestedEdition >
usk.suggestedEdition) {
Logger.minor(this, "Ignoring ARK edition
decrease: "+myARK.suggestedEdition+" to "+usk.suggestedEdition+" for "+this);
} else if(myARK.suggestedEdition <
usk.suggestedEdition) {
- Logger.minor(this, "New ARK edition found");
+ if(logMINOR) Logger.minor(this, "New ARK
edition found");
myARK = usk;
} else if(myARK == null) {
- Logger.minor(this, "Setting ARK to "+usk+" was
null on "+this);
+ if(logMINOR) Logger.minor(this, "Setting ARK to
"+usk+" was null on "+this);
myARK = usk;
}
} catch (MalformedURLException e) {
Modified: trunk/freenet/src/freenet/node/RequestHandler.java
===================================================================
--- trunk/freenet/src/freenet/node/RequestHandler.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/RequestHandler.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -20,6 +20,7 @@
*/
public class RequestHandler implements Runnable, ByteCounter {
+ private static boolean logMINOR;
final Message req;
final Node node;
final long uid;
@@ -59,7 +60,7 @@
int status = RequestSender.NOT_FINISHED;
RequestSender rs = null;
try {
- Logger.minor(this, "Handling a request: "+uid);
+ if(logMINOR) Logger.minor(this, "Handling a request: "+uid);
htl = source.decrementHTL(htl);
Message accepted = DMT.createFNPAccepted(uid);
@@ -74,7 +75,7 @@
if(needsPubKey) {
DSAPublicKey key =
((NodeSSK)block.getKey()).getPubKey();
Message pk = DMT.createFNPSSKPubKey(uid, key.asBytes());
- Logger.minor(this, "Sending PK: "+key+"
"+key.writeAsField());
+ if(logMINOR) Logger.minor(this, "Sending PK: "+key+"
"+key.writeAsField());
source.send(pk, null);
}
status = RequestSender.SUCCESS; // for byte logging
@@ -187,11 +188,11 @@
int sent = rs.getTotalSentBytes() + sentBytes;
int rcvd = rs.getTotalReceivedBytes() + receivedBytes;
if(key instanceof NodeSSK) {
- Logger.minor(this, "Remote SSK fetch cost
"+sent+"/"+rcvd+" bytes ("+status+")");
+ if(logMINOR) Logger.minor(this, "Remote SSK fetch cost
"+sent+"/"+rcvd+" bytes ("+status+")");
node.remoteSskFetchBytesSentAverage.report(sent);
node.remoteSskFetchBytesReceivedAverage.report(rcvd);
} else {
- Logger.minor(this, "Remote CHK fetch cost
"+sent+"/"+rcvd+" bytes ("+status+")");
+ if(logMINOR) Logger.minor(this, "Remote CHK fetch cost
"+sent+"/"+rcvd+" bytes ("+status+")");
node.remoteChkFetchBytesSentAverage.report(sent);
node.remoteChkFetchBytesReceivedAverage.report(rcvd);
}
Modified: trunk/freenet/src/freenet/node/RequestSender.java
===================================================================
--- trunk/freenet/src/freenet/node/RequestSender.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/RequestSender.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -74,8 +74,8 @@
static final int GENERATED_REJECTED_OVERLOAD = 7;
static final int INTERNAL_ERROR = 8;
+ private static boolean logMINOR;
-
public String toString() {
return super.toString()+" for "+uid;
}
@@ -97,6 +97,7 @@
this.resetNearestLoc = resetNearestLoc;
target = key.toNormalizedDouble();
node.addRequestSender(key, htl, this);
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
}
public void start() {
@@ -115,7 +116,7 @@
HashSet nodesNotIgnored = new HashSet();
try {
while(true) {
- Logger.minor(this, "htl="+htl);
+ if(logMINOR) Logger.minor(this, "htl="+htl);
if(htl == 0) {
// RNF
// Would be DNF if arrived with no HTL
@@ -138,12 +139,12 @@
finish(ROUTE_NOT_FOUND, null);
return;
}
- Logger.minor(this, "Routing request to "+next);
+ if(logMINOR) Logger.minor(this, "Routing request to "+next);
nodesRoutedTo.add(next);
if(PeerManager.distance(target, nextValue) >
PeerManager.distance(target, nearestLoc)) {
htl = node.decrementHTL(source, htl);
- Logger.minor(this, "Backtracking: target="+target+"
next="+nextValue+" closest="+nearestLoc+" so htl="+htl);
+ if(logMINOR) Logger.minor(this, "Backtracking:
target="+target+" next="+nextValue+" closest="+nearestLoc+" so htl="+htl);
}
Message req = createDataRequest();
@@ -178,14 +179,14 @@
try {
msg = node.usm.waitFor(mf, this);
- Logger.minor(this, "first part got "+msg);
+ if(logMINOR) Logger.minor(this, "first part got "+msg);
} catch (DisconnectedException e) {
Logger.normal(this, "Disconnected from "+next+" while
waiting for Accepted on "+uid);
break;
}
if(msg == null) {
- Logger.minor(this, "Timeout waiting for Accepted");
+ if(logMINOR) Logger.minor(this, "Timeout waiting for
Accepted");
// Timeout waiting for Accepted
next.localRejectedOverload("AcceptedTimeout");
forwardRejectedOverload();
@@ -194,20 +195,20 @@
}
if(msg.getSpec() == DMT.FNPRejectedLoop) {
- Logger.minor(this, "Rejected loop");
+ if(logMINOR) Logger.minor(this, "Rejected loop");
next.successNotOverload();
// Find another node to route to
break;
}
if(msg.getSpec() == DMT.FNPRejectedOverload) {
- Logger.minor(this, "Rejected: overload");
+ if(logMINOR) Logger.minor(this, "Rejected: overload");
// Non-fatal - probably still have time
left
forwardRejectedOverload();
if (msg.getBoolean(DMT.IS_LOCAL)) {
- Logger.minor(this, "Is local");
+ if(logMINOR) Logger.minor(this,
"Is local");
next.localRejectedOverload("ForwardRejectedOverload");
- Logger.minor(this, "Local
RejectedOverload, moving on to next peer");
+ if(logMINOR) Logger.minor(this,
"Local RejectedOverload, moving on to next peer");
// Give up on this one, try
another
break;
}
@@ -227,7 +228,7 @@
continue;
}
- Logger.minor(this, "Got Accepted");
+ if(logMINOR) Logger.minor(this, "Got Accepted");
// Otherwise, must be Accepted
@@ -252,7 +253,7 @@
break;
}
- Logger.minor(this, "second part got "+msg);
+ if(logMINOR) Logger.minor(this, "second part got "+msg);
if(msg == null) {
// Fatal timeout
@@ -281,7 +282,7 @@
forwardRejectedOverload();
if (msg.getBoolean(DMT.IS_LOCAL)) {
next.localRejectedOverload("ForwardRejectedOverload2");
- Logger.minor(this, "Local
RejectedOverload, moving on to next peer");
+ if(logMINOR) Logger.minor(this,
"Local RejectedOverload, moving on to next peer");
// Give up on this one, try
another
break;
}
@@ -316,9 +317,9 @@
BlockReceiver br = new BlockReceiver(node.usm,
next, uid, prb, this);
try {
- Logger.minor(this, "Receiving data");
+ if(logMINOR) Logger.minor(this,
"Receiving data");
byte[] data = br.receive();
- Logger.minor(this, "Received data");
+ if(logMINOR) Logger.minor(this,
"Received data");
// Received data
try {
verifyAndCommit(data);
@@ -341,7 +342,7 @@
if(msg.getSpec() == DMT.FNPSSKPubKey) {
- Logger.minor(this, "Got pubkey on "+uid);
+ if(logMINOR) Logger.minor(this, "Got pubkey on "+uid);
if(!(key instanceof NodeSSK)) {
Logger.error(this, "Got "+msg+" but expected a
different key type from "+next);
@@ -369,7 +370,7 @@
if(msg.getSpec() == DMT.FNPSSKDataFound) {
- Logger.minor(this, "Got data on "+uid);
+ if(logMINOR) Logger.minor(this, "Got data on "+uid);
if(!(key instanceof NodeSSK)) {
Logger.error(this, "Got "+msg+" but expected a
different key type from "+next);
@@ -395,7 +396,7 @@
Logger.error(this, "Caught "+t, t);
finish(INTERNAL_ERROR, null);
} finally {
- Logger.minor(this, "Leaving RequestSender.run() for "+uid);
+ if(logMINOR) Logger.minor(this, "Leaving RequestSender.run()
for "+uid);
node.completed(uid);
node.removeRequestSender(key, origHTL, this);
}
@@ -516,7 +517,7 @@
}
private void finish(int code, PeerNode next) {
- Logger.minor(this, "finish("+code+")");
+ if(logMINOR) Logger.minor(this, "finish("+code+")");
if(status != NOT_FINISHED)
throw new IllegalStateException("finish() called with "+code+"
when was already "+status);
status = code;
Modified: trunk/freenet/src/freenet/node/RequestStarter.java
===================================================================
--- trunk/freenet/src/freenet/node/RequestStarter.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/RequestStarter.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -75,16 +75,17 @@
void realRun() {
SendableRequest req = null;
while(true) {
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
if(req == null) req = sched.removeFirst();
if(req != null) {
- Logger.minor(this, "Running "+req);
+ if(logMINOR) Logger.minor(this, "Running "+req);
// Create a thread to handle starting the
request, and the resulting feedback
while(true) {
try {
Thread t = new Thread(new
SenderThread(req), "RequestStarter$SenderThread for "+req);
t.setDaemon(true);
t.start();
- Logger.minor(this, "Started
"+req+" on "+t);
+ if(logMINOR) Logger.minor(this,
"Started "+req+" on "+t);
break;
} catch (OutOfMemoryError e) {
// Probably out of threads
@@ -99,7 +100,7 @@
sentRequestTime = System.currentTimeMillis();
// Wait
long delay = throttle.getDelay();
- Logger.minor(this, "Delay="+delay+" from
"+throttle);
+ if(logMINOR) Logger.minor(this,
"Delay="+delay+" from "+throttle);
long sleepUntil = sentRequestTime + delay;
inputBucket.blockingGrab((int)(Math.max(0,
averageInputBytesPerRequest.currentValue())));
outputBucket.blockingGrab((int)(Math.max(0,
averageOutputBytesPerRequest.currentValue())));
@@ -109,14 +110,14 @@
if(now < sleepUntil)
try {
Thread.sleep(sleepUntil
- now);
- Logger.minor(this,
"Slept: "+(sleepUntil-now)+"ms");
+ if(logMINOR)
Logger.minor(this, "Slept: "+(sleepUntil-now)+"ms");
} catch (InterruptedException
e) {
// Ignore
}
} while(now < sleepUntil);
return;
} else {
- Logger.minor(this, "Waiting...");
+ if(logMINOR) Logger.minor(this, "Waiting...");
req = sched.removeFirst();
if(req != null) {
continue;
Modified: trunk/freenet/src/freenet/node/RequestStarterGroup.java
===================================================================
--- trunk/freenet/src/freenet/node/RequestStarterGroup.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/node/RequestStarterGroup.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -83,7 +83,8 @@
public synchronized void successfulCompletion(long rtt) {
roundTripTime.report(Math.max(rtt, 10));
- Logger.minor(this, "Reported successful completion:
"+rtt+" on "+this+" avg "+roundTripTime.currentValue());
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Reported successful
completion: "+rtt+" on "+this+" avg "+roundTripTime.currentValue());
}
public String toString() {
Modified: trunk/freenet/src/freenet/node/SSKInsertHandler.java
===================================================================
--- trunk/freenet/src/freenet/node/SSKInsertHandler.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/node/SSKInsertHandler.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -21,6 +21,8 @@
*/
public class SSKInsertHandler implements Runnable, ByteCounter {
+ private static boolean logMINOR;
+
static final int PUBKEY_TIMEOUT = 10000;
final Message req;
@@ -59,6 +61,7 @@
data = ((ShortBuffer) req.getObject(DMT.DATA)).getData();
headers = ((ShortBuffer) req.getObject(DMT.BLOCK_HEADERS)).getData();
canCommit = false;
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
}
public String toString() {
@@ -71,7 +74,7 @@
} catch (Throwable t) {
Logger.error(this, "Caught "+t, t);
} finally {
- Logger.minor(this, "Exiting InsertHandler.run() for "+uid);
+ if(logMINOR) Logger.minor(this, "Exiting InsertHandler.run() for
"+uid);
node.unlockUID(uid);
}
}
@@ -83,13 +86,13 @@
try {
source.send(accepted, this);
} catch (NotConnectedException e1) {
- Logger.minor(this, "Lost connection to source");
+ if(logMINOR) Logger.minor(this, "Lost connection to
source");
return;
}
if(pubKey == null) {
// Wait for pub key
- Logger.minor(this, "Waiting for pubkey on "+uid);
+ if(logMINOR) Logger.minor(this, "Waiting for pubkey on
"+uid);
MessageFilter mfPK =
MessageFilter.create().setType(DMT.FNPSSKPubKey).setField(DMT.UID,
uid).setSource(source).setTimeout(PUBKEY_TIMEOUT);
@@ -102,12 +105,12 @@
byte[] pubkeyAsBytes =
((ShortBuffer)pk.getObject(DMT.PUBKEY_AS_BYTES)).getData();
try {
pubKey = new
DSAPublicKey(pubkeyAsBytes);
- Logger.minor(this, "Got pubkey on
"+uid+" : "+pubKey);
+ if(logMINOR) Logger.minor(this, "Got
pubkey on "+uid+" : "+pubKey);
Message confirm =
DMT.createFNPSSKPubKeyAccepted(uid);
try {
source.sendAsync(confirm, null,
0, this);
} catch (NotConnectedException e) {
- Logger.minor(this, "Lost
connection to source on "+uid);
+ if(logMINOR) Logger.minor(this,
"Lost connection to source on "+uid);
return;
}
} catch (IOException e) {
@@ -121,7 +124,7 @@
return;
}
} catch (DisconnectedException e) {
- Logger.minor(this, "Lost connection to source
on "+uid);
+ if(logMINOR) Logger.minor(this, "Lost
connection to source on "+uid);
return;
}
}
@@ -147,12 +150,12 @@
try {
source.send(msg, this);
} catch (NotConnectedException e) {
- Logger.minor(this, "Lost connection to source
on "+uid);
+ if(logMINOR) Logger.minor(this, "Lost
connection to source on "+uid);
}
block = storedBlock;
}
- Logger.minor(this, "Got block for "+key+" for "+uid);
+ if(logMINOR) Logger.minor(this, "Got block for "+key+" for
"+uid);
if(htl == 0) {
Message msg = DMT.createFNPInsertReply(uid);
@@ -188,7 +191,7 @@
try {
source.send(m, this);
} catch (NotConnectedException e) {
- Logger.minor(this, "Lost connection to
source");
+ if(logMINOR) Logger.minor(this, "Lost
connection to source");
return;
}
}
@@ -207,7 +210,7 @@
try {
source.send(msg, this);
} catch (NotConnectedException e) {
- Logger.minor(this, "Lost connection to source");
+ if(logMINOR) Logger.minor(this, "Lost connection to
source");
return;
}
}
@@ -228,7 +231,7 @@
try {
source.send(msg, this);
} catch (NotConnectedException e) {
- Logger.minor(this, "Lost connection to
source");
+ if(logMINOR) Logger.minor(this, "Lost
connection to source");
return;
}
// Might as well store it anyway.
@@ -244,7 +247,7 @@
try {
source.send(msg, null);
} catch (NotConnectedException e) {
- Logger.minor(this, "Lost connection to
source");
+ if(logMINOR) Logger.minor(this, "Lost
connection to source");
return;
}
canCommit = true;
@@ -257,7 +260,7 @@
try {
source.send(msg, null);
} catch (NotConnectedException e) {
- Logger.minor(this, "Lost connection to
source");
+ if(logMINOR) Logger.minor(this, "Lost
connection to source");
return;
}
canCommit = true;
@@ -283,7 +286,7 @@
* verifies, then commit it.
*/
private void finish(int code) {
- Logger.minor(this, "Finishing");
+ if(logMINOR) Logger.minor(this, "Finishing");
if(canCommit) {
try {
@@ -301,7 +304,7 @@
totalSent += sender.getTotalSentBytes();
totalReceived += sender.getTotalReceivedBytes();
}
- Logger.minor(this, "Remote SSK insert cost
"+totalSent+"/"+totalReceived+" bytes ("+code+")");
+ if(logMINOR) Logger.minor(this, "Remote SSK insert cost
"+totalSent+"/"+totalReceived+" bytes ("+code+")");
node.remoteSskInsertBytesSentAverage.report(totalSent);
node.remoteSskInsertBytesReceivedAverage.report(totalReceived);
}
Modified: trunk/freenet/src/freenet/node/SSKInsertSender.java
===================================================================
--- trunk/freenet/src/freenet/node/SSKInsertSender.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/SSKInsertSender.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -52,6 +52,7 @@
private boolean hasCollided;
private boolean hasRecentlyCollided;
private SSKBlock block;
+ private static boolean logMINOR;
private int status = -1;
/** Still running */
@@ -70,6 +71,7 @@
static final int ROUTE_REALLY_NOT_FOUND = 6;
SSKInsertSender(SSKBlock block, long uid, short htl, PeerNode source, Node
node, boolean fromStore, double closestLoc) {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
this.fromStore = fromStore;
this.closestLocation = closestLoc;
this.node = node;
@@ -145,11 +147,11 @@
finish(ROUTE_NOT_FOUND, null);
return;
}
- Logger.minor(this, "Routing insert to "+next);
+ if(logMINOR) Logger.minor(this, "Routing insert to "+next);
nodesRoutedTo.add(next);
if(PeerManager.distance(target, nextValue) >
PeerManager.distance(target, closestLocation)) {
- Logger.minor(this, "Backtracking: target="+target+"
next="+nextValue+" closest="+closestLocation);
+ if(logMINOR) Logger.minor(this, "Backtracking:
target="+target+" next="+nextValue+" closest="+closestLocation);
htl = node.decrementHTL(source, htl);
}
@@ -171,7 +173,7 @@
try {
next.sendAsync(req, null, 0, this);
} catch (NotConnectedException e1) {
- Logger.minor(this, "Not connected to "+next);
+ if(logMINOR) Logger.minor(this, "Not connected
to "+next);
continue;
}
sentRequest = true;
@@ -197,7 +199,7 @@
if (msg == null) {
// Terminal overload
// Try to propagate back to source
- Logger.minor(this, "Timeout");
+ if(logMINOR) Logger.minor(this,
"Timeout");
next.localRejectedOverload("Timeout");
forwardRejectedOverload();
break;
@@ -207,8 +209,7 @@
// Non-fatal - probably still have time
left
if (msg.getBoolean(DMT.IS_LOCAL)) {
next.localRejectedOverload("ForwardRejectedOverload3");
- Logger.minor(this,
-
"Local RejectedOverload, moving on to next peer");
+ if(logMINOR) Logger.minor(this,
"Local RejectedOverload, moving on to next peer");
// Give up on this one, try
another
break;
} else {
@@ -235,7 +236,7 @@
if((msg == null) || (msg.getSpec() != DMT.FNPSSKAccepted))
continue;
- Logger.minor(this, "Got Accepted on "+this);
+ if(logMINOR) Logger.minor(this, "Got Accepted on "+this);
// Firstly, do we need to send them the pubkey?
@@ -244,7 +245,7 @@
try {
next.sendAsync(pkMsg, null, 0, this);
} catch (NotConnectedException e) {
- Logger.minor(this, "Node disconnected while sending
pubkey: "+next);
+ if(logMINOR) Logger.minor(this, "Node disconnected
while sending pubkey: "+next);
continue;
}
@@ -256,14 +257,14 @@
try {
newAck = node.usm.waitFor(mf1, null);
} catch (DisconnectedException e) {
- Logger.minor(this, "Disconnected from
"+next);
+ if(logMINOR) Logger.minor(this,
"Disconnected from "+next);
htl--;
break;
}
if(newAck == null) {
// Try to propagate back to source
- Logger.minor(this, "Timeout");
+ if(logMINOR) Logger.minor(this, "Timeout");
next.localRejectedOverload("Timeout2");
forwardRejectedOverload();
// Try another peer
@@ -319,7 +320,7 @@
// Probably non-fatal, if so, we have
time left, can try next one
if (msg.getBoolean(DMT.IS_LOCAL)) {
next.localRejectedOverload("ForwardRejectedOverload4");
- Logger.minor(this,
+ if(logMINOR) Logger.minor(this,
"Local
RejectedOverload, moving on to next peer");
// Give up on this one, try
another
break;
@@ -330,7 +331,7 @@
}
if (msg.getSpec() == DMT.FNPRouteNotFound) {
- Logger.minor(this, "Rejected: RNF");
+ if(logMINOR) Logger.minor(this,
"Rejected: RNF");
short newHtl = msg.getShort(DMT.HTL);
if (htl > newHtl)
htl = newHtl;
@@ -342,7 +343,7 @@
if (msg.getSpec() == DMT.FNPDataInsertRejected)
{
next.successNotOverload();
short reason =
msg.getShort(DMT.DATA_INSERT_REJECTED_REASON);
- Logger.minor(this, "DataInsertRejected:
" + reason);
+ if(logMINOR) Logger.minor(this,
"DataInsertRejected: " + reason);
if (reason ==
DMT.DATA_INSERT_REJECTED_VERIFY_FAILED) {
if (fromStore) {
// That's odd...
@@ -438,7 +439,7 @@
}
private void finish(int code, PeerNode next) {
- Logger.minor(this, "Finished: "+code+" on "+this, new
Exception("debug"));
+ if(logMINOR) Logger.minor(this, "Finished: "+code+" on "+this, new
Exception("debug"));
if(status != NOT_FINISHED)
throw new IllegalStateException("finish() called with "+code+"
when was already "+status);
@@ -451,7 +452,7 @@
notifyAll();
}
- Logger.minor(this, "Set status code: "+getStatusString());
+ if(logMINOR) Logger.minor(this, "Set status code: "+getStatusString());
// Nothing to wait for, no downstream transfers, just exit.
}
Modified: trunk/freenet/src/freenet/node/SendMessageOnErrorCallback.java
===================================================================
--- trunk/freenet/src/freenet/node/SendMessageOnErrorCallback.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/node/SendMessageOnErrorCallback.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -20,7 +20,8 @@
public SendMessageOnErrorCallback(Message message, PeerNode pn) {
this.msg = message;
this.dest = pn;
- Logger.minor(this, "Created "+this);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Created "+this);
}
public void sent() {
@@ -32,11 +33,13 @@
}
public void disconnected() {
- Logger.minor(this, "Disconnect trigger: "+this);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Disconnect trigger: "+this);
try {
dest.sendAsync(msg, null, 0, null);
} catch (NotConnectedException e) {
- Logger.minor(this, "Both source and destination disconnected:
"+msg+" for "+this);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Both source and destination
disconnected: "+msg+" for "+this);
}
}
Modified: trunk/freenet/src/freenet/node/SimpleSendableInsert.java
===================================================================
--- trunk/freenet/src/freenet/node/SimpleSendableInsert.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/node/SimpleSendableInsert.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -24,11 +24,13 @@
public void onSuccess() {
// Yay!
- Logger.minor(this, "Finished insert of "+block);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Finished insert of "+block);
}
public void onFailure(LowLevelPutException e) {
- Logger.minor(this, "Failed insert of "+block+": "+e);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Failed insert of "+block+": "+e);
}
public short getPriorityClass() {
@@ -41,17 +43,18 @@
}
public void send(NodeClientCore core) {
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
try {
- Logger.minor(this, "Starting request: "+this);
+ if(logMINOR) Logger.minor(this, "Starting request:
"+this);
core.realPut(block, false);
} catch (LowLevelPutException e) {
onFailure(e);
- Logger.minor(this, "Request failed: "+this+" for "+e);
+ if(logMINOR) Logger.minor(this, "Request failed:
"+this+" for "+e);
return;
} finally {
finished = true;
}
- Logger.minor(this, "Request succeeded: "+this);
+ if(logMINOR) Logger.minor(this, "Request succeeded: "+this);
onSuccess();
}
Modified: trunk/freenet/src/freenet/node/TestnetHandler.java
===================================================================
--- trunk/freenet/src/freenet/node/TestnetHandler.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/TestnetHandler.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -126,6 +126,7 @@
}
public void run() {
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
InputStream is = null;
OutputStream os = null;
try {
@@ -136,7 +137,7 @@
BufferedReader br = new BufferedReader(isr);
String command = br.readLine();
if(command == null) return;
- Logger.minor(this, "Command: "+command);
+ if(logMINOR) Logger.minor(this, "Command:
"+command);
FileLoggerHook loggerHook;
loggerHook =
Node.logConfigHandler.getFileLoggerHook();
if(loggerHook == null) {
@@ -146,12 +147,12 @@
return;
}
if(command.equalsIgnoreCase("LIST")) {
- Logger.minor(this, "Listing available
logs");
+ if(logMINOR) Logger.minor(this,
"Listing available logs");
OutputStreamWriter osw = new
OutputStreamWriter(os, "ISO-8859-1");
loggerHook.listAvailableLogs(osw);
osw.close();
} else if(command.startsWith("GET:")) {
- Logger.minor(this, "Sending log:
"+command);
+ if(logMINOR) Logger.minor(this,
"Sending log: "+command);
String date =
command.substring("GET:".length());
DateFormat df =
DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT,
Locale.ENGLISH);
df.setTimeZone(TimeZone.getTimeZone("GMT"));
@@ -159,17 +160,17 @@
try {
d = df.parse(date);
} catch (ParseException e) {
- Logger.minor(this, "Cannot
parse: "+e+" for "+date);
+ if(logMINOR) Logger.minor(this,
"Cannot parse: "+e+" for "+date);
return;
}
loggerHook.sendLogByContainedDate(d.getTime(), os);
} else if(command.equalsIgnoreCase("STATUS")) {
- Logger.minor(this, "Sending status");
+ if(logMINOR) Logger.minor(this,
"Sending status");
OutputStreamWriter osw = new
OutputStreamWriter(os, "ISO-8859-1");
osw.write(node.getStatus());
osw.close();
} else if(command.equalsIgnoreCase("PEERS")) {
- Logger.minor(this, "Sending
references");
+ if(logMINOR) Logger.minor(this,
"Sending references");
OutputStreamWriter osw = new
OutputStreamWriter(os, "ISO-8859-1");
osw.write("My ref:\n\n");
SimpleFieldSet fs =
node.exportPublicFieldSet();
Modified: trunk/freenet/src/freenet/node/TextModeClientInterface.java
===================================================================
--- trunk/freenet/src/freenet/node/TextModeClientInterface.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/node/TextModeClientInterface.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -86,7 +86,7 @@
try {
realRun();
} catch (IOException e) {
- Logger.minor(this, "Caught "+e, e);
+ if(Logger.shouldLog(Logger.MINOR, this)) Logger.minor(this,
"Caught "+e, e);
} catch (Throwable t) {
Logger.error(this, "Caught "+t, t);
}
@@ -197,7 +197,8 @@
boolean getCHKOnly = false;
if(line == null) return true;
String uline = line.toUpperCase();
- Logger.minor(this, "Command: "+line);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Command: "+line);
if(uline.startsWith("GET:")) {
// Should have a key next
String key = line.substring("GET:".length());
@@ -617,7 +618,8 @@
try{
n.config.get("node").getOption("name").setValue(key);
- Logger.minor(this, "Setting node.name to "+key);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Setting node.name to "+key);
}catch(Exception e){
Logger.error(this, "Error setting node's name");
}
Modified: trunk/freenet/src/freenet/node/ThrottleWindowManager.java
===================================================================
--- trunk/freenet/src/freenet/node/ThrottleWindowManager.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/node/ThrottleWindowManager.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -32,13 +32,15 @@
_droppedPackets++;
_totalPackets++;
_simulatedWindowSize *= PACKET_DROP_DECREASE_MULTIPLE;
- Logger.minor(this, "request rejected overload: "+this);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "request rejected overload: "+this);
}
public synchronized void requestCompleted() {
_totalPackets++;
_simulatedWindowSize += (PACKET_TRANSMIT_INCREMENT /
_simulatedWindowSize);
- Logger.minor(this, "requestCompleted on "+this);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "requestCompleted on "+this);
}
public synchronized String toString() {
Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-08-24 01:28:44 UTC (rev
10250)
+++ trunk/freenet/src/freenet/node/Version.java 2006-08-24 04:41:42 UTC (rev
10251)
@@ -136,9 +136,9 @@
return false;
}
} catch (NumberFormatException e) {
- Logger.minor(
- Version.class,
- "Not accepting (" + e + ") from " +
version);
+ if(Logger.shouldLog(Logger.MINOR,
Version.class))
+ Logger.minor(Version.class,
+ "Not accepting (" + e +
") from " + version);
return false;
}
}
@@ -207,9 +207,9 @@
return false;
}
} catch (NumberFormatException e) {
- Logger.minor(
- Version.class,
- "Not accepting (" + e + ") from " +
version + " and/or " + lastGoodVersion);
+ if(Logger.shouldLog(Logger.MINOR,
Version.class))
+ Logger.minor(Version.class,
+ "Not accepting (" + e +
") from " + version + " and/or " + lastGoodVersion);
return false;
}
}
Modified: trunk/freenet/src/freenet/node/fcp/ClientGet.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/ClientGet.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/fcp/ClientGet.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -400,7 +400,8 @@
getFailedMessage = new GetFailedMessage(e, identifier);
finished = true;
}
- Logger.minor(this, "Caught "+e, e);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Caught "+e, e);
trySendDataFoundOrGetFailed(null);
finish();
if(persistenceType != PERSIST_CONNECTION)
Modified: trunk/freenet/src/freenet/node/fcp/ClientGetMessage.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/ClientGetMessage.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/node/fcp/ClientGetMessage.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -148,7 +148,8 @@
throw new
MessageInvalidException(ProtocolErrorMessage.ERROR_PARSING_NUMBER, "Error
parsing MaxSize field: "+e.getMessage(), identifier);
}
}
- Logger.minor(this, "max retries="+maxRetries);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "max retries="+maxRetries);
String priorityString = fs.get("PriorityClass");
if(priorityString == null) {
// defaults to the one just below FProxy
Modified: trunk/freenet/src/freenet/node/fcp/ClientPut.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/ClientPut.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/fcp/ClientPut.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -87,7 +87,8 @@
Bucket tempData = data;
ClientMetadata cm = new ClientMetadata(mimeType);
boolean isMetadata = false;
- Logger.minor(this, "data = "+tempData+", uploadFrom =
"+ClientPutMessage.uploadFromString(uploadFrom));
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "data = "+tempData+",
uploadFrom = "+ClientPutMessage.uploadFromString(uploadFrom));
if(uploadFrom == ClientPutMessage.UPLOAD_FROM_REDIRECT) {
this.targetURI = redirectTarget;
Metadata m = new Metadata(Metadata.SIMPLE_REDIRECT,
targetURI, cm);
@@ -110,7 +111,7 @@
targetURI = null;
this.data = tempData;
this.clientMetadata = cm;
- Logger.minor(this, "data = "+data+", uploadFrom =
"+ClientPutMessage.uploadFromString(uploadFrom));
+ if(logMINOR) Logger.minor(this, "data = "+data+", uploadFrom =
"+ClientPutMessage.uploadFromString(uploadFrom));
inserter = new ClientPutter(this, data, uri, cm,
ctx,
client.core.requestStarters.chkPutScheduler,
client.core.requestStarters.sskPutScheduler, priorityClass,
getCHKOnly, isMetadata, client, null);
@@ -124,6 +125,7 @@
super(message.uri, message.identifier, message.verbosity,
handler,
message.priorityClass, message.persistenceType,
message.clientToken, message.global,
message.getCHKOnly, message.dontCompress,
message.maxRetries);
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
this.uploadFrom = message.uploadFromType;
this.origFilename = message.origFilename;
// Now go through the fields one at a time
@@ -140,7 +142,7 @@
Bucket tempData = message.bucket;
ClientMetadata cm = new ClientMetadata(mimeType);
boolean isMetadata = false;
- Logger.minor(this, "data = "+tempData+", uploadFrom =
"+ClientPutMessage.uploadFromString(uploadFrom));
+ if(logMINOR) Logger.minor(this, "data = "+tempData+",
uploadFrom = "+ClientPutMessage.uploadFromString(uploadFrom));
if(uploadFrom == ClientPutMessage.UPLOAD_FROM_REDIRECT) {
this.targetURI = message.redirectTarget;
Metadata m = new Metadata(Metadata.SIMPLE_REDIRECT,
targetURI, cm);
@@ -163,7 +165,7 @@
targetURI = null;
this.data = tempData;
this.clientMetadata = cm;
- Logger.minor(this, "data = "+data+", uploadFrom =
"+ClientPutMessage.uploadFromString(uploadFrom));
+ if(logMINOR) Logger.minor(this, "data = "+data+", uploadFrom =
"+ClientPutMessage.uploadFromString(uploadFrom));
inserter = new ClientPutter(this, data, uri, cm,
ctx,
client.core.requestStarters.chkPutScheduler,
client.core.requestStarters.sskPutScheduler, priorityClass,
getCHKOnly, isMetadata, client, null);
@@ -262,7 +264,8 @@
}
public void start() {
- Logger.minor(this, "Starting "+this+" : "+identifier);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Starting "+this+" : "+identifier);
if(finished) return;
try {
inserter.start();
Modified: trunk/freenet/src/freenet/node/fcp/ClientPutComplexDirMessage.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/ClientPutComplexDirMessage.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/node/fcp/ClientPutComplexDirMessage.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -57,16 +57,17 @@
SimpleFieldSet files = fs.subset("Files");
if(files == null)
throw new
MessageInvalidException(ProtocolErrorMessage.MISSING_FIELD, "Missing Files
section", identifier);
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
for(int i=0;;i++) {
SimpleFieldSet subset =
files.subset(Integer.toString(i));
if(subset == null) break;
DirPutFile f = DirPutFile.create(subset, identifier,
(persistenceType == ClientRequest.PERSIST_FOREVER) ? bfPersistent : bfTemp);
addFile(f);
- Logger.minor(this, "Adding "+f);
+ if(logMINOR) Logger.minor(this, "Adding "+f);
if(f instanceof DirectDirPutFile) {
totalBytes +=
((DirectDirPutFile)f).bytesToRead();
filesToRead.addLast(f);
- Logger.minor(this, "totalBytes now
"+totalBytes);
+ if(logMINOR) Logger.minor(this, "totalBytes now
"+totalBytes);
}
}
attachedBytes = totalBytes;
Modified: trunk/freenet/src/freenet/node/fcp/ClientPutDir.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/ClientPutDir.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/node/fcp/ClientPutDir.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -27,12 +27,14 @@
private final String defaultName;
private final long totalSize;
private final int numberOfFiles;
+ private static boolean logMINOR;
public ClientPutDir(FCPConnectionHandler handler, ClientPutDirMessage
message,
HashMap manifestElements) throws
IdentifierCollisionException {
super(message.uri, message.identifier, message.verbosity,
handler,
message.priorityClass, message.persistenceType,
message.clientToken, message.global,
message.getCHKOnly, message.dontCompress,
message.maxRetries);
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
this.manifestElements = manifestElements;
this.defaultName = message.defaultName;
SimpleManifestPutter p;
@@ -58,11 +60,12 @@
if(handler != null && (!handler.isGlobalSubscribed()))
handler.outputHandler.queue(msg);
}
- Logger.minor(this, "Putting dir "+identifier+" :
"+priorityClass);
+ if(logMINOR) Logger.minor(this, "Putting dir "+identifier+" :
"+priorityClass);
}
public ClientPutDir(SimpleFieldSet fs, FCPClient client) throws
PersistenceParseException, IOException {
super(fs, client);
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
SimpleFieldSet files = fs.subset("Files");
defaultName = fs.get("DefaultName");
// Flattened for disk, sort out afterwards
@@ -80,8 +83,8 @@
String contentTypeOverride =
subset.get("Metadata.ContentType");
String uploadFrom = subset.get("UploadFrom");
Bucket data = null;
- Logger.minor(this, "Parsing "+i);
- Logger.minor(this, "UploadFrom="+uploadFrom);
+ if(logMINOR) Logger.minor(this, "Parsing "+i);
+ if(logMINOR) Logger.minor(this,
"UploadFrom="+uploadFrom);
ManifestElement me;
if((uploadFrom == null) ||
uploadFrom.equalsIgnoreCase("direct")) {
long sz =
Long.parseLong(subset.get("DataLength"));
@@ -146,7 +149,7 @@
if(putter != null)
putter.start();
started = true;
- Logger.minor(this, "Started "+putter);
+ if(logMINOR) Logger.minor(this, "Started "+putter);
if(persistenceType != PERSIST_CONNECTION && !finished) {
FCPMessage msg = persistentTagMessage();
client.queueClientRequestMessage(msg, 0);
Modified: trunk/freenet/src/freenet/node/fcp/ClientPutDiskDirMessage.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/ClientPutDiskDirMessage.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/node/fcp/ClientPutDiskDirMessage.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -58,7 +58,8 @@
*/
private HashMap makeBucketsByName(File thisdir, String prefix) throws
MessageInvalidException {
- Logger.minor(this, "Listing directory: "+thisdir);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Listing directory: "+thisdir);
HashMap ret = new HashMap();
Modified: trunk/freenet/src/freenet/node/fcp/DirPutFile.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/DirPutFile.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/fcp/DirPutFile.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -64,7 +64,8 @@
String n = name;
int idx = n.lastIndexOf('/');
if(idx != -1) n = n.substring(idx+1);
- Logger.minor(this, "Element name: "+name+" -> "+n);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Element name: "+name+" -> "+n);
return new ManifestElement(n, getData(), getMIMEType(),
getData().size());
}
Modified: trunk/freenet/src/freenet/node/fcp/FCPClient.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/FCPClient.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/fcp/FCPClient.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -130,7 +130,8 @@
}
public void register(ClientRequest cg, boolean startLater) throws
IdentifierCollisionException {
- Logger.minor(this, "Registering
"+cg.getIdentifier()+(startLater ? " to start later" : ""));
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Registering
"+cg.getIdentifier()+(startLater ? " to start later" : ""));
synchronized(this) {
String ident = cg.getIdentifier();
ClientRequest old = (ClientRequest)
clientRequestsByIdentifier.get(ident);
@@ -148,7 +149,8 @@
public void removeByIdentifier(String identifier, boolean kill) throws
MessageInvalidException {
ClientRequest req;
- Logger.minor(this,
"removeByIdentifier("+identifier+","+kill+")");
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this,
"removeByIdentifier("+identifier+","+kill+")");
synchronized(this) {
req = (ClientRequest)
clientRequestsByIdentifier.get(identifier);
if(req == null)
@@ -158,7 +160,7 @@
clientRequestsByIdentifier.remove(identifier);
}
if(kill) {
- Logger.minor(this, "Killing request "+req);
+ if(logMINOR) Logger.minor(this, "Killing request "+req);
req.cancel();
}
server.forceStorePersistentRequests();
Modified: trunk/freenet/src/freenet/node/fcp/FCPConnectionHandler.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/FCPConnectionHandler.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/node/fcp/FCPConnectionHandler.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -137,7 +137,8 @@
}
public void startClientPut(ClientPutMessage message) {
- Logger.minor(this, "Starting insert
ID=\""+message.identifier+"\"");
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Starting insert
ID=\""+message.identifier+"\"");
String id = message.identifier;
ClientPut cp = null;
boolean success;
@@ -177,7 +178,8 @@
}
public void startClientPutDir(ClientPutDirMessage message, HashMap
buckets) {
- Logger.minor(this, "Start ClientPutDir");
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Start ClientPutDir");
String id = message.identifier;
ClientPutDir cp = null;
boolean success;
@@ -211,7 +213,8 @@
if(cp.isPersistentForever())
server.forceStorePersistentRequests();
}
- Logger.minor(this, "Starting "+cp);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Starting "+cp);
cp.start();
}
}
Modified: trunk/freenet/src/freenet/node/fcp/FCPConnectionInputHandler.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/FCPConnectionInputHandler.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/node/fcp/FCPConnectionInputHandler.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -25,7 +25,8 @@
try {
realRun();
} catch (IOException e) {
- Logger.minor(this, "Caught "+e, e);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Caught "+e, e);
} catch (Throwable t) {
Logger.error(this, "Caught "+t, t);
t.printStackTrace();
Modified: trunk/freenet/src/freenet/node/fcp/FCPConnectionOutputHandler.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/FCPConnectionOutputHandler.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/node/fcp/FCPConnectionOutputHandler.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -26,7 +26,8 @@
try {
realRun();
} catch (IOException e) {
- Logger.minor(this, "Caught "+e, e);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Caught "+e, e);
} catch (Throwable t) {
Logger.error(this, "Caught "+t, t);
}
Modified: trunk/freenet/src/freenet/node/fcp/FCPServer.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/FCPServer.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/node/fcp/FCPServer.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -44,6 +44,7 @@
*/
public class FCPServer implements Runnable {
+ private static boolean logMINOR;
public final static int DEFAULT_FCP_PORT = 9481;
NetworkInterface networkInterface;
final NodeClientCore core;
@@ -103,7 +104,7 @@
globalClient = new FCPClient("Global Queue", this, null, true);
-
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
}
public void maybeStart() throws IOException,
InvalidConfigValueException {
@@ -142,7 +143,7 @@
try {
realRun();
} catch (IOException e) {
- Logger.minor(this, "Caught "+e, e);
+ if(logMINOR) Logger.minor(this, "Caught "+e, e);
} catch (Throwable t) {
Logger.error(this, "Caught "+t, t);
}
@@ -470,7 +471,7 @@
}
public void forceStorePersistentRequests() {
- Logger.minor(this, "Forcing store persistent requests");
+ if(logMINOR) Logger.minor(this, "Forcing store persistent
requests");
if(!enablePersistentDownloads) return;
if(persister != null) {
persister.force();
@@ -482,9 +483,10 @@
/** Store all persistent requests to disk */
private void storePersistentRequests() {
- Logger.minor(this, "Storing persistent requests");
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "Storing persistent requests");
ClientRequest[] persistentRequests = getPersistentRequests();
- Logger.minor(this, "Persistent requests count:
"+persistentRequests.length);
+ if(logMINOR) Logger.minor(this, "Persistent requests count:
"+persistentRequests.length);
Bucket[] toFree = null;
try {
synchronized(persistenceSync) {
@@ -502,7 +504,7 @@
persistentRequests[i].write(w);
w.close();
if(!compressedTemp.renameTo(compressedFinal)) {
- Logger.minor(this, "Rename
failed");
+ if(logMINOR) Logger.minor(this,
"Rename failed");
compressedFinal.delete();
if(!compressedTemp.renameTo(compressedFinal)) {
Logger.error(this,
"Could not rename persisted requests temp file
"+persistentDownloadsTempFile+".gz to "+persistentDownloadsFile);
@@ -512,7 +514,7 @@
Logger.error(this, "Cannot write
persistent requests to disk: "+e);
}
}
- Logger.minor(this, "Stored persistent requests");
+ if(logMINOR) Logger.minor(this, "Stored persistent
requests");
} finally {
if(toFree != null) {
for(int i=0;i<toFree.length;i++)
Modified: trunk/freenet/src/freenet/node/fcp/GetFailedMessage.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/GetFailedMessage.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/node/fcp/GetFailedMessage.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -25,7 +25,8 @@
final FreenetURI redirectURI;
public GetFailedMessage(FetchException e, String identifier) {
- Logger.minor(this, "Creating get failed from "+e+" for
"+identifier, e);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Creating get failed from "+e+" for
"+identifier, e);
this.tracker = e.errorCodes;
this.code = e.mode;
this.codeDescription = FetchException.getMessage(code);
Modified: trunk/freenet/src/freenet/node/fcp/RedirectDirPutFile.java
===================================================================
--- trunk/freenet/src/freenet/node/fcp/RedirectDirPutFile.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/node/fcp/RedirectDirPutFile.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -23,7 +23,8 @@
} catch (MalformedURLException e) {
throw new
MessageInvalidException(ProtocolErrorMessage.INVALID_FIELD, "Invalid TargetURI:
"+e, identifier);
}
- Logger.minor(this, "targetURI = "+targetURI);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "targetURI = "+targetURI);
super.meta = new ClientMetadata();
}
Modified: trunk/freenet/src/freenet/node/updater/NodeUpdater.java
===================================================================
--- trunk/freenet/src/freenet/node/updater/NodeUpdater.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/node/updater/NodeUpdater.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -42,6 +42,7 @@
public final static String REVOCATION_URI = "freenet:SSK at
VOfCZVTYPaatJ~eB~4lu2cPrWEmGyt4bfbB1v15Z6qQ,B6EynLhm7QE0se~rMgWWhl7wh3rFWjxJsEUcyohAm8A,AQABAAE/revoked/";
public final static int REVOCATION_DNF_MIN = 3;
+ static private boolean logMINOR;
private FetcherContext ctx;
private FetcherContext ctxRevocation;
private FetchResult result;
@@ -72,6 +73,7 @@
private RevocationKeyFoundUserAlert revocationAlert;
public NodeUpdater(Node n, boolean isAutoUpdateAllowed, FreenetURI URI,
FreenetURI revocationURI) {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
this.URI = URI;
URI.setSuggestedEdition(Version.buildNumber()+1);
this.revocationURI = revocationURI;
@@ -121,7 +123,8 @@
}
public synchronized void onFoundEdition(long l, USK key){
- Logger.minor(this, "Found edition "+l);
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "Found edition "+l);
System.err.println("Found new update edition "+l);
if(!isRunning) return;
int found = (int)key.suggestedEdition;
@@ -141,7 +144,8 @@
ClientGetter toStart = null;
synchronized(this) {
try{
- Logger.minor(this, "maybeUpdate:
isFetching="+isFetching+", isRunning="+isRunning+",
isUpdatable="+isUpdatable()+", availableVersion="+availableVersion);
+ if(logMINOR)
+ Logger.minor(this, "maybeUpdate:
isFetching="+isFetching+", isRunning="+isRunning+",
isUpdatable="+isUpdatable()+", availableVersion="+availableVersion);
if(isFetching || (!isRunning) ||
(!isUpdatable())) return;
if(availableVersion == fetchedVersion) return;
fetchingVersion = availableVersion;
@@ -159,7 +163,7 @@
// We fetch it
try{
if((cg==null)||cg.isCancelled()){
- Logger.minor(this, "Scheduling request
for "+URI.setSuggestedEdition(availableVersion));
+ if(logMINOR) Logger.minor(this,
"Scheduling request for "+URI.setSuggestedEdition(availableVersion));
cg = new ClientGetter(this,
core.requestStarters.chkFetchScheduler, core.requestStarters.sskFetchScheduler,
URI.setSuggestedEdition(availableVersion), ctx,
RequestStarter.UPDATE_PRIORITY_CLASS,
this, new
ArrayBucket());
@@ -209,10 +213,10 @@
* Must run on its own thread.
*/
private void innerUpdate(){
- Logger.minor(this, "Update() called");
+ if(logMINOR) Logger.minor(this, "Update() called");
synchronized(this) {
if((result == null) || hasBeenBlown) {
- Logger.minor(this, "Returning:
result="+result+", isAutoUpdateAllowed="+isAutoUpdateAllowed+",
hasBeenBlown="+hasBeenBlown);
+ if(logMINOR) Logger.minor(this, "Returning:
result="+result+", isAutoUpdateAllowed="+isAutoUpdateAllowed+",
hasBeenBlown="+hasBeenBlown);
return;
}
@@ -409,6 +413,7 @@
}
public synchronized void onSuccess(FetchResult result, ClientGetter
state) {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
if(!state.getURI().equals(revocationURI)){
if(result == null || result.asBucket() == null ||
result.asBucket().size() == 0) {
Logger.error(this, "Cannot update: result
either null or empty for "+availableVersion);
@@ -461,10 +466,11 @@
}
public void onFailure(FetchException e, ClientGetter state) {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
int errorCode = e.getMode();
if(!state.getURI().equals(revocationURI)){
- Logger.minor(this, "onFailure("+e+","+state+")");
+ if(logMINOR) Logger.minor(this,
"onFailure("+e+","+state+")");
synchronized(this) {
this.cg = state;
isFetching=false;
@@ -506,7 +512,7 @@
}
private void queueFetchRevocation(long delay) {
- Logger.minor(this, "Queueing fetch of revocation key in
"+delay+"ms", new Exception("debug"));
+ if(logMINOR) Logger.minor(this, "Queueing fetch of revocation
key in "+delay+"ms", new Exception("debug"));
node.ps.queueTimedJob(new Runnable() { // maybe a FastRunnable?
FIXME
public void run() {
@@ -516,18 +522,18 @@
synchronized(this) {
if(revocationGetter != null &&
!(revocationGetter.isCancelled() || revocationGetter.isFinished())) {
- Logger.minor(this, "Not
queueing another revocation fetcher yet");
+ if(logMINOR)
Logger.minor(this, "Not queueing another revocation fetcher yet");
return;
} else {
- Logger.minor(this,
"fetcher="+revocationGetter);
+ if(logMINOR)
Logger.minor(this, "fetcher="+revocationGetter);
if(revocationGetter !=
null)
Logger.minor(this, "revocation fetcher:
cancelled="+revocationGetter.isCancelled()+",
finished="+revocationGetter.isFinished());
cg = revocationGetter =
new ClientGetter(NodeUpdater.this, core.requestStarters.chkFetchScheduler,
core.requestStarters.sskFetchScheduler, revocationURI, ctxRevocation,
RequestStarter.MAXIMUM_PRIORITY_CLASS, NodeUpdater.this, null);
- Logger.minor(this,
"Queued another revocation fetcher");
+ if(logMINOR)
Logger.minor(this, "Queued another revocation fetcher");
}
}
cg.start();
- Logger.minor(this, "Started revocation
fetcher");
+ if(logMINOR) Logger.minor(this,
"Started revocation fetcher");
} catch (FetchException e) {
Logger.error(this, "Not able to start
the revocation fetcher.");
blow("Cannot fetch the auto-update
URI");
Modified: trunk/freenet/src/freenet/store/BerkeleyDBFreenetStore.java
===================================================================
--- trunk/freenet/src/freenet/store/BerkeleyDBFreenetStore.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/store/BerkeleyDBFreenetStore.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -56,6 +56,8 @@
*/
public class BerkeleyDBFreenetStore implements FreenetStore {
+ private static boolean logMINOR;
+
final int dataBlockSize;
final int headerBlockSize;
@@ -89,6 +91,7 @@
* @throws FileNotFoundException if the dir does not exist and could not
be created
*/
public BerkeleyDBFreenetStore(String storeDir, long maxChkBlocks, int
blockSize, int headerSize, boolean throwOnTooFewKeys) throws IOException,
DatabaseException {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
this.dataBlockSize = blockSize;
this.headerBlockSize = headerSize;
this.freeBlocks = new SortedLongSet();
@@ -222,7 +225,7 @@
}
chkBlocksInStore = Math.max(chkBlocksInStore,
chkBlocksFromFile);
- Logger.minor(this, "Keys in store: "+chkBlocksInStore);
+ if(logMINOR) Logger.minor(this, "Keys in store:
"+chkBlocksInStore);
System.out.println("Keys in store: "+chkBlocksInStore+"
/ "+maxChkBlocks+" (db "+chkBlocksInDatabase+" file "+chkBlocksFromFile+")");
maybeShrink(true, true);
@@ -538,6 +541,7 @@
* @throws FileNotFoundException if the dir does not exist and could not
be created
*/
public BerkeleyDBFreenetStore(String storeDir, long maxChkBlocks, int
blockSize, int headerSize, short type) throws Exception {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
this.dataBlockSize = blockSize;
this.headerBlockSize = headerSize;
this.freeBlocks = new SortedLongSet();
@@ -732,14 +736,14 @@
t = null;
return;
}
- Logger.minor(this, "Found first key");
+ if(logMINOR) Logger.minor(this, "Found first key");
int x = 0;
while(true) {
StoreBlock storeBlock = (StoreBlock)
storeBlockTupleBinding.entryToObject(blockDBE);
- Logger.minor(this, "Found another key
("+(x++)+") ("+storeBlock.offset+")");
+ if(logMINOR) Logger.minor(this, "Found another key
("+(x++)+") ("+storeBlock.offset+")");
Long l = new Long(storeBlock.offset);
if(s.contains(l)) {
- Logger.minor(this, "Deleting (block
number conflict).");
+ if(logMINOR) Logger.minor(this,
"Deleting (block number conflict).");
chkDB.delete(t, keyDBE);
}
s.add(l);
@@ -842,9 +846,11 @@
t = null;
}
- Logger.minor(this, "Get key: "+chk);
- Logger.minor(this, "Headers: "+header.length+" bytes, hash
"+header);
- Logger.minor(this, "Data: "+data.length+" bytes, hash
"+data);
+ if(logMINOR) {
+ Logger.minor(this, "Get key: "+chk);
+ Logger.minor(this, "Headers: "+header.length+"
bytes, hash "+header);
+ Logger.minor(this, "Data: "+data.length+"
bytes, hash "+data);
+ }
}catch(CHKVerifyException ex){
Logger.error(this, "CHKBlock: Does not verify ("+ex+"),
setting accessTime to 0 for : "+chk);
@@ -940,9 +946,11 @@
t = null;
}
- Logger.minor(this, "Get key: "+chk);
- Logger.minor(this, "Headers: "+header.length+" bytes, hash
"+header);
- Logger.minor(this, "Data: "+data.length+" bytes, hash
"+data);
+ if(logMINOR) {
+ Logger.minor(this, "Get key: "+chk);
+ Logger.minor(this, "Headers: "+header.length+"
bytes, hash "+header);
+ Logger.minor(this, "Data: "+data.length+"
bytes, hash "+data);
+ }
}catch(SSKVerifyException ex){
Logger.normal(this, "SSKBlock: Does not verify
("+ex+"), setting accessTime to 0 for : "+chk, ex);
@@ -1029,12 +1037,12 @@
DSAPublicKey block = null;
byte[] data = new byte[dataBlockSize];
- Logger.minor(this, "Reading from store... "+storeBlock.offset+"
("+storeBlock.recentlyUsed+")");
+ if(logMINOR) Logger.minor(this, "Reading from store...
"+storeBlock.offset+" ("+storeBlock.recentlyUsed+")");
synchronized(chkStore) {
chkStore.seek(storeBlock.offset*(long)(dataBlockSize+headerBlockSize));
chkStore.readFully(data);
}
- Logger.minor(this, "Read");
+ if(logMINOR) Logger.minor(this, "Read");
try {
block = new DSAPublicKey(data);
@@ -1052,8 +1060,10 @@
t.commit();
t = null;
- Logger.minor(this, "Get key: "+HexUtil.bytesToHex(hash));
- Logger.minor(this, "Data: "+data.length+" bytes, hash "+data);
+ if(logMINOR) {
+ Logger.minor(this, "Get key:
"+HexUtil.bytesToHex(hash));
+ Logger.minor(this, "Data: "+data.length+" bytes, hash
"+data);
+ }
synchronized(this) {
hits++;
@@ -1105,10 +1115,10 @@
System.err.println("Freed block "+offset+"
("+reason+")");
Logger.normal(this, "Freed block "+offset+"
("+reason+")");
} else {
- Logger.minor(this, "Freed block "+offset+"
("+reason+")");
+ if(logMINOR) Logger.minor(this, "Freed block
"+offset+" ("+reason+")");
}
} else {
- Logger.minor(this, "Already freed block "+offset+"
("+reason+")");
+ if(logMINOR) Logger.minor(this, "Already freed block
"+offset+" ("+reason+")");
}
}
@@ -1236,9 +1246,11 @@
t.commit();
t = null;
- Logger.minor(this, "Put key: "+block.getKey());
- Logger.minor(this, "Headers: "+header.length+" bytes, hash
"+Fields.hashCode(header));
- Logger.minor(this, "Data: "+data.length+" bytes, hash
"+Fields.hashCode(data));
+ if(logMINOR) {
+ Logger.minor(this, "Put key: "+block.getKey());
+ Logger.minor(this, "Headers: "+header.length+" bytes,
hash "+Fields.hashCode(header));
+ Logger.minor(this, "Data: "+data.length+" bytes, hash
"+Fields.hashCode(data));
+ }
}catch(Throwable ex) { // FIXME: ugly
if(t!=null){
@@ -1364,8 +1376,10 @@
t.commit();
t = null;
- Logger.minor(this, "Put key: "+HexUtil.bytesToHex(hash));
- Logger.minor(this, "Data: "+data.length+" bytes, hash
"+Fields.hashCode(data));
+ if(logMINOR) {
+ Logger.minor(this, "Put key:
"+HexUtil.bytesToHex(hash));
+ Logger.minor(this, "Data: "+data.length+" bytes, hash
"+Fields.hashCode(data));
+ }
} catch(Throwable ex) { // FIXME: ugly
Logger.error(this, "Caught "+ex, ex);
@@ -1497,7 +1511,8 @@
// before we try to close it.
Currently we just guess
// This is nothing too problematic however
since the worst thing that should
// happen is that we miss the last few
store()'s and get an exception.
- Logger.minor(this, "Closing database.");
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "Closing database.");
closed=true;
// Give all threads some time to complete
if(sleep)
@@ -1537,7 +1552,7 @@
System.err.println("Caught closing database:
"+t);
t.printStackTrace();
}
- Logger.minor(this, "Closing database finished.");
+ if(logMINOR) Logger.minor(this, "Closing database finished.");
System.err.println("Closed database");
}catch(Exception ex){
Logger.error(this,"Error while closing database.",ex);
Modified: trunk/freenet/src/freenet/support/DoubleTokenBucket.java
===================================================================
--- trunk/freenet/src/freenet/support/DoubleTokenBucket.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/support/DoubleTokenBucket.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -19,6 +19,7 @@
private long maxForced;
private long curForced;
+ private static boolean logMINOR;
/**
* Create a DoubleTokenBucket.
@@ -28,7 +29,9 @@
*/
public DoubleTokenBucket(long max, long nanosPerTick, long
initialValue, long maxForced) {
super(max, nanosPerTick, initialValue);
- Logger.minor(this, "Max: "+max+" nanosPerTick: "+nanosPerTick+"
initialValue: "+initialValue+" maxForced: "+maxForced);
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR)
+ Logger.minor(this, "Max: "+max+" nanosPerTick:
"+nanosPerTick+" initialValue: "+initialValue+" maxForced: "+maxForced);
this.maxForced = maxForced;
this.curForced = 0;
}
@@ -41,7 +44,7 @@
addTokens();
long thisMax = maxForced - curForced;
if(tokens > thisMax) {
- Logger.minor(this, "Limiting force-grab to "+thisMax+"
tokens was "+tokens);
+ if(logMINOR) Logger.minor(this, "Limiting force-grab to
"+thisMax+" tokens was "+tokens);
tokens = thisMax;
}
curForced += tokens;
@@ -49,7 +52,7 @@
if(curForced > maxForced) {
curForced = maxForced;
}
- Logger.minor(this, "Force-Grabbed "+tokens+"
current="+current+" forced="+curForced);
+ if(logMINOR) Logger.minor(this, "Force-Grabbed "+tokens+"
current="+current+" forced="+curForced);
}
// blockingGrab is unchanged
@@ -72,11 +75,11 @@
curForced -= add;
if(curForced < 0) curForced = 0;
timeLastTick += add * nanosPerTick;
- Logger.minor(this, "Added "+add+" tokens current="+current+"
forced="+curForced);
+ if(logMINOR) Logger.minor(this, "Added "+add+" tokens
current="+current+" forced="+curForced);
}
public synchronized void addTokens() {
- Logger.minor(this, "current="+current+" forced="+curForced);
+ if(logMINOR) Logger.minor(this, "current="+current+"
forced="+curForced);
addTokensNoClip();
if(curForced > maxForced) curForced = maxForced;
if(current > max) current = max;
Modified: trunk/freenet/src/freenet/support/FileLoggerHook.java
===================================================================
--- trunk/freenet/src/freenet/support/FileLoggerHook.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/support/FileLoggerHook.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -249,7 +249,8 @@
}
System.err.println("Created log files");
startTime = gc.getTimeInMillis();
- Logger.minor(this, "Start time: "+gc+" ->
"+startTime);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Start time: "+gc+" ->
"+startTime);
lastTime = startTime;
gc.add(INTERVAL, INTERVAL_MULTIPLIER);
nextHour = gc.getTimeInMillis();
@@ -471,7 +472,8 @@
}
olf.filename.delete();
oldLogFilesDiskSpaceUsage -= olf.size;
- Logger.minor(this, "Deleting "+olf.filename+" -
saving "+olf.size+
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Deleting "+olf.filename+" -
saving "+olf.size+
" bytes, disk usage now:
"+oldLogFilesDiskSpaceUsage+" of "+maxOldLogfilesDiskUsage);
}
}
@@ -496,6 +498,7 @@
File oldFile = null;
previousFile.delete();
latestFile.renameTo(previousFile);
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
for(int i=0;i<files.length;i++) {
File f = files[i];
String name = f.getName();
@@ -504,7 +507,7 @@
continue;
}
if(!name.endsWith(".log.gz")) {
- Logger.minor(this, "Does not end in
.log.gz: "+name);
+ if(logMINOR) Logger.minor(this, "Does
not end in .log.gz: "+name);
f.delete();
continue;
} else {
@@ -512,7 +515,7 @@
}
name = name.substring(prefix.length());
if((name.length() == 0) || (name.charAt(0) !=
'-')) {
- Logger.minor(this, "Deleting
unrecognized: "+name+" ("+f.getPath()+")");
+ if(logMINOR) Logger.minor(this,
"Deleting unrecognized: "+name+" ("+f.getPath()+")");
f.delete();
continue;
} else
@@ -531,7 +534,7 @@
}
// First field: version
if(nums[0] != Version.buildNumber()) {
- Logger.minor(this, "Deleting old log
from build "+nums[0]+", current="+Version.buildNumber());
+ if(logMINOR) Logger.minor(this,
"Deleting old log from build "+nums[0]+", current="+Version.buildNumber());
// Logs that old are useless
f.delete();
continue;
@@ -916,10 +919,12 @@
Iterator i = logFiles.iterator();
while(i.hasNext()) {
OldLogFile olf = (OldLogFile) i.next();
- Logger.minor(this, "Checking "+time+" against
"+olf.filename+" : start="+olf.start+", end="+olf.end);
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR)
+ Logger.minor(this, "Checking "+time+" against
"+olf.filename+" : start="+olf.start+", end="+olf.end);
if((time >= olf.start) && (time < olf.end)) {
toReturn = olf;
- Logger.minor(this, "Found "+olf);
+ if(logMINOR) Logger.minor(this, "Found
"+olf);
break;
}
}
@@ -997,8 +1002,9 @@
}
olf.filename.delete();
oldLogFilesDiskSpaceUsage -= olf.size;
- Logger.minor(this, "Deleting "+olf.filename+" -
saving "+olf.size+
- " bytes, disk usage now:
"+oldLogFilesDiskSpaceUsage+" of "+maxOldLogfilesDiskUsage);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Deleting
"+olf.filename+" - saving "+olf.size+
+ " bytes, disk usage
now: "+oldLogFilesDiskSpaceUsage+" of "+maxOldLogfilesDiskUsage);
}
}
}
Modified: trunk/freenet/src/freenet/support/LRUHashtable.java
===================================================================
--- trunk/freenet/src/freenet/support/LRUHashtable.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/support/LRUHashtable.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -30,7 +30,8 @@
insert.value = value;
list.remove(insert);
}
- Logger.minor(this, "Pushed "+insert+" ( "+key+" "+value+" )");
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Pushed "+insert+" ( "+key+" "+value+" )");
list.unshift(insert);
}
Modified: trunk/freenet/src/freenet/support/LimitedRangeIntByteArrayMap.java
===================================================================
--- trunk/freenet/src/freenet/support/LimitedRangeIntByteArrayMap.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/support/LimitedRangeIntByteArrayMap.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -17,6 +17,7 @@
*/
public class LimitedRangeIntByteArrayMap {
+ private static boolean logMINOR;
private final HashMap contents;
private int minValue;
private int maxValue;
@@ -30,6 +31,7 @@
minValue = -1;
maxValue = -1;
flag = false;
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
}
public synchronized int minValue() {
@@ -70,7 +72,8 @@
* of range.
*/
public synchronized boolean add(int index, byte[] data,
AsyncMessageCallback[] callbacks) {
- Logger.minor(this, toString()+" add "+index);
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, toString()+" add "+index);
if(maxValue == -1) {
minValue = index;
maxValue = index;
@@ -109,15 +112,15 @@
boolean oldFlag = flag;
if(minValue == -1) return;
if(index - minValue < maxRange) return;
- Logger.minor(this, toString()+" lock("+index+") - minValue =
"+minValue+", maxValue = "+maxValue+", maxRange="+maxRange);
+ if(logMINOR) Logger.minor(this, toString()+" lock("+index+") -
minValue = "+minValue+", maxValue = "+maxValue+", maxRange="+maxRange);
while(true) {
wait();
if(flag != oldFlag) {
- Logger.minor(this, "Interrupted");
+ if(logMINOR) Logger.minor(this, "Interrupted");
throw new InterruptedException();
}
if((index - minValue < maxRange) || (minValue == -1)) {
- Logger.minor(this, "index="+index+", minValue="+minValue+",
maxRange="+maxRange+" - returning");
+ if(logMINOR) Logger.minor(this, "index="+index+",
minValue="+minValue+", maxRange="+maxRange+" - returning");
return;
}
}
@@ -138,7 +141,7 @@
* @return true if we removed something.
*/
public synchronized boolean remove(int index) {
- Logger.minor(this, "Removing "+index+" - min="+minValue+"
max="+maxValue);
+ if(logMINOR) Logger.minor(this, "Removing "+index+" - min="+minValue+"
max="+maxValue);
if(contents.remove(new Integer(index)) != null) {
if((index > minValue) && (index < maxValue)) return true;
if(contents.size() == 0) {
Modified: trunk/freenet/src/freenet/support/NumberedItemComparator.java
===================================================================
--- trunk/freenet/src/freenet/support/NumberedItemComparator.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/support/NumberedItemComparator.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -12,7 +12,7 @@
public int compare(Object o1, Object o2) {
int x = ocompare(o1, o2);
- Logger.minor(this, "compare("+o1+","+o2+") = "+x);
+ //Logger.minor(this, "compare("+o1+","+o2+") = "+x);
return x;
}
Modified: trunk/freenet/src/freenet/support/NumberedRecentItems.java
===================================================================
--- trunk/freenet/src/freenet/support/NumberedRecentItems.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/support/NumberedRecentItems.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -43,7 +43,8 @@
public synchronized boolean add(NumberedItem item) {
long num = item.getNumber();
int x = Arrays.binarySearch(items, new Long(num), myComparator);
- Logger.minor(this, "Search pos: "+x);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Search pos: "+x);
if(x >= 0) return false; // already present
count++;
if(x == -1) {
Modified: trunk/freenet/src/freenet/support/RandomGrabArray.java
===================================================================
--- trunk/freenet/src/freenet/support/RandomGrabArray.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/support/RandomGrabArray.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -32,7 +32,8 @@
public synchronized void add(RandomGrabArrayItem req) {
if(contents.contains(req)) return;
if(req.isFinished()) {
- Logger.minor(this, "Is finished already: "+req);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Is finished already: "+req);
return;
}
contents.add(req);
Modified: trunk/freenet/src/freenet/support/SimpleIntNumberedItemComparator.java
===================================================================
--- trunk/freenet/src/freenet/support/SimpleIntNumberedItemComparator.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/support/SimpleIntNumberedItemComparator.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -12,7 +12,7 @@
public int compare(Object o1, Object o2) {
int x = ocompare(o1, o2);
- Logger.debug(this, "compare("+o1+","+o2+") = "+x);
+ //Logger.debug(this, "compare("+o1+","+o2+") = "+x);
return x;
}
Modified: trunk/freenet/src/freenet/support/SortedLongSet.java
===================================================================
--- trunk/freenet/src/freenet/support/SortedLongSet.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/support/SortedLongSet.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -89,10 +89,11 @@
}
private synchronized void push(long num, int x) {
- Logger.minor(this, "Insertion point: "+x+" length "+length+"
data.length "+data.length);
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "Insertion point: "+x+" length
"+length+" data.length "+data.length);
// Move the data
if(length == data.length) {
- Logger.minor(this, "Expanding from "+length+" to
"+length*2);
+ if(logMINOR) Logger.minor(this, "Expanding from
"+length+" to "+length*2);
long[] newData = new long[length*2];
System.arraycopy(data, 0, newData, 0, data.length);
for(int i=length;i<newData.length;i++)
Modified: trunk/freenet/src/freenet/support/SortedVectorByNumber.java
===================================================================
--- trunk/freenet/src/freenet/support/SortedVectorByNumber.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/support/SortedVectorByNumber.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -87,10 +87,11 @@
}
private synchronized void push(IntNumberedItem grabber, int x) {
- Logger.minor(this, "Insertion point: "+x);
+ boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "Insertion point: "+x);
// Move the data
if(length == data.length) {
- Logger.minor(this, "Expanding from "+length+" to
"+length*2);
+ if(logMINOR) Logger.minor(this, "Expanding from
"+length+" to "+length*2);
IntNumberedItem[] newData = new
IntNumberedItem[length*2];
System.arraycopy(data, 0, newData, 0, data.length);
}
Modified: trunk/freenet/src/freenet/support/TokenBucket.java
===================================================================
--- trunk/freenet/src/freenet/support/TokenBucket.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/support/TokenBucket.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -6,6 +6,7 @@
*/
public class TokenBucket {
+ private static boolean logMINOR;
protected long current;
protected long max;
protected long timeLastTick;
@@ -24,6 +25,7 @@
long now = System.currentTimeMillis();
this.timeLastTick = now * (1000 * 1000);
nextWake = now;
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
}
/**
@@ -65,7 +67,8 @@
}
public synchronized void blockingGrab(long tokens) {
- Logger.minor(this, "Blocking grab: "+tokens);
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ if(logMINOR) Logger.minor(this, "Blocking grab: "+tokens);
if(tokens < max)
innerBlockingGrab(tokens);
else {
@@ -80,13 +83,13 @@
* @param tokens The number of tokens to grab.
*/
public synchronized void innerBlockingGrab(long tokens) {
- Logger.minor(this, "Inner blocking grab: "+tokens);
+ if(logMINOR) Logger.minor(this, "Inner blocking grab: "+tokens);
addTokens();
if(current > max) current = max;
- Logger.minor(this, "current="+current);
+ if(logMINOR) Logger.minor(this, "current="+current);
if(current > tokens) {
current -= tokens;
- Logger.minor(this, "Got tokens instantly,
current="+current);
+ if(logMINOR) Logger.minor(this, "Got tokens instantly,
current="+current);
return;
}
long extra = 0;
@@ -95,7 +98,7 @@
current = 0;
} else if(current < 0) {
extra = -current;
- Logger.minor(this, "Neutralizing debt: "+extra);
+ if(logMINOR) Logger.minor(this, "Neutralizing debt:
"+extra);
current = 0;
}
long minDelayNS = nanosPerTick * (tokens + extra);
@@ -105,18 +108,18 @@
// Schedule between the blockingGrab's.
if(nextWake < now) {
- Logger.minor(this, "Resetting nextWake to now");
+ if(logMINOR) Logger.minor(this, "Resetting nextWake to
now");
nextWake = now;
}
- Logger.minor(this, "nextWake: "+(nextWake - now)+"ms");
+ if(logMINOR) Logger.minor(this, "nextWake: "+(nextWake -
now)+"ms");
long wakeAt = nextWake + minDelayMS;
nextWake = wakeAt;
- Logger.minor(this, "nextWake now: "+(nextWake - now)+"ms");
+ if(logMINOR) Logger.minor(this, "nextWake now: "+(nextWake -
now)+"ms");
while(true) {
now = System.currentTimeMillis();
int delay = (int) Math.min(Integer.MAX_VALUE, wakeAt -
now);
if(delay <= 0) break;
- Logger.minor(this, "Waiting "+delay+"ms");
+ if(logMINOR) Logger.minor(this, "Waiting "+delay+"ms");
try {
wait(delay);
} catch (InterruptedException e) {
@@ -127,7 +130,7 @@
// will therefore go negative. We have paid off the initial
debt, and we have
// paid off the tokens, any more debt is a problem for future
blockingGrab's!
current -= tokens;
- Logger.minor(this, "Blocking grab removed tokens:
current="+current);
+ if(logMINOR) Logger.minor(this, "Blocking grab removed tokens:
current="+current);
}
public synchronized void recycle(long tokens) {
Modified: trunk/freenet/src/freenet/support/UpdatableSortedLinkedList.java
===================================================================
--- trunk/freenet/src/freenet/support/UpdatableSortedLinkedList.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/support/UpdatableSortedLinkedList.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -12,16 +12,19 @@
public class UpdatableSortedLinkedList {
private boolean killed = false;
+ private static boolean logMINOR;
public UpdatableSortedLinkedList() {
list = new DoublyLinkedListImpl();
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
}
private final DoublyLinkedList list;
public synchronized void add(UpdatableSortedLinkedListItem i) throws
UpdatableSortedLinkedListKilledException {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
if(killed) throw new UpdatableSortedLinkedListKilledException();
- Logger.minor(this, "Add("+i+") on "+this);
+ if(logMINOR) Logger.minor(this, "Add("+i+") on "+this);
if(list.isEmpty()) {
list.push(i);
checkList();
@@ -48,7 +51,7 @@
checkList();
return;
}
- Logger.minor(this, "Not matching "+cur+" "+prev);
+ if(logMINOR) Logger.minor(this, "Not matching "+cur+" "+prev);
prev = cur;
}
throw new IllegalStateException("impossible");
@@ -79,12 +82,13 @@
}
public synchronized UpdatableSortedLinkedListItem
remove(UpdatableSortedLinkedListItem i) throws
UpdatableSortedLinkedListKilledException {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
if(killed) throw new UpdatableSortedLinkedListKilledException();
- Logger.minor(this, "Remove("+i+") on "+this);
+ if(logMINOR) Logger.minor(this, "Remove("+i+") on "+this);
checkList();
UpdatableSortedLinkedListItem item =
(UpdatableSortedLinkedListItem) list.remove(i);
- Logger.minor(this, "Returning "+item);
+ if(logMINOR) Logger.minor(this, "Returning "+item);
checkList();
return item;
}
@@ -98,8 +102,9 @@
}
public synchronized void update(UpdatableSortedLinkedListItem i) throws
UpdatableSortedLinkedListKilledException {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
if(killed) throw new UpdatableSortedLinkedListKilledException();
- Logger.minor(this, "Update("+i+") on "+this);
+ if(logMINOR) Logger.minor(this, "Update("+i+") on "+this);
checkList();
if(i.compareTo(list.tail()) > 0) {
list.remove(i);
@@ -165,7 +170,7 @@
}
}
Logger.error(this, "Could not update "+i, new Exception("error"));
- dump();
+ if(logMINOR) dump();
remove(i);
add(i);
checkList();
@@ -179,7 +184,7 @@
if(killed) throw new UpdatableSortedLinkedListKilledException();
for(Enumeration e=list.elements();e.hasMoreElements();) {
UpdatableSortedLinkedListItem item =
(UpdatableSortedLinkedListItem) e.nextElement();
- Logger.minor(this, item.toString());
+ if(logMINOR) Logger.minor(this, item.toString());
}
}
Modified: trunk/freenet/src/freenet/support/io/FilenameGenerator.java
===================================================================
--- trunk/freenet/src/freenet/support/io/FilenameGenerator.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/support/io/FilenameGenerator.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -55,7 +55,8 @@
String filename = prefix +
HexUtil.bytesToHex(randomFilename);
File ret = new File(tmpDir, filename);
if(!ret.exists()) {
- Logger.minor(this, "Made random filename:
"+ret, new Exception("debug"));
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Made random
filename: "+ret, new Exception("debug"));
return ret;
}
}
Modified:
trunk/freenet/src/freenet/support/io/PaddedEphemerallyEncryptedBucket.java
===================================================================
--- trunk/freenet/src/freenet/support/io/PaddedEphemerallyEncryptedBucket.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/support/io/PaddedEphemerallyEncryptedBucket.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -292,7 +292,8 @@
if(size < min)
throw new IllegalStateException("???");
if((size >= min) && (size <= max)) {
- Logger.minor(this, "Padded: "+max+" was:
"+dataLength+" for "+getName());
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Padded: "+max+"
was: "+dataLength+" for "+getName());
return max;
}
min = max;
Modified: trunk/freenet/src/freenet/support/io/PersistentTempBucketFactory.java
===================================================================
--- trunk/freenet/src/freenet/support/io/PersistentTempBucketFactory.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/support/io/PersistentTempBucketFactory.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -56,7 +56,8 @@
if(f.isDirectory()) continue;
if(!f.exists()) continue;
if(!name.startsWith(prefix)) {
- Logger.minor(this, "Ignoring "+name);
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Ignoring "+name);
continue;
}
originalFiles.add(f);
Modified: trunk/freenet/src/freenet/support/io/RandomAccessFileBucket.java
===================================================================
--- trunk/freenet/src/freenet/support/io/RandomAccessFileBucket.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/support/io/RandomAccessFileBucket.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -139,13 +139,15 @@
if (streams.elementAt(i) instanceof InputStream) {
((InputStream)streams.elementAt(i)).close();
- Logger.debug(this, "closed open InputStream !: " +
- file.getAbsolutePath());
+ if(Logger.shouldLog(Logger.DEBUG, this))
+ Logger.debug(this, "closed open InputStream !: " +
+ file.getAbsolutePath());
}
else if (streams.elementAt(i) instanceof OutputStream) {
((OutputStream)streams.elementAt(i)).close();
- Logger.debug(this, "closed open OutputStream !: " +
- file.getAbsolutePath());
+ if(Logger.shouldLog(Logger.DEBUG, this))
+ Logger.debug(this, "closed open OutputStream !: " +
+ file.getAbsolutePath());
}
}
catch (IOException ioe) {
@@ -327,7 +329,8 @@
private final void println(String text) {
if (vociferous) {
- Logger.debug(this, text);
+ if(Logger.shouldLog(Logger.DEBUG, this))
+ Logger.debug(this, text);
}
}
@@ -420,7 +423,8 @@
////////////////////////////////////////////////////////////
private void println(String text) {
if (vociferous) {
- Logger.debug(this, text);
+ if(Logger.shouldLog(Logger.DEBUG, this))
+ Logger.debug(this, text);
}
}
Modified: trunk/freenet/src/freenet/support/io/TempFileBucket.java
===================================================================
--- trunk/freenet/src/freenet/support/io/TempFileBucket.java 2006-08-24
01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/support/io/TempFileBucket.java 2006-08-24
04:41:42 UTC (rev 10251)
@@ -142,7 +142,8 @@
* @return Success
*/
public synchronized boolean release() {
- Logger.minor(this, "Releasing bucket: "+file, new
Exception("debug"));
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this, "Releasing bucket: "+file, new
Exception("debug"));
//System.err.println("FProxyServlet.TempFileBucket -- release:
" + // file.getAbsolutePath());
//System.err.println("CALL STACK: ");
@@ -197,9 +198,9 @@
if (logDebug)
Logger.debug(this, "Closed streams for " + file);
if (released) {
- Logger.minor(
- this,
- "Already released file: " + file.getName());
+ if(Logger.shouldLog(Logger.MINOR, this))
+ Logger.minor(this,
+ "Already released file: " +
file.getName());
if (file.exists())
throw new IllegalStateException(
"already released file "
Modified:
trunk/freenet/src/freenet/support/math/BootstrappingDecayingRunningAverage.java
===================================================================
---
trunk/freenet/src/freenet/support/math/BootstrappingDecayingRunningAverage.java
2006-08-24 01:28:44 UTC (rev 10250)
+++
trunk/freenet/src/freenet/support/math/BootstrappingDecayingRunningAverage.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -66,11 +66,13 @@
public synchronized void report(double d) {
if(d < min) {
- Logger.debug(this, "Too low: "+d, new Exception("debug"));
+ if(Logger.shouldLog(Logger.DEBUG, this))
+ Logger.debug(this, "Too low: "+d, new
Exception("debug"));
d = min;
}
if(d > max) {
- Logger.debug(this, "Too high: "+d, new Exception("debug"));
+ if(Logger.shouldLog(Logger.DEBUG, this))
+ Logger.debug(this, "Too high: "+d, new
Exception("debug"));
d = max;
}
reports++;
Modified: trunk/freenet/src/freenet/support/math/TimeDecayingRunningAverage.java
===================================================================
--- trunk/freenet/src/freenet/support/math/TimeDecayingRunningAverage.java
2006-08-24 01:28:44 UTC (rev 10250)
+++ trunk/freenet/src/freenet/support/math/TimeDecayingRunningAverage.java
2006-08-24 04:41:42 UTC (rev 10251)
@@ -137,8 +137,8 @@
if(!started) {
curValue = d;
started = true;
- //if(logDEBUG)
- Logger.minor(this, "Reported "+d+" on
"+this+" when just started");
+ if(logDEBUG)
+ Logger.debug(this, "Reported "+d+" on
"+this+" when just started");
} else if(lastReportTime != -1) { // might be just
serialized in
long thisInterval =
now - lastReportTime;
@@ -151,8 +151,8 @@
double oldCurValue = curValue;
curValue = curValue * changeFactor /* close to
1.0 if short interval, close to 0.0 if long interval */
+ (1.0 - changeFactor) * d;
- //if(logDEBUG)
- Logger.minor(this, "Reported "+d+" on
"+this+": thisInterval="+thisInterval+
+ if(logDEBUG)
+ Logger.debug(this, "Reported "+d+" on
"+this+": thisInterval="+thisInterval+
",
halfLife="+halfLife+", uptime="+uptime+", thisHalfLife="+thisHalfLife+
",
changeFactor="+changeFactor+", oldCurValue="+oldCurValue+
",
currentValue="+currentValue()+
Modified: trunk/freenet/src/freenet/transport/IPUtil.java
===================================================================
--- trunk/freenet/src/freenet/transport/IPUtil.java 2006-08-24 01:28:44 UTC
(rev 10250)
+++ trunk/freenet/src/freenet/transport/IPUtil.java 2006-08-24 04:41:42 UTC
(rev 10251)
@@ -126,7 +126,8 @@
} catch (NumberFormatException e) {
// dns address
if (n < 2) {
- Logger.minor(IPUtil.class, a+": Not a DNS
address, too short!");
+ if(Logger.shouldLog(Logger.MINOR, IPUtil.class))
+ Logger.minor(IPUtil.class, a+": Not a
DNS address, too short!");
return false;
}