Class: CephStorage::Pool

Inherits:
CephRuby::Pool
  • Object
show all
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

Direct Known Subclasses

PoolFactory

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PoolWrapper

wrap_me

Constructor Details

#initialize(cluster, name) ⇒ Pool

Returns a new instance of Pool.



16
17
18
19
20
21
22
23
# File 'lib/ceph_storage/pool.rb', line 16

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

#cartridgesObject

Returns the value of attribute cartridges.



7
8
9
# File 'lib/ceph_storage/pool.rb', line 7

def cartridges
  @cartridges
end

#close_lockObject

Returns the value of attribute close_lock.



7
8
9
# File 'lib/ceph_storage/pool.rb', line 7

def close_lock
  @close_lock
end

#clusterObject

Returns the value of attribute cluster.



7
8
9
# File 'lib/ceph_storage/pool.rb', line 7

def cluster
  @cluster
end

#nameObject

Returns the value of attribute name.



7
8
9
# File 'lib/ceph_storage/pool.rb', line 7

def name
  @name
end

#pop_lockObject

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

#closeObject



70
71
72
73
74
75
# File 'lib/ceph_storage/pool.rb', line 70

def close
  close_lock.synchronize do
    close_group(false)
    close_group(true)
  end
end

#log(message) ⇒ Object



48
49
50
# File 'lib/ceph_storage/pool.rb', line 48

def log(message)
  CephStorage.log("pool #{name} #{message}")
end

#num_freeObject



64
65
66
67
68
# File 'lib/ceph_storage/pool.rb', line 64

def num_free
  pop_lock.synchronize do
    cartridges.count { |c| c[:lock].locked? == false }
  end
end

#num_lockedObject



58
59
60
61
62
# File 'lib/ceph_storage/pool.rb', line 58

def num_locked
  pop_lock.synchronize do
    cartridges.count { |c| c[:lock].locked? == true }
  end
end

#pathObject



77
78
79
# File 'lib/ceph_storage/pool.rb', line 77

def path
  "ceph://#{cluster.cluster}/#{name}"
end

#rados_poolObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/ceph_storage/pool.rb', line 25

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



36
37
38
# File 'lib/ceph_storage/pool.rb', line 36

def rados_pool=(pool)
  push(pool)
end

#sizeObject



52
53
54
55
56
# File 'lib/ceph_storage/pool.rb', line 52

def size
  pop_lock.synchronize do
    cartridges.size
  end
end

#storage_object(name, &block) ⇒ Object



40
41
42
# File 'lib/ceph_storage/pool.rb', line 40

def storage_object(name, &block)
  CephStorage::StorageObject::RadosStorageObject.new(self, name, &block)
end

#storage_object_enumerator(&block) ⇒ Object



44
45
46
# File 'lib/ceph_storage/pool.rb', line 44

def storage_object_enumerator(&block)
  CephStorage::StorageObject::RadosStorageObjectEnumerator.new(self, &block)
end