Author: toad
Date: 2009-03-26 15:23:25 +0000 (Thu, 26 Mar 2009)
New Revision: 26205
Added:
branches/db4o/freenet/src/freenet/support/DebuggingHashMap.java
Modified:
branches/db4o/freenet/src/freenet/node/fcp/ClientPutDir.java
Log:
Factor out DebuggingHashMap
Modified: branches/db4o/freenet/src/freenet/node/fcp/ClientPutDir.java
===================================================================
--- branches/db4o/freenet/src/freenet/node/fcp/ClientPutDir.java
2009-03-26 15:22:31 UTC (rev 26204)
+++ branches/db4o/freenet/src/freenet/node/fcp/ClientPutDir.java
2009-03-26 15:23:25 UTC (rev 26205)
@@ -43,37 +43,6 @@
private final int numberOfFiles;
private final boolean wasDiskPut;
- @SuppressWarnings("serial")
- static class MyHashMap extends HashMap<String, Object> {
- public boolean objectCanUpdate(ObjectContainer container) {
- if(logMINOR)
- Logger.minor(this, "objectCanUpdate() on
HashMap for ClientPutDir "+this+" stored="+container.ext().isStored(this)+"
active="+container.ext().isActive(this)+" size="+size(), new
Exception("debug"));
- return true;
- }
-
- public boolean objectCanNew(ObjectContainer container) {
- if(logMINOR)
- Logger.minor(this, "objectCanNew() on HashMap
for ClientPutDir "+this+" stored="+container.ext().isStored(this)+"
active="+container.ext().isActive(this)+" size="+size(), new
Exception("debug"));
- return true;
- }
-
- public void objectOnUpdate(ObjectContainer container) {
- if(logMINOR)
- Logger.minor(this, "objectOnUpdate() on HashMap
for ClientPutDir "+this+" stored="+container.ext().isStored(this)+"
active="+container.ext().isActive(this)+" size="+size(), new
Exception("debug"));
- }
-
- public void objectOnNew(ObjectContainer container) {
- if(logMINOR)
- Logger.minor(this, "objectOnNew() on HashMap
for ClientPutDir "+this+" stored="+container.ext().isStored(this)+"
active="+container.ext().isActive(this)+" size="+size(), new
Exception("debug"));
- }
-
- public void objectOnActivate(ObjectContainer container) {
- if(logMINOR)
- Logger.minor(this, "objectOnActivate() on
HashMap for ClientPutDir stored="+container.ext().isStored(this)+"
active="+container.ext().isActive(this)+" size="+size(), new
Exception("debug"));
- }
-
- }
-
private static volatile boolean logMINOR;
static {
Added: branches/db4o/freenet/src/freenet/support/DebuggingHashMap.java
===================================================================
--- branches/db4o/freenet/src/freenet/support/DebuggingHashMap.java
(rev 0)
+++ branches/db4o/freenet/src/freenet/support/DebuggingHashMap.java
2009-03-26 15:23:25 UTC (rev 26205)
@@ -0,0 +1,63 @@
+package freenet.support;
+
+import java.util.HashMap;
+
+import com.db4o.ObjectContainer;
+
+
+...@suppresswarnings("serial")
+public class DebuggingHashMap<K extends Object, V extends Object> extends
HashMap<K, V> {
+
+ private static volatile boolean logMINOR;
+
+ static {
+ Logger.registerLogThresholdCallback(new LogThresholdCallback() {
+
+ @Override
+ public void shouldUpdate() {
+ logMINOR = Logger.shouldLog(Logger.MINOR, this);
+ }
+ });
+ }
+
+ public boolean objectCanUpdate(ObjectContainer container) {
+ if(logMINOR)
+ Logger.minor(this, "objectCanUpdate() on
DebuggingHashMap "+this+" stored="+container.ext().isStored(this)+"
active="+container.ext().isActive(this)+" size="+size(), new
Exception("debug"));
+ return true;
+ }
+
+ public boolean objectCanNew(ObjectContainer container) {
+ if(logMINOR)
+ Logger.minor(this, "objectCanNew() on DebuggingHashMap
"+this+" stored="+container.ext().isStored(this)+"
active="+container.ext().isActive(this)+" size="+size(), new
Exception("debug"));
+ return true;
+ }
+
+ public void objectOnUpdate(ObjectContainer container) {
+ if(logMINOR)
+ Logger.minor(this, "objectOnUpdate() on
DebuggingHashMap "+this+" stored="+container.ext().isStored(this)+"
active="+container.ext().isActive(this)+" size="+size(), new
Exception("debug"));
+ }
+
+ public void objectOnNew(ObjectContainer container) {
+ if(logMINOR)
+ Logger.minor(this, "objectOnNew() on DebuggingHashMap
"+this+" stored="+container.ext().isStored(this)+"
active="+container.ext().isActive(this)+" size="+size(), new
Exception("debug"));
+ }
+
+ private transient boolean activating = false;
+
+ public boolean objectCanActivate(ObjectContainer container) {
+ if(logMINOR)
+ Logger.minor(this, "objectCanActivate() on
DebuggingHashMap stored="+container.ext().isStored(this)+"
active="+container.ext().isActive(this)+" size="+size(), new
Exception("debug"));
+
+ /** FIXME: This was an attempt to ensure we always activate to
depth 2. It didn't work. :( */
+
+// if(activating) {
+// activating = false;
+// return true;
+// }
+// activating = true;
+// container.activate(this, 2);
+// return false;
+ return true;
+ }
+
+}
\ No newline at end of file
_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs