]> git.mxchange.org Git - quix0rs-apt-p2p.git/commitdiff
Move the key expiring to the checkpoint function.
authorCameron Dale <camrdale@gmail.com>
Fri, 22 Feb 2008 19:33:50 +0000 (11:33 -0800)
committerCameron Dale <camrdale@gmail.com>
Fri, 22 Feb 2008 19:33:50 +0000 (11:33 -0800)
apt-dht.conf
apt_dht/apt_dht_conf.py
apt_dht_Khashmir/DHT.py
apt_dht_Khashmir/actions.py
apt_dht_Khashmir/khashmir.py
debian/apt-dht.conf.sgml
test.py

index 7f42e4d31822fe30147cbb5a1c7499b52495a2cd..709a0d3f81d59baf5ef20d7b41af36154161a816 100644 (file)
@@ -82,14 +82,8 @@ MIN_PING_INTERVAL = 15m
 # refresh buckets that haven't been touched in this long
 BUCKET_STALENESS = 1h
 
-# time before expirer starts running
-KEINITIAL_DELAY = 15s
-
-# time between expirer runs
-KE_DELAY = 20m
-
-# expire entries older than this
-KE_AGE = 1h
+# expire unrefreshed entries older than this
+KEY_EXPIRE = 1h
 
 # whether to spew info about the requests/responses in the protocol
 SPEW = no
index 16f10c1c3914731a0ec2a6fece3e1c98e331d823..931d46cdd5a1a7fb48308c2dbac0ea22dc00e9c0 100644 (file)
@@ -86,15 +86,8 @@ DHT_DEFAULTS = {
     # refresh buckets that haven't been touched in this long
     'BUCKET_STALENESS': '1h', # one hour
     
-    ###  KEY EXPIRER
-    # time before expirer starts running
-    'KEINITIAL_DELAY': '15s', # 15 seconds - to clean out old stuff in persistent db
-    
-    # time between expirer runs
-    'KE_DELAY': '20m', # 20 minutes
-    
     # expire entries older than this
-    'KE_AGE': '1h', # 60 minutes
+    'KEY_EXPIRE': '1h', # 60 minutes
     
     # whether to spew info about the requests/responses in the protocol
     'SPEW': 'yes',
index e62f30441b1bd555fa95e1bdeee2846c56c08958..ab206d2abf3ba04a5e531325646249f08307a5af 100644 (file)
@@ -49,7 +49,7 @@ class DHT:
                      'MAX_FAILURES', 'PORT']:
                 self.config[k] = self.config_parser.getint(section, k)
             elif k in ['CHECKPOINT_INTERVAL', 'MIN_PING_INTERVAL', 
-                       'BUCKET_STALENESS', 'KEINITIAL_DELAY', 'KE_DELAY', 'KE_AGE']:
+                       'BUCKET_STALENESS', 'KEY_EXPIRE']:
                 self.config[k] = self.config_parser.gettime(section, k)
             elif k in ['SPEW']:
                 self.config[k] = self.config_parser.getboolean(section, k)
@@ -186,8 +186,7 @@ class TestSimpleDHT(unittest.TestCase):
                     'CHECKPOINT_INTERVAL': 300, 'CONCURRENT_REQS': 4,
                     'STORE_REDUNDANCY': 3, 'MAX_FAILURES': 3,
                     'MIN_PING_INTERVAL': 900,'BUCKET_STALENESS': 3600,
-                    'KEINITIAL_DELAY': 15, 'KE_DELAY': 1200,
-                    'KE_AGE': 3600, 'SPEW': False, }
+                    'KEY_EXPIRE': 3600, 'SPEW': False, }
 
     def setUp(self):
         self.a = DHT()
@@ -279,8 +278,7 @@ class TestMultiDHT(unittest.TestCase):
                     'CHECKPOINT_INTERVAL': 300, 'CONCURRENT_REQS': 4,
                     'STORE_REDUNDANCY': 3, 'MAX_FAILURES': 3,
                     'MIN_PING_INTERVAL': 900,'BUCKET_STALENESS': 3600,
-                    'KEINITIAL_DELAY': 15, 'KE_DELAY': 1200,
-                    'KE_AGE': 3600, 'SPEW': False, }
+                    'KEY_EXPIRE': 3600, 'SPEW': False, }
 
     def setUp(self):
         self.l = []
index 7822579733b55a9ec1e0234767dcf1d422daf74b..05349d4147efe1df81e5c1ccfe35c95c599008a4 100644 (file)
@@ -236,20 +236,3 @@ class StoreValue(ActionBase):
         self.nodes = nodes
         self.nodes.sort(self.sort)
         self.schedule()
-
-
-class KeyExpirer:
-    def __init__(self, store, config):
-        self.store = store
-        self.config = config
-        self.next_expire = reactor.callLater(self.config['KEINITIAL_DELAY'], self.doExpire)
-    
-    def doExpire(self):
-        self.store.expireValues(self.config['KE_AGE'])
-        self.next_expire = reactor.callLater(self.config['KE_DELAY'], self.doExpire)
-        
-    def shutdown(self):
-        try:
-            self.next_expire.cancel()
-        except:
-            pass
index d3479e661e4f610723ff9a1cc825b19078b9e153..a9a78674a048c8e3d6e0f0e3392bcb285bd7bfce 100644 (file)
@@ -17,7 +17,7 @@ from db import DB
 from ktable import KTable
 from knode import KNodeBase, KNodeRead, KNodeWrite, NULL_ID
 from khash import newID, newIDInRange
-from actions import FindNode, GetValue, KeyExpirer, StoreValue
+from actions import FindNode, GetValue, StoreValue
 import krpc
 
 # this is the base class, has base functionality and find node, no key-value mappings
@@ -39,7 +39,6 @@ class KhashmirBase(protocol.Factory):
         self.udp.protocol = krpc.KRPC
         self.listenport = reactor.listenUDP(self.port, self.udp)
         self._loadRoutingTable()
-        self.expirer = KeyExpirer(self.store, config)
         self.refreshTable(force=1)
         self.next_checkpoint = reactor.callLater(60, self.checkpoint, (1,))
 
@@ -65,6 +64,7 @@ class KhashmirBase(protocol.Factory):
             self.token_secrets.pop()
         self.store.saveSelfNode(self.node.id)
         self.store.dumpRoutingTable(self.table.buckets)
+        self.store.expireValues(self.config['KEY_EXPIRE'])
         self.refreshTable()
         if auto:
             self.next_checkpoint = reactor.callLater(randrange(int(self.config['CHECKPOINT_INTERVAL'] * .9), 
@@ -196,7 +196,6 @@ class KhashmirBase(protocol.Factory):
             self.next_checkpoint.cancel()
         except:
             pass
-        self.expirer.shutdown()
         self.store.close()
 
     #### Remote Interface - called by remote nodes
@@ -301,8 +300,7 @@ class SimpleTests(unittest.TestCase):
                     'CHECKPOINT_INTERVAL': 300, 'CONCURRENT_REQS': 4,
                     'STORE_REDUNDANCY': 3, 'MAX_FAILURES': 3,
                     'MIN_PING_INTERVAL': 900,'BUCKET_STALENESS': 3600,
-                    'KEINITIAL_DELAY': 15, 'KE_DELAY': 1200,
-                    'KE_AGE': 3600, 'SPEW': False, }
+                    'KEY_EXPIRE': 3600, 'SPEW': False, }
 
     def setUp(self):
         krpc.KRPC.noisy = 0
@@ -375,8 +373,7 @@ class MultiTest(unittest.TestCase):
                     'CHECKPOINT_INTERVAL': 300, 'CONCURRENT_REQS': 4,
                     'STORE_REDUNDANCY': 3, 'MAX_FAILURES': 3,
                     'MIN_PING_INTERVAL': 900,'BUCKET_STALENESS': 3600,
-                    'KEINITIAL_DELAY': 15, 'KE_DELAY': 1200,
-                    'KE_AGE': 3600, 'SPEW': False, }
+                    'KEY_EXPIRE': 3600, 'SPEW': False, }
 
     def _done(self, val):
         self.done = 1
index 6b7762ddd4c8f27a565f50bc3576425dd7c41f3c..b481193f9475a0cfc3e7d241e4891ea458acff0a 100644 (file)
            </listitem>
          </varlistentry>
          <varlistentry>
-           <term><option>KEINITIAL_DELAY = <replaceable>time</replaceable></option></term>
-            <listitem>
-             <para>The <replaceable>time</replaceable> to wait after startup before starting the key expirer.
-                 (Default is 15 seconds.)</para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><option>KE_DELAY = <replaceable>time</replaceable></option></term>
-            <listitem>
-             <para>The <replaceable>time</replaceable> to wait between runs of the key expirer.
-                 (Default is 20 minutes.)</para>
-           </listitem>
-         </varlistentry>
-         <varlistentry>
-           <term><option>KE_AGE = <replaceable>time</replaceable></option></term>
+           <term><option>KEY_EXPIRE = <replaceable>time</replaceable></option></term>
             <listitem>
              <para>The <replaceable>time</replaceable> to wait before expiring unrefreshed keys.
                  (Default is 1 hour.)</para>
diff --git a/test.py b/test.py
index cfac85b572851815e030689792ed4611fbaabd10..66f0fc6598d63657eddfadd674a1c7d92fda258d 100755 (executable)
--- a/test.py
+++ b/test.py
@@ -376,14 +376,8 @@ MIN_PING_INTERVAL = 15m
 # refresh buckets that haven't been touched in this long
 BUCKET_STALENESS = 1h
 
-# time before expirer starts running
-KEINITIAL_DELAY = 15s
-
-# time between expirer runs
-KE_DELAY = 20m
-
 # expire entries older than this
-KE_AGE = 1h
+KEY_EXPIRE = 1h
 
 # whether to spew info about the requests/responses in the protocol
 SPEW = yes