Update of /cvsroot/freenet/freenet/src/freenet/transport In directory sc8-pr-cvs1:/tmp/cvs-serv29488/src/freenet/transport
Modified Files:
ThrottledSelectorLoop.java WriteSelectorLoop.java
Log Message:
selective logging, logging improvements
Index: ThrottledSelectorLoop.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/transport/ThrottledSelectorLoop.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- ThrottledSelectorLoop.java 5 Sep 2003 16:08:52 -0000 1.22
+++ ThrottledSelectorLoop.java 10 Sep 2003 20:48:42 -0000 1.23
@@ -78,16 +78,16 @@
}
public final void throttleBeforeSelect() {
- boolean logDEBUG = Core.logger.shouldLog(Logger.DEBUG);
+ logDebug = Core.logger.shouldLog(Logger.DEBUG, this);
if (throttling) {
long now = System.currentTimeMillis();
- if(logDEBUG)
+ if(logDebug)
Core.logger.log(this, "Still throttling at "+now,
Logger.DEBUG);
if(now >= reregisterThrottledTime) {
synchronized(throttleLock) {
if(bytesRemainingOnThrottle > 0) {
- if(logDEBUG)
+ if(logDebug)
Core.logger.log(this, "Calling
throttle with remaining "+
bytesRemainingOnThrottle+" bytes",
Logger.DEBUG);
@@ -96,7 +96,7 @@
if(tok.sleepUntil > 0) {
reregisterThrottledTime =
tok.sleepUntil;
bytesRemainingOnThrottle -=
tok.availableNow;
- if(logDEBUG)
+ if(logDebug)
Core.logger.log(this,
"Still not ready - sleeping for "+
(reregisterThrottledTime - now)+" ms",
Logger.DEBUG);
@@ -116,7 +116,7 @@
} else
timeout = shortTimeout ? 0 : TIMEOUT;
shortTimeout = false;
- if(logDEBUG)
+ if(logDebug)
Core.logger.log(this, "Set timeout to "+timeout,
Logger.DEBUG);
}
@@ -203,9 +203,9 @@
protected final void throttleConnections(int bytesRead, int throttledBytesRead,
int pseudoThrottledBytesRead) {
if(bw == null) return;
- boolean logDEBUG = Core.logger.shouldLog(Logger.DEBUG);
+ logDebug = Core.logger.shouldLog(Logger.DEBUG, this);
if(bytesRead > 0) {
- if(logDEBUG)
+ if(logDebug)
Core.logger.log(this, "Bytes moved total this loop: "+
bytesRead+", bytes
that need throttling: "+
throttledBytesRead+",
pseudo-throttled: "+
@@ -255,7 +255,7 @@
SelectionKey curKey =
(SelectionKey)(it.next());
if(!curKey.isValid()) {
- if(logDEBUG) Core.logger.log(this,
"Invalid "+curKey+"("+curKey.channel()+","+curKey.attachment()+" on selector in
throttleConnections, ignoring", Logger.DEBUG);
+ if(logDebug) Core.logger.log(this,
"Invalid "+curKey+"("+curKey.channel()+","+curKey.attachment()+" on selector in
throttleConnections, ignoring", Logger.DEBUG);
onInvalidKey(curKey);
continue;
}
@@ -282,11 +282,11 @@
throttleQueueLength =
throttleDisabledQueue.size();
deregistered++;
}
- if(logDEBUG) Core.logger.log(this,
"Deregistered "+
+ if(logDebug) Core.logger.log(this,
"Deregistered "+
curKey.attachment(), Logger.DEBUG);
}
}
- if(logDEBUG)
+ if(logDebug)
Core.logger.log(this, "Deregistered
"+deregistered+
" keys,
TDQ.size="+
throttleDisabledQueue.size(),
Index: WriteSelectorLoop.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/transport/WriteSelectorLoop.java,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- WriteSelectorLoop.java 5 Sep 2003 17:10:34 -0000 1.57
+++ WriteSelectorLoop.java 10 Sep 2003 20:48:42 -0000 1.58
@@ -325,8 +325,7 @@
//this queue is local to the thread.
LinkedList waitingJobs = new LinkedList();
- boolean logDEBUG = logDebug;
- if(logDEBUG)
+ if(logDebug)
Core.logger.log(this, "beforeSelect()", Logger.DEBUG);
// first check if any channel is registered in the
// selector.
@@ -348,13 +347,13 @@
if (sel.keys().isEmpty() && jobs.isEmpty()) {
//check if the jobs queue is empty,
//and if it is, block on it.
- if(logDEBUG)
+ if(logDebug)
Core.logger.log(this, "Waiting for
job to add to "+
"queue", Logger.DEBUG);
long delay = 0;
synchronized(throttleLock) {
if(throttling) {
- if(logDEBUG)
+ if(logDebug)
Core.logger.log(this,
"Throttling at "+now+
" until "+
reregisterThrottledTime,
@@ -369,7 +368,7 @@
}
int x = (delay > Integer.MAX_VALUE) ?
Integer.MAX_VALUE
: ((int)delay);
- if(logDEBUG)
+ if(logDebug)
Core.logger.log(this, "Delay will be
"+x+" ms: ",
Logger.DEBUG);
Object o = jobs.dequeue(x);
@@ -381,7 +380,7 @@
ChannelAttachmentPair
pair =
new
ChannelAttachmentPair(current.destination, current);
throttleDisabledQueue.addLast(pair);
- if(logDEBUG)
+ if(logDebug)
Core.logger.log(this, "Moving new job "+
pair+" onto delay queue",
Logger.DEBUG);
@@ -389,7 +388,7 @@
}
}
waitingJobs.add(o);
- if(logDEBUG)
+ if(logDebug)
Core.logger.log(this,
"Dequeued job",
Logger.DEBUG);
continue;
@@ -408,20 +407,20 @@
ChannelAttachmentPair
pair =
new
ChannelAttachmentPair(current.destination, current);
throttleDisabledQueue.addLast(pair);
- if(logDEBUG)
+ if(logDebug)
Core.logger.log(this, "Moving new job "+
pair+" onto delay queue",
Logger.DEBUG);
continue;
}
}
- if(logDEBUG)
+ if(logDebug)
Core.logger.log(this,
"Copying job "+current+
" to queue", Logger.DEBUG);
waitingJobs.add(current);
}
long endTime = System.currentTimeMillis();
- if(logDEBUG)
+ if(logDebug)
Core.logger.log(this, "Took
"+(endTime-startTime)+
"
millis copying queue ("+iter+")",
Logger.DEBUG);
@@ -439,15 +438,15 @@
while (i.hasNext()) {
SendJob currentJob = (SendJob) i.next();
try {
- if(logDEBUG)
+ if(logDebug)
Core.logger.log(this, "Registering channel
"+currentJob+
" with
selector", Logger.DEBUG);
currentJob.destination.register(sel,
SelectionKey.OP_WRITE, currentJob);
- if(logDEBUG)
+ if(logDebug)
Core.logger.log(this, "Registered channel
"+currentJob+
" with
selector", Logger.DEBUG);
}catch (ClosedChannelException e) {
- if(logDEBUG)
+ if(logDebug)
Core.logger.log(this, "Channel closed:
"+currentJob+": "+e,
e,
Logger.DEBUG);
queueClose(((SocketChannel)currentJob.destination),
@@ -489,8 +488,7 @@
//at this stage the selected set should contain only channels
//that are ready to be written to and have something to be sent.
protected final boolean processConnections() {
- boolean logDEBUG = logDebug;
- if(logDEBUG)
+ if(logDebug)
Core.logger.log(this, "processConnections()", Logger.DEBUG);
boolean success = true;
int throttledBytes = 0;
@@ -541,7 +539,7 @@
if(bw != null && currentJob.client.shouldThrottle()) {
if(noMoreThrottled) {
// Will get cancelled by
throttleConnections
- if(logDEBUG)
+ if(logDebug)
Core.logger.log(this,
"Skipping (A) throttled "+
currentJob, Logger.DEBUG);
shortTimeout = true; // just in case
the bytes are absorbed by the throttle
@@ -572,13 +570,13 @@
if(currentJob.data.remaining() > lim) {
currentJob.data.limit(currentJob.data.position() +
lim);
- if(logDEBUG)
+ if(logDebug)
Core.logger.log(this,
"Limited: "+currentJob.data+
" for "+currentJob.client+
", limit was "+oldLimit, Logger.DEBUG);
}
} else {
- if(logDEBUG)
+ if(logDebug)
Core.logger.log(this, "Did not limit,
"+
currentJob.data.remaining()+"/"+
(bw==null?"(null)": Integer.
@@ -608,7 +606,7 @@
if(currentJob.client.shouldThrottle()) {
throttledBytes += (sent+OVERHEAD);
totalWrittenThrottlableBytes +=
(sent+OVERHEAD);
- if(logDEBUG) {
+ if(logDebug) {
Core.logger.log(this, "Should
throttle "+
currentJob, Logger.DEBUG);
Core.logger.log(this, "Written
"+sent+
@@ -633,11 +631,11 @@
if(currentJob.client.countAsThrottled()) {
pseudoThrottledBytes +=
(sent+OVERHEAD);
totalWrittenPseudoThrottlableBytes += (sent+OVERHEAD);
- if(logDEBUG)
+ if(logDebug)
Core.logger.log(this,
"Pseudo-throttle "+
currentJob, Logger.DEBUG);
} else {
- if(logDEBUG)
+ if(logDebug)
Core.logger.log(this,
"Should not throttle "+
currentJob, Logger.DEBUG);
}
@@ -701,10 +699,10 @@
noMoreThrottled = true;
}
}
- if(logDEBUG)
+ if(logDebug)
Core.logger.log(this, "Written "+bytesSent, Logger.DEBUG);
if(throttledBytes != 0 || pseudoThrottledBytes != 0) {
- if(logDEBUG)
+ if(logDebug)
Core.logger.log(this, "Written "+throttledBytes+
" bytes that should be
throttled",
Logger.DEBUG);
_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs
