Author: j16sdiz
Date: 2008-05-02 11:21:43 +0000 (Fri, 02 May 2008)
New Revision: 19678

Modified:
   trunk/freenet/src/freenet/node/FailureTable.java
   trunk/freenet/src/freenet/support/LRUHashtable.java
Log:
more oom handler


Modified: trunk/freenet/src/freenet/node/FailureTable.java
===================================================================
--- trunk/freenet/src/freenet/node/FailureTable.java    2008-05-02 11:03:20 UTC 
(rev 19677)
+++ trunk/freenet/src/freenet/node/FailureTable.java    2008-05-02 11:21:43 UTC 
(rev 19678)
@@ -21,6 +21,8 @@
 import freenet.keys.SSKBlock;
 import freenet.support.LRUHashtable;
 import freenet.support.Logger;
+import freenet.support.OOMHandler;
+import freenet.support.OOMHook;
 import freenet.support.SerialExecutor;
 import freenet.support.io.NativeThread;

@@ -38,7 +40,7 @@
  * in the last hour.
  * @author toad
  */
-public class FailureTable {
+public class FailureTable implements OOMHook {

        /** FailureTableEntry's by key. Note that we push an entry only when 
sentTime changes. */
        private final LRUHashtable entriesByKey;
@@ -78,6 +80,7 @@

        public void start() {
                offerExecutor.start(node.executor, "FailureTable offers 
executor");
+               OOMHandler.addOOMHook(this);
        }

        /**
@@ -625,4 +628,15 @@
                return entry.othersWant(null);
        }

+       public void handleLowMemory() throws Exception {
+               synchronized (this) {
+                       entriesByKey.clear();
+               }
+       }
+
+       public void handleOutOfMemory() throws Exception {
+               synchronized (this) {
+                       entriesByKey.clear();
+               }
+       }
 }

Modified: trunk/freenet/src/freenet/support/LRUHashtable.java
===================================================================
--- trunk/freenet/src/freenet/support/LRUHashtable.java 2008-05-02 11:03:20 UTC 
(rev 19677)
+++ trunk/freenet/src/freenet/support/LRUHashtable.java 2008-05-02 11:21:43 UTC 
(rev 19678)
@@ -162,4 +162,8 @@
                        entries[i++] = values.nextElement();
        }

+       public synchronized void clear() {
+               list.clear();
+               hash.clear();
+       }
 }


Reply via email to