Class: CephStorage::Pool

Inherits:
PoolFactory 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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from PoolWrapper

wrap_me

Methods inherited from PoolFactory

build

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

#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



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(message)
  CephStorage.log("pool #{name} #{message}")
end

#num_freeObject



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_lockedObject



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

#pathObject



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

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

#rados_poolObject



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

#sizeObject



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