uses SBDB-provided gc for databases
This commit is contained in:
parent
496c7437a7
commit
2f2b4fd558
17
bin/s2l.rb
17
bin/s2l.rb
|
@ -65,9 +65,6 @@ class Rotate
|
||||||
end
|
end
|
||||||
|
|
||||||
def db k
|
def db k
|
||||||
h = hashing k
|
|
||||||
db = @dbs[h]
|
|
||||||
unless db
|
|
||||||
n = @rdb[ h]
|
n = @rdb[ h]
|
||||||
if n
|
if n
|
||||||
n = UUIDTools::UUID.parse_raw n
|
n = UUIDTools::UUID.parse_raw n
|
||||||
|
@ -76,10 +73,8 @@ class Rotate
|
||||||
@rdb[ h] = n.raw
|
@rdb[ h] = n.raw
|
||||||
end
|
end
|
||||||
info :open => n.to_s
|
info :open => n.to_s
|
||||||
db = @env.open SBDB::Btree, n.to_s, 'logs', Bdb::DB_CREATE | Bdb::DB_AUTO_COMMIT, nil
|
@env[ n.to_s, 'logs', SBDB::Btree, SBDB::CREATE | SBDB::AUTO_COMMIT]
|
||||||
@dbs[h] = db
|
@env[ "#{n}.newids", 'logs', SBDB::Queue, SBDB::CREATE | SBDB::AUTO_COMMIT]
|
||||||
end
|
|
||||||
db
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def sync
|
def sync
|
||||||
|
@ -132,11 +127,9 @@ info :create => {:home => $conf[:home]}
|
||||||
Dir.mkdir $conf[:home] rescue Errno::EEXIST
|
Dir.mkdir $conf[:home] rescue Errno::EEXIST
|
||||||
|
|
||||||
info :open => SBDB::Env
|
info :open => SBDB::Env
|
||||||
SBDB::Env.new( $conf[:home], SBDB::CREATE | SBDB::INIT_TXN | SBDB::INIT_LOCK | SBDB::INIT_LOG | SBDB::INIT_MPOOL | Bdb::DB_AUTO_COMMIT) do |dbenv|
|
SBDB::Env.new( $conf[:home], SBDB::CREATE | SBDB::Env::INIT_TRANSACTION | Bdb::DB_AUTO_COMMIT) do |dbenv|
|
||||||
info :open => SBDB::Btree
|
|
||||||
dbenv.open( SBDB::Btree, 'rotates.db', 'rotates', SBDB::CREATE | Bdb::DB_AUTO_COMMIT, nil) do |rdb|
|
|
||||||
info :open => Rotate
|
info :open => Rotate
|
||||||
dbs = Rotate.new rdb
|
dbs = Rotate.new dbenv[ 'rotates.db', 'rotates', SBDB::Btree, SBDB::CREATE | Bdb::DB_AUTO_COMMIT]
|
||||||
info :open => S2L
|
info :open => S2L
|
||||||
serv = S2L.new :sock => TCPServer.new( *$conf[:server]), :dbs => dbs
|
serv = S2L.new :sock => TCPServer.new( *$conf[:server]), :dbs => dbs
|
||||||
retries = Retries.new *$conf[:retries]
|
retries = Retries.new *$conf[:retries]
|
||||||
|
@ -154,8 +147,6 @@ SBDB::Env.new( $conf[:home], SBDB::CREATE | SBDB::INIT_TXN | SBDB::INIT_LOCK | S
|
||||||
fatal "Too many retries (#{retries.count})"
|
fatal "Too many retries (#{retries.count})"
|
||||||
info :shutdown => :fatal
|
info :shutdown => :fatal
|
||||||
end
|
end
|
||||||
info :close => rdb
|
|
||||||
end
|
|
||||||
info :close => dbenv
|
info :close => dbenv
|
||||||
end
|
end
|
||||||
info :halted
|
info :halted
|
||||||
|
|
Loading…
Reference in a new issue