Author: nextgens
Date: 2009-01-30 13:32:20 +0000 (Fri, 30 Jan 2009)
New Revision: 25394
Modified:
trunk/freenet/src/freenet/client/async/OfferedKeysList.java
trunk/freenet/src/freenet/client/async/RequestCooldownQueue.java
Log:
more
Modified: trunk/freenet/src/freenet/client/async/OfferedKeysList.java
===================================================================
--- trunk/freenet/src/freenet/client/async/OfferedKeysList.java 2009-01-30
13:28:50 UTC (rev 25393)
+++ trunk/freenet/src/freenet/client/async/OfferedKeysList.java 2009-01-30
13:32:20 UTC (rev 25394)
@@ -14,6 +14,7 @@
import freenet.node.RequestScheduler;
import freenet.node.NodeClientCore.SimpleRequestSenderCompletionListener;
import freenet.support.Logger;
+import freenet.support.LogThresholdCallback;
/**
* All the keys at a given priority which we have received key offers from
other nodes for.
@@ -33,7 +34,17 @@
private final HashSet<Key> keys;
private final Vector<Key> keysList; // O(1) remove random element the
way we use it, see chooseKey().
- private static boolean logMINOR;
+ private static volatile boolean logMINOR;
+ private static volatile boolean logDEBUG;
+
+ static {
+ Logger.registerLogThresholdCallback(new LogThresholdCallback(){
+ public void shouldUpdate(){
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ logDEBUG = Logger.shouldLog(Logger.DEBUG, this);
+ }
+ });
+ }
private final RandomSource random;
private final short priorityClass;
private final NodeClientCore core;
@@ -44,13 +55,11 @@
this.random = random;
this.priorityClass = priorityClass;
this.core = core;
- logMINOR = Logger.shouldLog(Logger.MINOR, this);
}
/** Called when a key is found, when it no longer belongs to this list
etc. */
public synchronized void remove(Key key) {
assert(keysList.size() == keys.size());
- logMINOR = Logger.shouldLog(Logger.MINOR, this);
if(keys.remove(key)) {
keysList.remove(key);
if(logMINOR) Logger.minor(this, "Found "+key+" ,
removing it "+" for "+this+" size now "+keysList.size());
Modified: trunk/freenet/src/freenet/client/async/RequestCooldownQueue.java
===================================================================
--- trunk/freenet/src/freenet/client/async/RequestCooldownQueue.java
2009-01-30 13:28:50 UTC (rev 25393)
+++ trunk/freenet/src/freenet/client/async/RequestCooldownQueue.java
2009-01-30 13:32:20 UTC (rev 25394)
@@ -7,6 +7,7 @@
import freenet.node.SendableGet;
import freenet.support.Fields;
import freenet.support.Logger;
+import freenet.support.LogThresholdCallback;
/**
* Queue of keys which have been recently requested, which we have
unregistered for a fixed period.
@@ -30,14 +31,23 @@
int startPtr;
/** location next key will be put in (may be < startPtr if wrapped
around) */
int endPtr;
- static boolean logMINOR;
+ private static volatile boolean logMINOR;
+ private static volatile boolean logDEBUG;
+
+ static {
+ Logger.registerLogThresholdCallback(new LogThresholdCallback(){
+ public void shouldUpdate(){
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ logDEBUG = Logger.shouldLog(Logger.DEBUG, this);
+ }
+ });
+ }
static final int MIN_SIZE = 128;
final long cooldownTime;
RequestCooldownQueue(long cooldownTime) {
- logMINOR = Logger.shouldLog(Logger.MINOR, this);
keys = new Key[MIN_SIZE];
times = new long[MIN_SIZE];
clients = new SendableGet[MIN_SIZE];
@@ -68,7 +78,6 @@
private synchronized void add(Key key, SendableGet client, long
removeTime) {
if(holes < 0) Logger.error(this, "holes = "+holes+" !!");
- logMINOR = Logger.shouldLog(Logger.MINOR, this);
if(logMINOR)
Logger.minor(this, "Adding key "+key+" client
"+client+" remove time "+removeTime+" startPtr="+startPtr+" endPtr="+endPtr+"
keys.length="+keys.length);
int ptr = endPtr;
@@ -115,9 +124,8 @@
* @return Either a Key or null if no keys have passed their cooldown
time.
*/
synchronized Key removeKeyBefore(long now) {
- logMINOR = Logger.shouldLog(Logger.MINOR, this);
boolean foundIT = false;
- if(Logger.shouldLog(Logger.DEBUG, this)) {
+ if(logDEBUG) {
foundIT = bigLog();
}
if(logMINOR)
@@ -224,7 +232,6 @@
*/
synchronized boolean removeKey(Key key, SendableGet client, long time) {
if(time <= 0) return false; // We won't find it.
- logMINOR = Logger.shouldLog(Logger.MINOR, this);
if(holes < 0) Logger.error(this, "holes = "+holes+" !!");
if(logMINOR) Logger.minor(this, "Remove key "+key+" client
"+client+" at time "+time+" startPtr="+startPtr+" endPtr="+endPtr+"
holes="+holes+" keys.length="+keys.length);
int idx = -1;
_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs