summaryrefslogtreecommitdiffstats
path: root/combox
diff options
context:
space:
mode:
authorSiddharth Ravikumar <sravik@bgsu.edu>2015-03-31 20:28:42 -0400
committerSiddharth Ravikumar <sravik@bgsu.edu>2015-03-31 20:28:42 -0400
commit370e6ecf0fc5a493878fe4e0171254b632d72471 (patch)
tree137a5005ee5159cd7f54484153826d7fa094ca5c /combox
parentd26dfc87e40dfb34481edbed75e0200931e9a815 (diff)
new methods in combox.silo.ComboxSilo -- node_get, node_set. noddicts.
These methods will be used to manage the dictionaries in the db related to the zarking shards. modified: combox/silo.py modified: tests/silo_test.py
Diffstat (limited to 'combox')
-rw-r--r--combox/silo.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/combox/silo.py b/combox/silo.py
index 4f5b746..55345c9 100644
--- a/combox/silo.py
+++ b/combox/silo.py
@@ -124,3 +124,42 @@ class ComboxSilo(object):
return False
else:
return True
+
+
+ def nodedicts(self):
+ """
+ Returns a list containing the dicts related the the node directories.
+ """
+ return self.node_dicts
+
+
+ def node_set(self, type_, file_):
+ """
+ Update information about the shard of `file_'.
+
+ type_: 'shard_created', 'shard_modified', 'shard_moved', 'shard_deleted'
+ file_: path of the file_ in combox directory.
+ """
+
+ with self.lock:
+ try:
+ num = self.db.dget(type_, file_)
+ num += 1
+ except KeyError, e:
+ # means file_ is not already there, so:
+ num = 1
+ self.db.dadd(type_, (file_, num))
+
+
+ def node_get(self, type_, file_):
+ """
+ Returns a number denoting the number of node directories in which the file_'s shard was created/modified/moved/deleted.
+
+ type_: 'shard_created', 'shard_modified', 'shard_moved', 'shard_deleted'
+ file_: path of the file_ in combox directory.
+ """
+ try:
+ return self.db.dget(type_, file_)
+ except KeyError, e:
+ # file_ info not there under type_ dict.
+ return None