Class: CephStorage::Pool
- Inherits:
-
PoolFactory
- Object
- CephRuby::Pool
- PoolFactory
- CephStorage::Pool
- Extended by:
- PoolWrapper
- Includes:
- Multiton
- Defined in:
- lib/ceph_storage/pool.rb
Overview
A reference to a Ceph pool This is a collection of held open pool IOctx’s for a given pool
Instance Attribute Summary collapse
-
#cartridges ⇒ Object
Returns the value of attribute cartridges.
-
#close_lock ⇒ Object
Returns the value of attribute close_lock.
-
#cluster ⇒ Object
Returns the value of attribute cluster.
-
#name ⇒ Object
Returns the value of attribute name.
-
#pop_lock ⇒ Object
Returns the value of attribute pop_lock.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(cluster, name) ⇒ Pool
constructor
A new instance of Pool.
- #log(message) ⇒ Object
- #num_free ⇒ Object
- #num_locked ⇒ Object
- #path ⇒ Object
- #rados_pool ⇒ Object
- #rados_pool=(pool) ⇒ Object
- #size ⇒ Object
- #storage_object(name, &block) ⇒ Object
- #storage_object_enumerator(&block) ⇒ Object
Methods included from PoolWrapper
Methods inherited from PoolFactory
Constructor Details
#initialize(cluster, name) ⇒ Pool
Returns a new instance of Pool.
12 13 14 15 16 17 18 19 |
# File 'lib/ceph_storage/pool.rb', line 12 def initialize(cluster, name) log("init #{name}") self.close_lock = Mutex.new self.pop_lock = Mutex.new self.cluster = cluster self.name = name.to_s self.cartridges = [] end |
Instance Attribute Details
#cartridges ⇒ Object
Returns the value of attribute cartridges.
7 8 9 |
# File 'lib/ceph_storage/pool.rb', line 7 def cartridges @cartridges end |
#close_lock ⇒ Object
Returns the value of attribute close_lock.
7 8 9 |
# File 'lib/ceph_storage/pool.rb', line 7 def close_lock @close_lock end |
#cluster ⇒ Object
Returns the value of attribute cluster.
7 8 9 |
# File 'lib/ceph_storage/pool.rb', line 7 def cluster @cluster end |
#name ⇒ Object
Returns the value of attribute name.
7 8 9 |
# File 'lib/ceph_storage/pool.rb', line 7 def name @name end |
#pop_lock ⇒ Object
Returns the value of attribute pop_lock.
7 8 9 |
# File 'lib/ceph_storage/pool.rb', line 7 def pop_lock @pop_lock end |
Instance Method Details
#close ⇒ Object
66 67 68 69 70 71 |
# File 'lib/ceph_storage/pool.rb', line 66 def close close_lock.synchronize do close_group(false) close_group(true) end end |
#log(message) ⇒ Object
44 45 46 |
# File 'lib/ceph_storage/pool.rb', line 44 def log() CephStorage.log("pool #{name} #{}") end |
#num_free ⇒ Object
60 61 62 63 64 |
# File 'lib/ceph_storage/pool.rb', line 60 def num_free pop_lock.synchronize do cartridges.count { |c| c[:lock].locked? == false } end end |
#num_locked ⇒ Object
54 55 56 57 58 |
# File 'lib/ceph_storage/pool.rb', line 54 def num_locked pop_lock.synchronize do cartridges.count { |c| c[:lock].locked? == true } end end |
#path ⇒ Object
73 74 75 |
# File 'lib/ceph_storage/pool.rb', line 73 def path "ceph://#{cluster.cluster}/#{name}" end |
#rados_pool ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ceph_storage/pool.rb', line 21 def rados_pool close_lock.synchronize {} h = pop return h unless block_given? begin yield(h) ensure push(h) end end |
#rados_pool=(pool) ⇒ Object
32 33 34 |
# File 'lib/ceph_storage/pool.rb', line 32 def rados_pool=(pool) push(pool) end |
#size ⇒ Object
48 49 50 51 52 |
# File 'lib/ceph_storage/pool.rb', line 48 def size pop_lock.synchronize do cartridges.size end end |
#storage_object(name, &block) ⇒ Object
36 37 38 |
# File 'lib/ceph_storage/pool.rb', line 36 def storage_object(name, &block) CephStorage::StorageObject::RadosStorageObject.new(self, name, &block) end |
#storage_object_enumerator(&block) ⇒ Object
40 41 42 |
# File 'lib/ceph_storage/pool.rb', line 40 def storage_object_enumerator(&block) CephStorage::StorageObject::RadosStorageObjectEnumerator.new(self, &block) end |