Class: Receiver::AmbariReceiver
- Inherits:
-
BasicReceiver
- Object
- BasicReceiver
- Receiver::AmbariReceiver
- Defined in:
- lib/receiver/ambari_receiver.rb
Overview
Catch the HTTPError and throw a new one with just the error message.
Reformat the returned arrays to remove the http notion.
Refactor names and private methods below
Class listing all the available methods to interact with Ambari.
Constant Summary collapse
- @@hadoop_services_description =
{ "HDFS" => { "MASTER" => %w{NAMENODE SECONDARY_NAMENODE}, "SLAVE" => %w{DATANODE}}, "MAPREDUCE" => { "MASTER" => %w{JOBTRACKER}, "SLAVE" => %w{TASKTRACKER}}, "HIVE" => { "MASTER" => %w{HIVE_SERVER}, "SLAVE" => []}, "HBASE" => { "MASTER" => %w{HBASE_MASTER}, "SLAVE" => %w{HBASE_REGIONSERVER}}, "ZOOKEEPER" => { "MASTER" => %w{ZOOKEEPER_SERVER}, "SLAVE" => []}, "OOZIE" => { "MASTER" => %w{OOZIE_SERVER}, "SLAVE" => []}, "NAGIOS" => { "MASTER" => %w{NAGIOS_SERVER}, "SLAVE" => []}, "GANGLIA" => { "MASTER" => %w{GANGLIA_SERVER}, "SLAVE" => []} }
- @@available_actions =
{'START' => {'required_state' => %w{INSTALLED STARTED START_FAILED}, 'target_state' => 'STARTED'}, 'STOP' => {'required_state' => %w{STARTED INSTALLED STOP_FAILED}, 'target_state' => 'INSTALLED'}, 'INSTALL' => {'required_state' => %w{INIT MAINTENANCE INSTALLED INSTALL_FAILED}, 'target_state' => 'INSTALLED'}, 'DETACH' => {'required_state' => %w{INSTALLED MAINTENANCE}, 'target_state' => 'MAINTENANCE'}, 'DELETE' => {'required_state' => %w{MAINTENANCE}, 'target_state' => nil}}
Class Method Summary collapse
-
.get_components_by_service_name(service_name) ⇒ Array<String>
Get the component list of service_name.
-
.get_service_by_component_name(component_name) ⇒ String
Get the component list of service_name.
-
.valid_component?(component_name) ⇒ Boolean
Check if component_name is a Hadoop service.
-
.valid_service?(service_name) ⇒ Boolean
Check if service_name is a Hadoop service.
-
.valid_service_component?(service_name, component_name) ⇒ Boolean
Check if a component is part of a service.
Instance Method Summary collapse
-
#add_host(cluster_name, host_name) ⇒ Object
Adds an host.
-
#add_host_component(cluster_name, host_name, component_name) ⇒ Object
Adds a component to an host.
-
#add_service_component(cluster_name, service_name, component_name) ⇒ Object
Adds a component to a service.
-
#apply_configuration(cluster_name, configuration_type, configuration_tag) ⇒ Object
Apply a configuration into a cluster.
-
#create_apply_configuration(cluster_name, configuration_type, configuration_tag, configuration_properties) ⇒ Object
Create and apply a configuration into a cluster.
-
#create_configuration(cluster_name, configuration_type, configuration_tag, configuration_properties) ⇒ Object
Create a configuration into a cluster.
-
#define_cluster(cluster_name, cluster_version) ⇒ Object
Defines a new cluster.
-
#define_service(cluster_name, service_name) ⇒ Object
Defines a new service.
-
#delete_cluster(cluster_name) ⇒ Object
Deletes a new cluster.
-
#delete_host(cluster_name, host_name) ⇒ Object
Deletes an host.
-
#delete_host_component(cluster_name, host_name, component_name) ⇒ Object
Deletes a component from an host.
-
#delete_service(cluster_name, service_name) ⇒ Object
Deletes a service.
-
#detach_host_component(cluster_name, host_name, component_name) ⇒ Int
Detachs a component of an host.
-
#execute_method_on_components(method, cluster_name, service_name = nil, host_name = nil, component_type = nil) ⇒ Array
private
Execute a method passed in parameter for every host component of a cluster.
-
#get_cluster_configuration(cluster_name, type, tag) ⇒ Object
Returns the list of configuration of a cluster.
-
#get_cluster_configurations_list(cluster_name) ⇒ Object
Returns the list of configuration of a cluster.
-
#get_host_list(cluster_name) ⇒ Array
Gets the list of hosts.
-
#get_request_id_from_response(response) ⇒ Object
private
Get the id of the ambari request from the http response when the response code is 202.
-
#initialize(logger = nil) ⇒ AmbariReceiver
constructor
Default constructor.
-
#install_cluster(cluster_name) ⇒ Array
Installs every host components of a cluster.
-
#install_component(cluster_name, component_name) ⇒ Array
Installs a type of components of a service.
-
#install_host(cluster_name, host_name) ⇒ Array
Installs every components of an host.
-
#install_host_component(cluster_name, host_name, component_name) ⇒ Int
Installs a component of an host.
-
#install_host_components(cluster_name, service_name, host_name) ⇒ Array
Installs every components of a specific service for an host.
-
#install_service(cluster_name, service_name) ⇒ Array
Installs a service.
-
#list_clusters ⇒ Object
Shows the list of clusters.
-
#show_cluster(cluster_name, show_host, show_components) ⇒ Object
Shows the information of a cluster.
-
#show_cluster_hosts(cluster_name) ⇒ Object
Shows the hosts of a cluster.
-
#show_cluster_services(cluster_name) ⇒ Object
Shows the services of a cluster.
-
#show_host(cluster_name, host_name) ⇒ Object
Shows information of an host.
-
#show_host_component(cluster_name, host_name, component_name) ⇒ Hash
Shows information of an host component.
-
#show_request(cluster_name, request_id) ⇒ Object
Shows the requests of a cluster.
-
#show_requests(cluster_name) ⇒ Object
Shows the requests of a cluster.
-
#show_service(cluster_name, service_name) ⇒ Object
Shows the list of service of a cluster.
-
#show_service_components(cluster_name, service_name, component_name) ⇒ Object
Shows information of a type of components of a service.
-
#start_cluster(cluster_name) ⇒ Array
Starts every host components of a cluster.
-
#start_component(cluster_name, component_name) ⇒ Array
Starts a type of component.
-
#start_host(cluster_name, host_name) ⇒ Array
Starts every components of an host.
-
#start_host_component(cluster_name, host_name, component_name) ⇒ Int
Starts a component of an host.
-
#start_host_components(cluster_name, service_name, host_name) ⇒ Array
Starts every components of a specific service for an host.
-
#start_service(cluster_name, service_name) ⇒ Array
Starts a service.
-
#stop_cluster(cluster_name) ⇒ Array
Stops every host components of a cluster.
-
#stop_component(cluster_name, component_name) ⇒ Array
Stops a type of component.
-
#stop_host(cluster_name, host_name) ⇒ Array
Stops every components of an host.
-
#stop_host_component(cluster_name, host_name, component_name) ⇒ Int
Stops a component of an host.
-
#stop_host_components(cluster_name, service_name, host_name) ⇒ Array
Stops every components of a specific service for an host.
-
#stop_service(cluster_name, service_name) ⇒ Array
Stops a service.
-
#valid_action_host_component(action, cluster_name, host_name, component_name) ⇒ Object
private
Checks if the action is valid on the host component.
Constructor Details
#initialize(logger = nil) ⇒ AmbariReceiver
Default constructor.
136 137 138 139 140 |
# File 'lib/receiver/ambari_receiver.rb', line 136 def initialize(logger = nil) super(logger) @rest_connector = Receiver::AmbariRestAPIConnector.new(logger) @logger.info("Command::AmbariReceiver initialize the parameters...") end |
Class Method Details
.get_components_by_service_name(service_name) ⇒ Array<String>
throw an exception of type UnknownHadoopService
Get the component list of service_name. It includes master and slave nodes.
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/receiver/ambari_receiver.rb', line 65 def self.get_components_by_service_name(service_name) return nil if !valid_service?(service_name) # @todo throw exception components = [] components.concat(@@hadoop_services_description[service_name]["MASTER"]) components.concat(@@hadoop_services_description[service_name]["SLAVE"]) return components end |
.get_service_by_component_name(component_name) ⇒ String
throw an exception of type UnknownHadoopComponent
Get the component list of service_name. It includes master and slave nodes.
82 83 84 85 86 87 88 89 90 |
# File 'lib/receiver/ambari_receiver.rb', line 82 def self.get_service_by_component_name(component_name) return nil if !valid_component?(component_name) # @todo throw exception @@hadoop_services_description.each do |service_name| return service_name if get_components_by_service_name(service_name).include?(component_name) end return nil end |
.valid_component?(component_name) ⇒ Boolean
Check if component_name is a Hadoop service.
104 105 106 107 108 109 |
# File 'lib/receiver/ambari_receiver.rb', line 104 def self.valid_component?(component_name) @@hadoop_services_description.each_key do |service| return true if get_component_by_service_name(service).include?(component_name) end return false end |
.valid_service?(service_name) ⇒ Boolean
Check if service_name is a Hadoop service.
96 97 98 |
# File 'lib/receiver/ambari_receiver.rb', line 96 def self.valid_service?(service_name) return true if @@hadoop_services_description.has_key?(service_name) end |
.valid_service_component?(service_name, component_name) ⇒ Boolean
throw an exception of type UnknownHadoopService if the service_name doesn’t exists.
throw and exception of type UnknownHadoopComponent if the component_name doesn’t exists.
Check if a component is part of a service
118 119 120 121 122 123 124 125 126 127 |
# File 'lib/receiver/ambari_receiver.rb', line 118 def self.valid_service_component?(service_name, component_name) return nil if !valid_service?(service_name) # @todo throw an exception return nil if !valid_component?(component_name) # @todo throw an exception @@hadoop_services_description[service_name].each_value do |component| return true if component == component_name end return false end |
Instance Method Details
#add_host(cluster_name, host_name) ⇒ Object
Adds an host.
486 487 488 |
# File 'lib/receiver/ambari_receiver.rb', line 486 def add_host(cluster_name, host_name) @rest_connector.add_host(cluster_name, host_name) end |
#add_host_component(cluster_name, host_name, component_name) ⇒ Object
Adds a component to an host.
382 383 384 385 386 387 388 |
# File 'lib/receiver/ambari_receiver.rb', line 382 def add_host_component(cluster_name, host_name, component_name) begin @rest_connector.add_host_component(cluster_name, host_name, component_name) rescue ClientError => e raise Common::AlreadyExistsEntity.new("host component", component_name, e.to_s) if e.code == 409 end end |
#add_service_component(cluster_name, service_name, component_name) ⇒ Object
Adds a component to a service.
620 621 622 |
# File 'lib/receiver/ambari_receiver.rb', line 620 def add_service_component(cluster_name, service_name, component_name) @rest_connector.add_service_component(cluster_name, service_name, component_name) end |
#apply_configuration(cluster_name, configuration_type, configuration_tag) ⇒ Object
Apply a configuration into a cluster.
180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/receiver/ambari_receiver.rb', line 180 def apply_configuration(cluster_name, configuration_type, configuration_tag) confs = get_cluster_configurations_list(cluster_name) exist = false confs.each do |conf| if (configuration_type == conf["type"] && configuration_tag == conf["tag"]) exist = true end end raise Common::UnknownEntity.new("Ambari configuration", "Type: #{configuration_type} Tag: #{configuration_tag}") unless exist response = @rest_connector.apply_configuration(cluster_name, configuration_type, configuration_tag) end |
#create_apply_configuration(cluster_name, configuration_type, configuration_tag, configuration_properties) ⇒ Object
Create and apply a configuration into a cluster.
166 167 168 |
# File 'lib/receiver/ambari_receiver.rb', line 166 def create_apply_configuration(cluster_name, configuration_type, configuration_tag, configuration_properties) @rest_connector.create_apply_configuration(cluster_name, configuration_type, configuration_tag, configuration_properties) end |
#create_configuration(cluster_name, configuration_type, configuration_tag, configuration_properties) ⇒ Object
Create a configuration into a cluster.
152 153 154 |
# File 'lib/receiver/ambari_receiver.rb', line 152 def create_configuration(cluster_name, configuration_type, configuration_tag, configuration_properties) @rest_connector.create_configuration(cluster_name, configuration_type, configuration_tag, configuration_properties) end |
#define_cluster(cluster_name, cluster_version) ⇒ Object
Defines a new cluster.
201 202 203 |
# File 'lib/receiver/ambari_receiver.rb', line 201 def define_cluster(cluster_name, cluster_version) @rest_connector.define_cluster(cluster_name, cluster_version) end |
#define_service(cluster_name, service_name) ⇒ Object
Defines a new service.
632 633 634 635 636 637 638 |
# File 'lib/receiver/ambari_receiver.rb', line 632 def define_service(cluster_name, service_name) begin @rest_connector.define_service(cluster_name, service_name) rescue ServerError => e raise Common::AlreadyExistsEntity.new("service", service_name, e.to_s) if e.code == 409 end end |
#delete_cluster(cluster_name) ⇒ Object
Deletes a new cluster.
211 212 213 |
# File 'lib/receiver/ambari_receiver.rb', line 211 def delete_cluster(cluster_name) @rest_connector.delete_cluster(cluster_name) end |
#delete_host(cluster_name, host_name) ⇒ Object
Deletes an host.
411 412 413 |
# File 'lib/receiver/ambari_receiver.rb', line 411 def delete_host(cluster_name, host_name) @rest_connector.delete_host(cluster_name, host_name) end |
#delete_host_component(cluster_name, host_name, component_name) ⇒ Object
Deletes a component from an host.
399 400 401 402 |
# File 'lib/receiver/ambari_receiver.rb', line 399 def delete_host_component(cluster_name, host_name, component_name) valid_action_host_component('DELETE', cluster_name, host_name, component_name) @rest_connector.delete_host_component(cluster_name, host_name, component_name) end |
#delete_service(cluster_name, service_name) ⇒ Object
Deletes a service.
647 648 649 |
# File 'lib/receiver/ambari_receiver.rb', line 647 def delete_service(cluster_name, service_name) @rest_connector.delete_service(cluster_name, service_name) end |
#detach_host_component(cluster_name, host_name, component_name) ⇒ Int
Detachs a component of an host.
473 474 475 476 477 |
# File 'lib/receiver/ambari_receiver.rb', line 473 def detach_host_component(cluster_name, host_name, component_name) valid_action_host_component('DETACH', cluster_name, host_name, component_name) response = @rest_connector.detach_host_component(cluster_name, host_name, component_name) return get_request_id_from_response(response) end |
#execute_method_on_components(method, cluster_name, service_name = nil, host_name = nil, component_type = nil) ⇒ Array (private)
Execute a method passed in parameter for every host component of a cluster
775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 |
# File 'lib/receiver/ambari_receiver.rb', line 775 def execute_method_on_components(method, cluster_name, service_name = nil, host_name = nil, component_type = nil) request_ids = [] data = show_cluster(cluster_name, true, true) data['services'].each do |service| if service_name == nil || service_name == service['ServiceInfo']['service_name'] service['components'].each do |component| if component_type == nil || component_type == component['ServiceComponentInfo']['component_name'] component['host_components'].each do |host_component| if host_name == nil || host_name == host_component['HostRoles']['host_name'] begin request_ids << method.call(cluster_name, host_component['HostRoles']['host_name'], component['ServiceComponentInfo']['component_name']) rescue Common::InvalidActionSequence # @todo Do a feedback to the interface that the install of the component was ignored. end end end end end end end return request_ids end |
#get_cluster_configuration(cluster_name, type, tag) ⇒ Object
Returns the list of configuration of a cluster.
277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/receiver/ambari_receiver.rb', line 277 def get_cluster_configuration(cluster_name, type, tag) if cluster_name == nil || type == nil || tag == nil raise(ArgumentError, 'Arguments can\'t be nil!') end response = @rest_connector.get_cluster_configuration(cluster_name, type, tag) conf = JSON.parse(response.body) conf = conf["items"][0] if conf.nil? raise Common::UnknownEntity.new("Ambari configuration", "Type: #{type} Tag: #{tag}") end return conf["properties"] end |
#get_cluster_configurations_list(cluster_name) ⇒ Object
Returns the list of configuration of a cluster.
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/receiver/ambari_receiver.rb', line 246 def get_cluster_configurations_list(cluster_name) if cluster_name == nil raise(ArgumentError, 'Arguments can\'t be nil!') end response = @rest_connector.show_cluster(cluster_name) confs = JSON.parse(response.body) active_confs = confs["Clusters"]["desired_configs"] confs = confs["configurations"].sort { |x, y| x["href"] <=> y["href"] } confs.each do |conf| conf.delete("href") conf.delete("Config") if (!conf["type"].nil? && active_confs[conf["type"]]["tag"] == conf["tag"]) conf["active"] = true else conf["active"] = false end end return confs end |
#get_host_list(cluster_name) ⇒ Array
Gets the list of hosts.
495 496 497 498 499 500 501 502 503 |
# File 'lib/receiver/ambari_receiver.rb', line 495 def get_host_list(cluster_name) response = @rest_connector.show_cluster(cluster_name) data = JSON.parse(response.body) hosts = [] data["hosts"].each do |host| hosts << host["Hosts"]["host_name"] end return hosts end |
#get_request_id_from_response(response) ⇒ Object (private)
Get the id of the ambari request from the http response when the response code is 202.
803 804 805 806 807 808 809 |
# File 'lib/receiver/ambari_receiver.rb', line 803 def get_request_id_from_response(response) request_id = nil if response.code == '202' request_id = JSON.parse(response.body)['Requests']['id'] end return request_id end |
#install_cluster(cluster_name) ⇒ Array
Installs every host components of a cluster.
347 348 349 |
# File 'lib/receiver/ambari_receiver.rb', line 347 def install_cluster(cluster_name) return execute_method_on_components(method(:install_host_component), cluster_name) end |
#install_component(cluster_name, component_name) ⇒ Array
Installs a type of components of a service.
695 696 697 |
# File 'lib/receiver/ambari_receiver.rb', line 695 def install_component(cluster_name, component_name) return execute_method_on_components(method(:install_host_component), cluster_name, nil, nil, component_name) end |
#install_host(cluster_name, host_name) ⇒ Array
Installs every components of an host.
545 546 547 |
# File 'lib/receiver/ambari_receiver.rb', line 545 def install_host(cluster_name, host_name) return execute_method_on_components(method(:install_host_component), cluster_name, nil, host_name) end |
#install_host_component(cluster_name, host_name, component_name) ⇒ Int
Installs a component of an host.
425 426 427 428 429 |
# File 'lib/receiver/ambari_receiver.rb', line 425 def install_host_component(cluster_name, host_name, component_name) valid_action_host_component('INSTALL', cluster_name, host_name, component_name) response = @rest_connector.install_host_component(cluster_name, host_name, component_name) return get_request_id_from_response(response) end |
#install_host_components(cluster_name, service_name, host_name) ⇒ Array
Installs every components of a specific service for an host.
582 583 584 |
# File 'lib/receiver/ambari_receiver.rb', line 582 def install_host_components(cluster_name, service_name, host_name) return execute_method_on_components(method(:install_host_component), cluster_name, service_name, host_name) end |
#install_service(cluster_name, service_name) ⇒ Array
Installs a service.
659 660 661 |
# File 'lib/receiver/ambari_receiver.rb', line 659 def install_service(cluster_name, service_name) return execute_method_on_components(method(:install_host_component), cluster_name, service_name) end |
#list_clusters ⇒ Object
Shows the list of clusters.
335 336 337 338 |
# File 'lib/receiver/ambari_receiver.rb', line 335 def list_clusters response = @rest_connector.list_clusters() return JSON.parse(response.body) end |
#show_cluster(cluster_name, show_host, show_components) ⇒ Object
Shows the information of a cluster.
325 326 327 328 |
# File 'lib/receiver/ambari_receiver.rb', line 325 def show_cluster(cluster_name, show_host, show_components) response = @rest_connector.show_cluster(cluster_name, show_host, show_components) return JSON.parse(response.body) end |
#show_cluster_hosts(cluster_name) ⇒ Object
Shows the hosts of a cluster.
222 223 224 225 |
# File 'lib/receiver/ambari_receiver.rb', line 222 def show_cluster_hosts(cluster_name) response = @rest_connector.show_cluster_hosts(cluster_name) return JSON.parse(response.body) end |
#show_cluster_services(cluster_name) ⇒ Object
Shows the services of a cluster.
234 235 236 237 |
# File 'lib/receiver/ambari_receiver.rb', line 234 def show_cluster_services(cluster_name) response = @rest_connector.show_cluster_services(cluster_name) return JSON.parse(response.body) end |
#show_host(cluster_name, host_name) ⇒ Object
Shows information of an host.
513 514 515 516 |
# File 'lib/receiver/ambari_receiver.rb', line 513 def show_host(cluster_name, host_name) response = @rest_connector.show_host(cluster_name, host_name) return JSON.parse(response.body) end |
#show_host_component(cluster_name, host_name, component_name) ⇒ Hash
Shows information of an host component.
527 528 529 530 531 532 533 534 535 |
# File 'lib/receiver/ambari_receiver.rb', line 527 def show_host_component(cluster_name, host_name, component_name) response = @rest_connector.show_host(cluster_name, host_name) data = JSON.parse(response.body) data["host_components"].each do |component| if component["HostRoles"]["component_name"] == component_name return component["HostRoles"] end end end |
#show_request(cluster_name, request_id) ⇒ Object
Shows the requests of a cluster.
311 312 313 314 |
# File 'lib/receiver/ambari_receiver.rb', line 311 def show_request(cluster_name, request_id) response = @rest_connector.show_request(cluster_name, request_id) return JSON.parse(response.body) end |
#show_requests(cluster_name) ⇒ Object
Shows the requests of a cluster.
298 299 300 301 |
# File 'lib/receiver/ambari_receiver.rb', line 298 def show_requests(cluster_name) response = @rest_connector.show_requests(cluster_name) return JSON.parse(response.body) end |
#show_service(cluster_name, service_name) ⇒ Object
Shows the list of service of a cluster.
745 746 747 748 |
# File 'lib/receiver/ambari_receiver.rb', line 745 def show_service(cluster_name, service_name) response = @rest_connector.show_service(cluster_name, service_name) return JSON.parse(response.body) end |
#show_service_components(cluster_name, service_name, component_name) ⇒ Object
Shows information of a type of components of a service.
732 733 734 735 |
# File 'lib/receiver/ambari_receiver.rb', line 732 def show_service_components(cluster_name, service_name, component_name) response = @rest_connector.show_service_components(cluster_name, service_name, component_name) return JSON.parse(response.body) end |
#start_cluster(cluster_name) ⇒ Array
Starts every host components of a cluster.
358 359 360 |
# File 'lib/receiver/ambari_receiver.rb', line 358 def start_cluster(cluster_name) return execute_method_on_components(method(:start_host_component), cluster_name) end |
#start_component(cluster_name, component_name) ⇒ Array
Starts a type of component.
707 708 709 |
# File 'lib/receiver/ambari_receiver.rb', line 707 def start_component(cluster_name, component_name) return execute_method_on_components(method(:start_host_component), cluster_name, nil, nil, component_name) end |
#start_host(cluster_name, host_name) ⇒ Array
Starts every components of an host.
557 558 559 |
# File 'lib/receiver/ambari_receiver.rb', line 557 def start_host(cluster_name, host_name) return execute_method_on_components(method(:start_host_component), cluster_name, nil, host_name) end |
#start_host_component(cluster_name, host_name, component_name) ⇒ Int
Starts a component of an host.
441 442 443 444 445 |
# File 'lib/receiver/ambari_receiver.rb', line 441 def start_host_component(cluster_name, host_name, component_name) valid_action_host_component('START', cluster_name, host_name, component_name) response = @rest_connector.start_host_component(cluster_name, host_name, component_name) return get_request_id_from_response(response) end |
#start_host_components(cluster_name, service_name, host_name) ⇒ Array
Starts every components of a specific service for an host.
595 596 597 |
# File 'lib/receiver/ambari_receiver.rb', line 595 def start_host_components(cluster_name, service_name, host_name) return execute_method_on_components(method(:start_host_component), cluster_name, service_name, host_name) end |
#start_service(cluster_name, service_name) ⇒ Array
Starts a service.
671 672 673 |
# File 'lib/receiver/ambari_receiver.rb', line 671 def start_service(cluster_name, service_name) return execute_method_on_components(method(:start_host_component), cluster_name, service_name) end |
#stop_cluster(cluster_name) ⇒ Array
Stops every host components of a cluster.
369 370 371 |
# File 'lib/receiver/ambari_receiver.rb', line 369 def stop_cluster(cluster_name) return execute_method_on_components(method(:stop_host_component), cluster_name) end |
#stop_component(cluster_name, component_name) ⇒ Array
Stops a type of component.
719 720 721 |
# File 'lib/receiver/ambari_receiver.rb', line 719 def stop_component(cluster_name, component_name) return execute_method_on_components(method(:stop_host_component), cluster_name, nil, nil, component_name) end |
#stop_host(cluster_name, host_name) ⇒ Array
Stops every components of an host.
569 570 571 |
# File 'lib/receiver/ambari_receiver.rb', line 569 def stop_host(cluster_name, host_name) return execute_method_on_components(method(:stop_host_component), cluster_name, nil, host_name) end |
#stop_host_component(cluster_name, host_name, component_name) ⇒ Int
Stops a component of an host.
457 458 459 460 461 |
# File 'lib/receiver/ambari_receiver.rb', line 457 def stop_host_component(cluster_name, host_name, component_name) valid_action_host_component('STOP', cluster_name, host_name, component_name) response = @rest_connector.stop_host_component(cluster_name, host_name, component_name) return get_request_id_from_response(response) end |
#stop_host_components(cluster_name, service_name, host_name) ⇒ Array
Stops every components of a specific service for an host.
608 609 610 |
# File 'lib/receiver/ambari_receiver.rb', line 608 def stop_host_components(cluster_name, service_name, host_name) return execute_method_on_components(method(:stop_host_component), cluster_name, service_name, host_name) end |
#stop_service(cluster_name, service_name) ⇒ Array
Stops a service.
683 684 685 |
# File 'lib/receiver/ambari_receiver.rb', line 683 def stop_service(cluster_name, service_name) return execute_method_on_components(method(:stop_host_component), cluster_name, service_name) end |
#valid_action_host_component(action, cluster_name, host_name, component_name) ⇒ Object (private)
Checks if the action is valid on the host component.
758 759 760 761 762 763 764 |
# File 'lib/receiver/ambari_receiver.rb', line 758 def valid_action_host_component(action, cluster_name, host_name, component_name) response = show_host_component(cluster_name, host_name, component_name) current_state = response["state"] unless @@available_actions[action]['required_state'].include?(current_state) raise Common::InvalidActionSequence.new(action, current_state, @@available_actions, "#{component_name}/#{host_name}", "host component") end end |