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 13 14 15 |
# File 'lib/ceph-ruby/pool.rb', line 5 def initialize(cluster, name) self.cluster = cluster self.name = name if block_given? begin yield(self) ensure close end 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
34 35 36 37 38 39 |
# File 'lib/ceph-ruby/pool.rb', line 34 def close return unless open? log("close") Lib::Rados.rados_ioctx_destroy(handle) self.handle = nil end |
#ensure_open ⇒ Object
57 58 59 60 |
# File 'lib/ceph-ruby/pool.rb', line 57 def ensure_open return if open? open end |
#exists? ⇒ Boolean
17 18 19 20 21 22 23 |
# File 'lib/ceph-ruby/pool.rb', line 17 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
62 63 64 |
# File 'lib/ceph-ruby/pool.rb', line 62 def log() CephRuby.log("pool #{name} #{}") end |
#open ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/ceph-ruby/pool.rb', line 25 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
53 54 55 |
# File 'lib/ceph-ruby/pool.rb', line 53 def open? !!handle end |
#rados_block_device(name, &block) ⇒ Object
46 47 48 49 |
# File 'lib/ceph-ruby/pool.rb', line 46 def rados_block_device(name, &block) ensure_open RadosBlockDevice.new(self, name, &block) end |
#rados_object(name, &block) ⇒ Object
41 42 43 44 |
# File 'lib/ceph-ruby/pool.rb', line 41 def rados_object(name, &block) ensure_open RadosObject.new(self, name, &block) end |