# 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
# 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',
'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)
'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()
'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 = []
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
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
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,))
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),
self.next_checkpoint.cancel()
except:
pass
- self.expirer.shutdown()
self.store.close()
#### Remote Interface - called by remote nodes
'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
'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
</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>
# 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