class MerrittZK::Locks
Helper class for setting and releasing Merritt ZooKeeper locks
Constants
- LOCKS
- LOCKS_COLLECTION
- LOCKS_INVENTORY
- LOCKS_QUEUE
- LOCKS_QUEUE_ACCESS_LARGE
- LOCKS_QUEUE_ACCESS_SMALL
- LOCKS_QUEUE_INGEST
- LOCKS_STORAGE
Public Class Methods
check_lock_collection(zk, mnemonic)
click to toggle source
# File lib/merritt_zk_locks.rb, line 92 def self.check_lock_collection(zk, mnemonic) zk.exists?("#{LOCKS_COLLECTION}/#{mnemonic}") end
check_lock_ingest_queue(zk)
click to toggle source
# File lib/merritt_zk_locks.rb, line 50 def self.check_lock_ingest_queue(zk) zk.exists?(LOCKS_QUEUE_INGEST) end
check_lock_large_access_queue(zk)
click to toggle source
# File lib/merritt_zk_locks.rb, line 64 def self.check_lock_large_access_queue(zk) zk.exists?(LOCKS_QUEUE_ACCESS_LARGE) end
check_lock_object_inventory(zk, ark)
click to toggle source
# File lib/merritt_zk_locks.rb, line 120 def self.check_lock_object_inventory(zk, ark) zk.exists?("#{LOCKS_INVENTORY}/#{ark.gsub('/', '_')}") end
check_lock_object_storage(zk, ark)
click to toggle source
# File lib/merritt_zk_locks.rb, line 106 def self.check_lock_object_storage(zk, ark) zk.exists?("#{LOCKS_STORAGE}/#{ark.gsub('/', '_')}") end
check_lock_small_access_queue(zk)
click to toggle source
# File lib/merritt_zk_locks.rb, line 78 def self.check_lock_small_access_queue(zk) zk.exists?(LOCKS_QUEUE_ACCESS_SMALL) end
create_ephemeral_lock(zk, path)
click to toggle source
# File lib/merritt_zk_locks.rb, line 39 def self.create_ephemeral_lock(zk, path) zk.create(path, data: nil, mode: :ephemeral) true rescue StandardError false end
create_if_needed(zk, path)
click to toggle source
# File lib/merritt_zk_locks.rb, line 20 def self.create_if_needed(zk, path) zk.create(path, data: nil) unless zk.exists?(path) end
create_lock(zk, path)
click to toggle source
# File lib/merritt_zk_locks.rb, line 32 def self.create_lock(zk, path) zk.create(path, data: nil) true rescue StandardError false end
init_locks(zk)
click to toggle source
# File lib/merritt_zk_locks.rb, line 24 def self.init_locks(zk) create_if_needed(zk, LOCKS) create_if_needed(zk, LOCKS_QUEUE) create_if_needed(zk, LOCKS_STORAGE) create_if_needed(zk, LOCKS_INVENTORY) create_if_needed(zk, LOCKS_COLLECTION) end
lock_collection(zk, mnemonic)
click to toggle source
# File lib/merritt_zk_locks.rb, line 88 def self.lock_collection(zk, mnemonic) create_lock(zk, "#{LOCKS_COLLECTION}/#{mnemonic}") end
lock_ingest_queue(zk)
click to toggle source
# File lib/merritt_zk_locks.rb, line 46 def self.lock_ingest_queue(zk) create_lock(zk, LOCKS_QUEUE_INGEST) end
lock_large_access_queue(zk)
click to toggle source
# File lib/merritt_zk_locks.rb, line 60 def self.lock_large_access_queue(zk) create_lock(zk, LOCKS_QUEUE_ACCESS_LARGE) end
lock_object_inventory(zk, ark)
click to toggle source
# File lib/merritt_zk_locks.rb, line 116 def self.lock_object_inventory(zk, ark) create_ephemeral_lock(zk, "#{LOCKS_INVENTORY}/#{ark.gsub('/', '_')}") end
lock_object_storage(zk, ark)
click to toggle source
# File lib/merritt_zk_locks.rb, line 102 def self.lock_object_storage(zk, ark) create_ephemeral_lock(zk, "#{LOCKS_STORAGE}/#{ark.gsub('/', '_')}") end
lock_small_access_queue(zk)
click to toggle source
# File lib/merritt_zk_locks.rb, line 74 def self.lock_small_access_queue(zk) create_lock(zk, LOCKS_QUEUE_ACCESS_SMALL) end
unlock_collection(zk, mnemonic)
click to toggle source
# File lib/merritt_zk_locks.rb, line 96 def self.unlock_collection(zk, mnemonic) zk.delete("#{LOCKS_COLLECTION}/#{mnemonic}") rescue StandardError # no action end
unlock_ingest_queue(zk)
click to toggle source
# File lib/merritt_zk_locks.rb, line 54 def self.unlock_ingest_queue(zk) zk.delete(LOCKS_QUEUE_INGEST) rescue StandardError # no action end
unlock_large_access_queue(zk)
click to toggle source
# File lib/merritt_zk_locks.rb, line 68 def self.unlock_large_access_queue(zk) zk.delete(LOCKS_QUEUE_ACCESS_LARGE) rescue StandardError # no action end
unlock_object_inventory(zk, ark)
click to toggle source
# File lib/merritt_zk_locks.rb, line 124 def self.unlock_object_inventory(zk, ark) zk.delete("#{LOCKS_INVENTORY}/#{ark.gsub('/', '_')}") rescue StandardError # no action end
unlock_object_storage(zk, ark)
click to toggle source
# File lib/merritt_zk_locks.rb, line 110 def self.unlock_object_storage(zk, ark) zk.delete("#{LOCKS_STORAGE}/#{ark.gsub('/', '_')}") rescue StandardError # no action end
unlock_small_access_queue(zk)
click to toggle source
# File lib/merritt_zk_locks.rb, line 82 def self.unlock_small_access_queue(zk) zk.delete(LOCKS_QUEUE_ACCESS_SMALL) rescue StandardError # no action end