Skip to content

Commit

Permalink
fixes #3
Browse files Browse the repository at this point in the history
  • Loading branch information
prashanthellina committed Oct 28, 2016
1 parent 7bedc5a commit 5eaec35
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class SimpleDBServer(RocksDBServer):
return SimpleDBAPI(self.args.data_dir)

if __name__ == '__main__':
SimpleDBServer()
SimpleDBServer().start()
```

The above code represents a database with just one table called 'names'. Run this server by doing
Expand Down
3 changes: 2 additions & 1 deletion examples/simple_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class SimpleDBServer(RocksDBServer):
DESC = 'Simple DB Server based on RockDB Server'

def prepare_api(self):
super(SimpleDBAPI, self).prepare_api()
return SimpleDBAPI(self.args.data_dir)

if __name__ == '__main__':
SimpleDBServer()
SimpleDBServer().start()
19 changes: 9 additions & 10 deletions rocksdbserver/rocksdbserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,8 @@ def __init__(self, *args, **kwargs):
if not os.path.exists(self.data_dir):
os.makedirs(self.data_dir)

self.set_file_limits()

def set_file_limits(self):
try:
# ulimit -n unlimited
Expand All @@ -545,10 +547,10 @@ def set_file_limits(self):
except ValueError:
self.log.warning('unable to increase num files limit. run as root?')

def expire_iters(self):
def expire_iters(self, api):
while 1:
ts = time.time()
for table in self.api.tables.itervalues():
for table in api.tables.itervalues():
expired = []

for iter_name, _iter in table.iters.iteritems():
Expand All @@ -560,14 +562,11 @@ def expire_iters(self):

time.sleep(ITERATOR_EXPIRY_CHECK)

def pre_run(self):
super(RocksDBServer, self).pre_run()
self.set_file_limits()

self.thread_expire_iters = gevent.spawn(self.expire_iters)

def prepare_api(self):
return RocksDBAPI(self.args.data_dir)
super(RocksDBServer, self).prepare_api()
api = RocksDBAPI(self.args.data_dir)
self.thread_expire_iters = gevent.spawn(self.expire_iters, api)
return api

def define_args(self, parser):
parser.add_argument('data_dir', type=str, metavar='data-dir',
Expand Down Expand Up @@ -607,4 +606,4 @@ def iteritems(self, table, reverse=False):
return self._iter(table, reverse, 'iter_items')

if __name__ == '__main__':
RocksDBServer()
RocksDBServer().start()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="rocksdbserver",
version='0.1.2',
version='0.1.3',
description="RocksDB Server",
keywords='rocksdbserver rocksdb',
author='Prashanth Ellina',
Expand Down

0 comments on commit 5eaec35

Please sign in to comment.