Class: CephRuby::Pool
- Inherits:
-
Object
- Object
- CephRuby::Pool
- Defined in:
- lib/ceph-ruby/pool.rb
Instance Attribute Summary collapse
-
#cluster ⇒ Object
Returns the value of attribute cluster.
-
#handle ⇒ Object
Returns the value of attribute handle.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #close ⇒ Object
- #ensure_open ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(cluster, name) ⇒ Pool
constructor
A new instance of Pool.
- #log(message) ⇒ Object
- #open ⇒ Object
-
#open? ⇒ Boolean
helper methods below.
- #rados_block_device(name, &block) ⇒ Object
- #rados_object(name, &block) ⇒ Object
Constructor Details
#initialize(cluster, name) ⇒ Pool
Returns a new instance of Pool.
5 6 7 8 9 10 11 12 |
# File 'lib/ceph-ruby/pool.rb', line 5 def initialize(cluster, name) self.cluster = cluster self.name = name if block_given? yield(self) close end end |
Instance Attribute Details
#cluster ⇒ Object
Returns the value of attribute cluster.
3 4 5 |
# File 'lib/ceph-ruby/pool.rb', line 3 def cluster @cluster end |
#handle ⇒ Object
Returns the value of attribute handle.
3 4 5 |
# File 'lib/ceph-ruby/pool.rb', line 3 def handle @handle end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/ceph-ruby/pool.rb', line 3 def name @name end |
Instance Method Details
#close ⇒ Object
31 32 33 34 35 36 |
# File 'lib/ceph-ruby/pool.rb', line 31 def close return unless open? log("close") Lib::Rados.rados_ioctx_destroy(handle) self.handle = nil end |
#ensure_open ⇒ Object
54 55 56 57 |
# File 'lib/ceph-ruby/pool.rb', line 54 def ensure_open return if open? open end |
#exists? ⇒ Boolean
14 15 16 17 18 19 20 |
# File 'lib/ceph-ruby/pool.rb', line 14 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 |
#log(message) ⇒ Object
59 60 61 |
# File 'lib/ceph-ruby/pool.rb', line 59 def log() CephRuby.log("pool #{name} #{}") end |
#open ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/ceph-ruby/pool.rb', line 22 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 |
#open? ⇒ Boolean
helper methods below
50 51 52 |
# File 'lib/ceph-ruby/pool.rb', line 50 def open? !!handle end |
#rados_block_device(name, &block) ⇒ Object
43 44 45 46 |
# File 'lib/ceph-ruby/pool.rb', line 43 def rados_block_device(name, &block) ensure_open RadosBlockDevice.new(self, name, &block) end |
#rados_object(name, &block) ⇒ Object
38 39 40 41 |
# File 'lib/ceph-ruby/pool.rb', line 38 def rados_object(name, &block) ensure_open RadosObject.new(self, name, &block) end |