This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

adjust dir structure

  • Loading branch information...
davies committed Feb 23, 2012
1 parent 7ed097e commit a9d5cb4a7e8e9f4080723c5fa38c1815424a3900
View
@@ -1,9 +1,9 @@
bin_PROGRAMS = beansdb
-beansdb_SOURCES = beansdb.c item.c fnv1a.h beansdb.h thread.c htree.h htree.c hint.h hint.c record.h record.c codec.h codec.c bitcask.h bitcask.c hstore.h hstore.c quicklz.h quicklz.c diskmgr.h diskmgr.c
+beansdb_SOURCES = src/beansdb.c src/item.c src/fnv1a.h src/beansdb.h src/thread.c src/htree.h src/htree.c src/hint.h src/hint.c src/record.h src/record.c src/codec.h src/codec.c src/bitcask.h src/bitcask.c src/hstore.h src/hstore.c src/quicklz.h src/quicklz.c src/diskmgr.h src/diskmgr.c
beansdb_CPPFLAGS = -DNDEBUG
SUBDIRS = doc
-EXTRA_DIST = python crc32.c clock_gettime_stub.c ae_epoll.c ae_kqueue.c ae_select.c CREDITS AUTHORS LICENSE
+EXTRA_DIST = python src/crc32.c src/clock_gettime_stub.c src/ae_epoll.c src/ae_kqueue.c src/ae_select.c CREDITS AUTHORS LICENSE
dist-hook:
rm -rf $(distdir)/*/.svn/
View
File renamed without changes.
View
@@ -1,157 +0,0 @@
-#!/usr/bin/env python
-
-import time, math
-import logging
-from eventlet import api, util, tpool
-#from tcstore import TCStore, MultiTCStore
-from store import HStore
-
-quit = False
-
-def flush(store):
- while not quit:
- store.flush(30)
- api.sleep(1)
-
-def handler(store, sock, reader, writer):
-
- def writeline(line):
- writer.write(line)
- writer.write('\r\n')
-
- while not quit:
- # pass through every non-eof line
- x = reader.readline()
- if not x: break
-
- args = x.split()
- cmd = args[0]
- #print args
-
- st = time.time()
- if cmd == 'get':
- def do():
- for key in args[1:]:
- v = store.get(key)
- if v is not None:
- writeline("VALUE %s %d %d" % (key, 0, len(v)))
- writeline(v)
- del v
- writeline('END')
- t = time.time() - st
- if t > 0.1:
- print t, args
- writer.flush()
- tpool.execute(do)
-
- elif cmd == 'set':
- def do():
- key, flag, rev, bytes = args[1:5]
- flag, rev, bytes = int(flag), int(rev), int(bytes)
-
- buf = reader.read(bytes)
- while len(buf) < bytes:
- buf += reader.read(bytes - len(buf))
- reader.read(2)
- if store.set(key, buf, rev):
- writeline('STORED')
- else:
- writeline('NOT_STORED')
- del buf
- t = time.time() - st
- if t > 0.1:
- print t, args
- writer.flush()
- tpool.execute(do)
-
- elif cmd == 'delete':
- def do():
- key = args[1]
- v = store.delete(key)
- noreply = len(args) > 3 and int(args[3]) or False
- if not noreply:
- writeline(v and 'DELETED' or 'NOT_FOUND')
- t = time.time() - st
- if t > 0.1:
- print t, args
- writer.flush()
- tpool.execute(do)
-
- elif cmd == 'stat':
- writeline('END')
- writer.flush()
-
- elif cmd == 'quit':
- break
-
- else:
- writeline('CLIENT_ERROR')
-
- api.sleep()
-
- reader.close()
- writer.close()
- sock.close()
-
-
-def main():
- from optparse import OptionParser
- parser = OptionParser()
- parser.add_option("-l", "--listen", dest="host", default="0.0.0.0",
- help="the ip interface to bind")
- parser.add_option("-p", "--port", default=7902, type=int,
- help="which port to listen")
-# parser.add_option("-d", "--daemon", action="store_true",
-# help="run in daemon", default=False)
- parser.add_option("-H", "--home", default="beansdb",
- help="the database path")
- parser.add_option("-c", "--count", default=16, type=int,
- help="number of db file, power of 16")
- parser.add_option("-s", "--start", default=0, type=int,
- help="start index of db file")
- parser.add_option("-e", "--end", default=-1, type=int,
- help="last end of db file, -1 means no limit")
- parser.add_option("-n", "--limit", default=100, type=int,
- help="diffs limit to do db scan")
- parser.add_option("-t", "--threads", type=int, default=20,
- help="number of IO threads")
-
-
- (options, args) = parser.parse_args()
-
- store = (HStore(options.home,
- int(math.log(options.count, 16)),
- options.start, options.end))
- #store.check(options.limit, nonblocking=True)
- api.spawn(tpool.execute, store.check, options.limit) # check in thread pool
- api.spawn(tpool.execute, flush, store)
-
- print "server listening on %s:%s" % (options.host, options.port)
- server = api.tcp_listener((options.host, options.port))
- util.set_reuse_addr(server)
-
- while True:
- try:
- new_sock, address = server.accept()
- except KeyboardInterrupt:
- break
- api.spawn(handler, store, new_sock,
- new_sock.makefile('r'), new_sock.makefile('w'))
-
- global quit
- quit = True
-
- print 'close listener ...'
- server.close()
-
- print 'stop checker thread ...'
- store.stop_check()
-
- print 'stop worker threads ...'
- tpool.killall()
-
- print 'close store...'
- store.close()
-
-if __name__ == '__main__':
- main()
View
@@ -1,16 +0,0 @@
-from setuptools import setup, Extension
-from Cython.Distutils import build_ext
-
-setup(
- name="beansdb",
- cmdclass={'build_ext': build_ext},
- ext_modules=[
- Extension("store", ["store.pyx", "../htree.c", "../hstore.c"],
- libraries=["tokyocabinet"],
- )],
- packages=["beansdb"],
- test_suite="test",
- install_requires=['cython'],
- zip_safe=False,
- version="0.3.0",
-)
View
@@ -1,36 +0,0 @@
-#!/usr/bin/python
-
-import os,os.path
-import time
-import sys
-import math
-
-from dbclient import Beansdb, db
-
-def stat(s):
- st = {}
- for i in range(16):
- for d,h,c in [line.split(' ') for line in (s.get('@%x'%i) or '').split('\n') if line]:
- if not d.endswith('/') or len(d) != 2: continue
- st[i*16+int(d[0],16)] = int(c)
- return st
-
-def status(db):
- st = {}
- for s in db.servers.values():
- st[str(s)] = stat(s)
- print '\t',s,
- print
- scale = 256/db.buckets_count
- for b in range(db.buckets_count):
- print '%x' % b,
- for s in db.servers.values():
- print '\t',
- if s in db.buckets[b]:
- print '\x1b[01;32m%8d\x1b[0m' % sum(st[str(s)].get(b*scale+i,0) for i in range(scale)),
- else:
- print '%8d' % sum(st[str(s)].get(b*scale,0) for i in range(scale)),
- print
-
-if __name__ == '__main__':
- status(db)
Oops, something went wrong.

0 comments on commit a9d5cb4

Please sign in to comment.