Class: Emissary::Agent::Mysql
- Inherits:
-
Emissary::Agent
- Object
- Emissary::Agent
- Emissary::Agent::Mysql
- Defined in:
- lib/emissary/agent/mysql.rb
Defined Under Namespace
Classes: Helper
Constant Summary collapse
- DEFAULT_COORDINATES_FILE =
'/var/nyt/mysql/master.coordinates'.freeze
Instance Attribute Summary collapse
-
#coordinates_file ⇒ Object
Returns the value of attribute coordinates_file.
Attributes inherited from Emissary::Agent
#args, #config, #message, #method, #name, #operator
Instance Method Summary collapse
- #lock(host, user, password, timeout = Agent::Mysql::Helper::DEFAULT_TIMEOUT, coordinates_file = nil) ⇒ Object
- #status(host, user, password) ⇒ Object
- #unlock(host, user, password) ⇒ Object
- #valid_methods ⇒ Object
Methods inherited from Emissary::Agent
#activate, #initialize, #post_init, #send
Constructor Details
This class inherits a constructor from Emissary::Agent
Instance Attribute Details
#coordinates_file ⇒ Object
Returns the value of attribute coordinates_file.
28 29 30 |
# File 'lib/emissary/agent/mysql.rb', line 28 def coordinates_file @coordinates_file end |
Instance Method Details
#lock(host, user, password, timeout = Agent::Mysql::Helper::DEFAULT_TIMEOUT, coordinates_file = nil) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/emissary/agent/mysql.rb', line 30 def lock(host, user, password, timeout = Agent::Mysql::Helper::DEFAULT_TIMEOUT, coordinates_file = nil) @coordinates_file ||= coordinates_file @coordinates_file ||= config[:agents][:mysql][:coordinates_file] rescue nil @coordinates_file ||= DEFAULT_COORDINATES_FILE locker = ::Emissary::Agent::Mysql::Helper.new(host, user, password, timeout) locker.lock! filename, position = locker.get_binlog_info unless filename.nil? write_lock_info(filename, position) response = .response response.args = [ filename, position ] response.status_note = 'Locked' else response = .response response.status_note = "No binlog information - can't lock." end response end |
#status(host, user, password) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/emissary/agent/mysql.rb', line 64 def status(host, user, password) locker = ::Emissary::Agent::Mysql::Helper.new(host, user, password) response = .response response.status_note = locker.locked? ? 'Locked' : 'Unlocked' response end |
#unlock(host, user, password) ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/emissary/agent/mysql.rb', line 53 def unlock(host, user, password) locker = ::Emissary::Agent::Mysql::Helper.new(host, user, password) raise "The database was not locked! (Possibly timed out.)" unless locker.locked? locker.unlock! response = .response response.status_note = 'Unlocked' response end |
#valid_methods ⇒ Object
24 25 26 |
# File 'lib/emissary/agent/mysql.rb', line 24 def valid_methods [ :lock, :unlock, :status ] end |