Sha256: b074081b59e09dc8de56ae54591b4646ad2bddb20624f7e77a85df5d91c4f353
Contents?: true
Size: 1.37 KB
Versions: 2
Compression:
Stored size: 1.37 KB
Contents
module CephRuby class Pool attr_accessor :cluster, :name, :handle def initialize(cluster, name) self.cluster = cluster self.name = name if block_given? yield(self) close end end def exists? log("exists?") ret = Lib::Rados.rados_pool_lookup(cluster.handle, name) return true if ret >= 0 return false if ret == -Errno::ENOENT::Errno raise SystemCallError.new("lookup of '#{name}' failed", -ret) if ret < 0 end def open return if open? log("open") handle_p = FFI::MemoryPointer.new(:pointer) ret = Lib::Rados.rados_ioctx_create(cluster.handle, name, handle_p) raise SystemCallError.new("creation of io context for '#{name}' failed", -ret) if ret < 0 self.handle = handle_p.get_pointer(0) end def close return unless open? log("close") Lib::Rados.rados_ioctx_destroy(handle) self.handle = nil end def rados_object(name, &block) ensure_open RadosObject.new(self, name, &block) end def rados_block_device(name, &block) ensure_open RadosBlockDevice.new(self, name, &block) end # helper methods below def open? !!handle end def ensure_open return if open? open end def log(message) CephRuby.log("pool #{name} #{message}") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ceph-ruby-1.1 | lib/ceph-ruby/pool.rb |
ceph-ruby-1.0 | lib/ceph-ruby/pool.rb |