Update of /cvsroot/freenet/freenet/src/freenet/node/rt
In directory sc8-pr-cvs1:/tmp/cvs-serv14667/src/freenet/node/rt
Modified Files:
ResponseTimeEstimator.java
Log Message:
Indenting
Made ASL.CloseThread strictly wait for notification before starting to close.
Made ResponseTimeEstimator.dumpLog() execute only if we are logging Logger.MINOR level.
Index: ResponseTimeEstimator.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/ResponseTimeEstimator.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -w -r1.10 -r1.11
--- ResponseTimeEstimator.java 22 Oct 2003 14:14:14 -0000 1.10
+++ ResponseTimeEstimator.java 25 Oct 2003 10:44:45 -0000 1.11
@@ -311,18 +311,9 @@
static final BigInteger THREE = BigInteger.valueOf(3);
static final BigInteger FOUR = BigInteger.valueOf(4);
- protected synchronized int reportDecreasing(BigInteger lowerBound,
- BigInteger upperBound,
- BigInteger center,
- int usec,
- int initialSteps,
- int lowerBoundPos,
- int upperBoundPos) {
+ protected synchronized int reportDecreasing(BigInteger lowerBound, BigInteger
upperBound, BigInteger center, int usec, int initialSteps, int lowerBoundPos, int
upperBoundPos) {
if(logDEBUG)
- Core.logger.log(this, "reportDecreasing("+lowerBound.toString(16)+","+
- upperBound.toString(16)+","+center.toString(16)+","+
- initialSteps+","+lowerBoundPos+","+upperBoundPos+")",
- new Exception("debug"), Logger.DEBUG);
+ Core.logger.log(this, "reportDecreasing(" +
lowerBound.toString(16) + "," + upperBound.toString(16) + "," + center.toString(16) +
"," + initialSteps + "," + lowerBoundPos + "," + upperBoundPos + ")", new
Exception("debug"), Logger.DEBUG);
dumpLog();
if(upperBoundPos >= key.length-1)
upperBoundPos = key.length - 1;
@@ -332,33 +323,35 @@
lowerBoundPos = 0;
if(upperBoundPos < 0)
upperBoundPos = 0;
- if(usec < 0) throw new IllegalArgumentException("usec "+usec+" negative!");
+ if (usec < 0)
+ throw new IllegalArgumentException("usec " + usec + "
negative!");
// Loop from lowerBoundPos to upperBoundPos, inclusive
// We are increasing
// inc shiftAmount each time we move a point
int shiftAmount = initialSteps;
while(key[upperBoundPos].compareTo(upperBound) == 1) {
upperBoundPos--;
- if(upperBoundPos < 0) return initialSteps;
+ if (upperBoundPos < 0)
+ return initialSteps;
}
while(key[lowerBoundPos].compareTo(lowerBound) == -1) {
lowerBoundPos++;
- if(lowerBoundPos >= key.length) return initialSteps;
+ if (lowerBoundPos >= key.length)
+ return initialSteps;
}
- if(lowerBoundPos > upperBoundPos) return initialSteps;
+ if (lowerBoundPos > upperBoundPos)
+ return initialSteps;
for(int i=lowerBoundPos;i<=upperBoundPos;i++) {
if(time[i] < 0)
- Core.logger.log(this, "time["+i+"] = "+time[i]+
- " - NEGATIVE TIME!", Logger.ERROR);
+ Core.logger.log(this, "time[" + i + "] = " + time[i] +
" - NEGATIVE TIME!", Logger.ERROR);
if(logDEBUG)
- Core.logger.log(this, "Trying key["+i+"]: "+
- key[i].toString(16)+","+time[i],
- Logger.DEBUG);
+ Core.logger.log(this, "Trying key[" + i + "]: " +
key[i].toString(16) + "," + time[i], Logger.DEBUG);
if(sensitivity[i] > SENSITIVITY_MAX)
sensitivity[i] = SENSITIVITY_MAX;
double sens = sensitivity[i];
BigInteger diff = key[i].subtract(center);
- if(diff.signum() == -1) diff = diff.add(keyspace);
+ if (diff.signum() == -1)
+ diff = diff.add(keyspace);
// Result = old position + ((old position * sensitivity) / (sensitivity +
1)
// >> shiftAmount
@@ -367,15 +360,13 @@
/*
* R = O + ((S-O)/(r+1))*m
*
- * Where R is the result, O is the old value, r is the sensitivity,
- * m is the shift multiplier
+ * Where R is the result, O is the old value, r is the
sensitivity, m is the shift multiplier
*/
// Multiply by 75% to prevent points from collapsing on each other
BigDecimal fracDiff = new BigDecimal(diff);
BigDecimal fracSens = new BigDecimal(sens);
BigDecimal fracOrig = new BigDecimal(center);
- BigDecimal resultDiff = fracDiff.divide(fracSens.add(DEC_ONE),
- BigDecimal.ROUND_DOWN);
+ BigDecimal resultDiff = fracDiff.divide(fracSens.add(DEC_ONE),
BigDecimal.ROUND_DOWN);
diff = resultDiff.toBigInteger().shiftRight(shiftAmount);
diff = diff.multiply(THREE).divide(FOUR);
key[i] = key[i].subtract(diff);
@@ -385,32 +376,24 @@
key[i] = key[i].subtract(keyspace);
int timediff = usec - time[i];
if(logDEBUG)
- Core.logger.log(this, "usec="+usec+", time["+i+"]="+time[i]+
- ", timediff="+timediff,
- Logger.DEBUG);
+ Core.logger.log(this, "usec=" + usec + ", time[" + i +
"]=" + time[i] + ", timediff=" + timediff, Logger.DEBUG);
double fracTimediff = (double)timediff;
if(logDEBUG)
- Core.logger.log(this, "fracTimediff="+fracTimediff,
- Logger.DEBUG);
+ Core.logger.log(this, "fracTimediff=" + fracTimediff,
Logger.DEBUG);
double resultTimediff = fracTimediff/(sens+1.0);
if(logDEBUG)
- Core.logger.log(this, "resultTimediff="+resultTimediff,
- Logger.DEBUG);
+ Core.logger.log(this, "resultTimediff=" +
resultTimediff, Logger.DEBUG);
timediff = ((int)resultTimediff) >> shiftAmount;
if(logDEBUG)
- Core.logger.log(this, "timediff now = "+timediff,
- Logger.DEBUG);
+ Core.logger.log(this, "timediff now = " + timediff,
Logger.DEBUG);
timediff = (int)((((long)timediff)*3)/4);
if(logDEBUG)
- Core.logger.log(this,"time["+i+"] = "+time[i]+", timediff = "+
- timediff, Logger.DEBUG);
+ Core.logger.log(this, "time[" + i + "] = " + time[i] +
", timediff = " + timediff, Logger.DEBUG);
time[i] += timediff;
if(logDEBUG)
- Core.logger.log(this, "key["+i+"] now: "+key[i].toString(16)+
- ","+time[i], Logger.DEBUG);
+ Core.logger.log(this, "key[" + i + "] now: " +
key[i].toString(16) + "," + time[i], Logger.DEBUG);
if(time[i] < 0)
- Core.logger.log(this, "time["+i+"] = "+time[i]+
- " - NEGATIVE TIME!", Logger.ERROR);
+ Core.logger.log(this, "time[" + i + "] = " + time[i] +
" - NEGATIVE TIME!", Logger.ERROR);
sensitivity[i] += 1.0/(1<<shiftAmount);
shiftAmount++;
}
@@ -598,6 +581,7 @@
}
public void dumpLog() {
+ if (Core.logger.shouldLog(Logger.MINOR, this)) {
StringBuffer sb = new StringBuffer();
for(int x=0;x<key.length;x++) {
sb.append(key[x].toString(16));
@@ -605,12 +589,18 @@
int t = time[x];
sb.append(Integer.toString(t));
if(t < 0)
- Core.logger.log(this, "time["+x+"]="+t+" - NEGATIVE ("+this+")",
- Logger.ERROR);
+ Core.logger.log(this, "time[" + x + "]=" + t +
" - NEGATIVE (" + this +")", Logger.ERROR);
sb.append("\n");
}
- Core.logger.log(this, "Dump of "+this+": \n"+sb.toString(),
- Logger.MINOR);
+ Core.logger.log(this, "Dump of " + this +": \n" +
sb.toString(), Logger.MINOR);
+ }else{
+ //Do only the sanity check if we wont log the contents of the
estimator
+ for (int x = 0; x < key.length; x++) {
+ int t = time[x];
+ if (t < 0)
+ Core.logger.log(this, "time[" + x + "]=" + t +
" - NEGATIVE (" + this +")", Logger.ERROR);
+ }
+ }
}
public double guessTime(Key k) {
_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs