Status: smarter...

This commit is contained in:
Denis Knauf 2010-04-01 23:32:24 +02:00
parent f562f25d82
commit bc097f8532
2 changed files with 11 additions and 5 deletions

View file

@ -81,7 +81,9 @@ module LogAn::Inc
begin
stores = @conf[:stores] = {}
db = @etc[ 'sids.store', 'seeks', SBDB::Recno, SBDB::CREATE | SBDB::AUTO_COMMIT]
db = LogAn::AutoValueConvertHash.new( db, lambda {|val| val.pack( 'NN') }) {|val| (val||0.chr*8).unpack( 'NN') }
db = LogAn::AutoValueConvertHash.new( db, lambda {|val| val.pack( 'NN') }) {|val|
(val||0.chr*8).unpack( 'NN')
}
stores[:seeks] = LogAn::Cache.new db
LogAn::Inc::FileParser::Base.store = LogAn::Inc::SID0.store = stores
end
@ -90,13 +92,15 @@ module LogAn::Inc
@select = LogAn::Inc::Select.new
status = lambda do
@select.at Time.now+5, &status
LogAn::Logging.info :recv_lines => @logs.counter, :connections => @serv && @serv.clients.map{|cl|cl.sock.peeraddr}
LogAn::Logging.info :recv_lines => @logs.counter,
:connections => @serv && @serv.clients.map {|cl| cl.sid }
@conf[:stores].each{|key, db| db.flush!}
end
status.call
# Prepare Inc-server - create server
@serv = LogAn::Inc::Server.new :sock => TCPServer.new( *@conf[:server]), :config => @conf[:configs], :select => @select
@serv = LogAn::Inc::Server.new :sock => TCPServer.new( *@conf[:server]),
:config => @conf[:configs], :select => @select
LogAn::Logging.debug @serv
# Shutdown on signals

View file

@ -27,7 +27,8 @@ module LogAn
else env
end
@rdb = @env[ 'rotates.db', :type => SBDB::Btree, :flags => SBDB::CREATE | SBDB::AUTO_COMMIT]
@queue = @env[ "newids.queue", :type => SBDB::Queue, :flags => SBDB::CREATE | SBDB::AUTO_COMMIT, :re_len => 16]
@queue = @env[ "newids.queue", :type => SBDB::Queue,
:flags => SBDB::CREATE | SBDB::AUTO_COMMIT, :re_len => 16]
@dbs, @counter = {}, 0
self.hash_func = lambda {|k|
[k.timestamp.to_i/60/60].pack 'N' # Hour-based rotation
@ -64,7 +65,8 @@ module LogAn
end
def db name
@dbs[name] ||= @env[ name.to_s, :type => SBDB::Btree, :flags => SBDB::CREATE | SBDB::AUTO_COMMIT]
@dbs[name] ||= @env[ name.to_s, :type => SBDB::Btree,
:flags => SBDB::CREATE | SBDB::AUTO_COMMIT]
end
def sync