Class: Puppet::Util::MasterWorkerLinkManager
- Inherits:
-
Object
- Object
- Puppet::Util::MasterWorkerLinkManager
- Defined in:
- lib/puppet/util/master_worker_link_manager.rb
Overview
GraphDB master worker link manager
Instance Attribute Summary collapse
-
#master_endpoint ⇒ Object
readonly
Returns the value of attribute master_endpoint.
-
#master_repository_id ⇒ Object
readonly
Returns the value of attribute master_repository_id.
-
#replication_port ⇒ Object
readonly
Returns the value of attribute replication_port.
-
#worker_endpoint ⇒ Object
readonly
Returns the value of attribute worker_endpoint.
-
#worker_repository_id ⇒ Object
readonly
Returns the value of attribute worker_repository_id.
Instance Method Summary collapse
- #check_link ⇒ Object
- #create_link ⇒ Object
- #delete_link ⇒ Object
-
#initialize(master_endpoint, master_repository_id, worker_endpoint, worker_repository_id, replication_port) ⇒ MasterWorkerLinkManager
constructor
A new instance of MasterWorkerLinkManager.
Constructor Details
#initialize(master_endpoint, master_repository_id, worker_endpoint, worker_repository_id, replication_port) ⇒ MasterWorkerLinkManager
Returns a new instance of MasterWorkerLinkManager.
17 18 19 20 21 22 23 24 |
# File 'lib/puppet/util/master_worker_link_manager.rb', line 17 def initialize(master_endpoint, master_repository_id, worker_endpoint, worker_repository_id, replication_port) @master_endpoint = master_endpoint @master_repository_id = master_repository_id @worker_endpoint = worker_endpoint @worker_repository_id = worker_repository_id @replication_port = replication_port end |
Instance Attribute Details
#master_endpoint ⇒ Object (readonly)
Returns the value of attribute master_endpoint.
11 12 13 |
# File 'lib/puppet/util/master_worker_link_manager.rb', line 11 def master_endpoint @master_endpoint end |
#master_repository_id ⇒ Object (readonly)
Returns the value of attribute master_repository_id.
12 13 14 |
# File 'lib/puppet/util/master_worker_link_manager.rb', line 12 def master_repository_id @master_repository_id end |
#replication_port ⇒ Object (readonly)
Returns the value of attribute replication_port.
15 16 17 |
# File 'lib/puppet/util/master_worker_link_manager.rb', line 15 def replication_port @replication_port end |
#worker_endpoint ⇒ Object (readonly)
Returns the value of attribute worker_endpoint.
13 14 15 |
# File 'lib/puppet/util/master_worker_link_manager.rb', line 13 def worker_endpoint @worker_endpoint end |
#worker_repository_id ⇒ Object (readonly)
Returns the value of attribute worker_repository_id.
14 15 16 |
# File 'lib/puppet/util/master_worker_link_manager.rb', line 14 def worker_repository_id @worker_repository_id end |
Instance Method Details
#check_link ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/puppet/util/master_worker_link_manager.rb', line 26 def check_link Puppet.debug "Check link between #{master_endpoint}/repositories/#{master_repository_id} and #{worker_endpoint}/repositories/#{worker_repository_id}" uri = master_endpoint.dup uri.path = "/jolokia/read/ReplicationCluster:name=ClusterInfo!/#{master_repository_id}/NodeStatus" expected_massage = Regexp.escape("#{worker_endpoint}/repositories/#{worker_repository_id}".gsub('/', '\/')) Puppet::Util::RequestManager.perform_http_request(uri, { method: :get }, { messages: [expected_massage], codes: [200] }, 0) end |
#create_link ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/puppet/util/master_worker_link_manager.rb', line 40 def create_link Puppet.debug "Creating link between #{master_endpoint}/repositories/#{master_repository_id} and #{worker_endpoint}/repositories/#{worker_repository_id}" uri = master_endpoint.dup uri.path = '/jolokia' body = { 'type' => 'EXEC', 'mbean' => "ReplicationCluster:name=ClusterInfo/#{master_repository_id}", 'operation' => 'addClusterNode', 'arguments' => ["#{worker_endpoint}/repositories/#{worker_repository_id}", replication_port, true] } expected_massage = Regexp.escape("#{worker_endpoint}/repositories/#{worker_repository_id}".gsub('/', '\/')) Puppet::Util::RequestManager.perform_http_request(uri, { method: :post, content_type: 'application/json', body_data: body.to_json }, { messages: [expected_massage], codes: [200] }, 0) end |
#delete_link ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/puppet/util/master_worker_link_manager.rb', line 62 def delete_link Puppet.debug "Deleting link between #{master_endpoint}/repositories/#{master_repository_id} and #{worker_endpoint}/repositories/#{worker_repository_id}" uri = master_endpoint.dup uri.path = '/jolokia' body = { 'type' => 'EXEC', 'mbean' => "ReplicationCluster:name=ClusterInfo/#{master_repository_id}", 'operation' => 'removeClusterNode', 'arguments' => ["#{worker_endpoint}/repositories/#{worker_repository_id}"] } expected_massage = Regexp.escape("#{worker_endpoint}/repositories/#{worker_repository_id}".gsub('/', '\/')) Puppet::Util::RequestManager.perform_http_request(uri, { method: :post, content_type: 'application/json', body_data: body.to_json }, { messages: [expected_massage], codes: [200] }, 0) end |