class Ccp::Kvs::Tokyo::Base
Public Instance Methods
info()
click to toggle source
info
# File lib/ccp/kvs/tokyo/base.rb, line 11 def info if path.exist? Tokyo::Info.parse(`tcamgr inform #{path}`) else raise Ccp::Kvs::NotConnected, "%s(%s)" % [ self.class, @source] end end
path()
click to toggle source
kvs
# File lib/ccp/kvs/tokyo/base.rb, line 22 def path file = @source.to_s.sub(/#.*$/, '') # parse "foo.tch#mode=r" Pathname(file) end
Private Instance Methods
atomic(&block)
click to toggle source
Check ecode and then raise. too boring… The library should implement this as atomic operation!
# File lib/ccp/kvs/tokyo/base.rb, line 29 def atomic(&block) raise NotImplementedError, "tc keep ecode until new erros occured" if tokyo_error? raise "tc already error before atomic: #{@db.ecode}" end v = block.call tokyo_error! if tokyo_error? return v end
error_message()
click to toggle source
# File lib/ccp/kvs/tokyo/base.rb, line 52 def error_message if @db # TODO: Where is adb_errmsg? "%s (%s)" % [@db.errmsg(@db.ecode).to_s, @db.ecode] else '[Not Initialized]' end rescue Exception => e "[BUG] #{e}" end
threading_error?()
click to toggle source
# File lib/ccp/kvs/tokyo/base.rb, line 48 def threading_error? @db.ecode == HDB::ETHREAD end
tokyo_error!(label = nil)
click to toggle source
# File lib/ccp/kvs/tokyo/base.rb, line 40 def tokyo_error!(label = nil) raise Ccp::Kvs::Tokyo::Error, "%s%s (%s)" % [label, error_message, @source] end
tokyo_error?()
click to toggle source
# File lib/ccp/kvs/tokyo/base.rb, line 44 def tokyo_error? @db.ecode != HDB::ESUCCESS end