Class: Exec::ServiceStart
- Inherits:
-
ExecutableCommand
- Object
- ExecutableCommand
- Exec::ServiceStart
- Defined in:
- lib/exec/service_start.rb
Overview
Allows the user to start services.
Instance Attribute Summary
Attributes inherited from ExecutableCommand
#argv, #command_name, #logger, #options, #stderr, #stdin, #stdout, #values
Instance Method Summary collapse
-
#exec ⇒ Object
private
Execution of the command.
-
#set_options ⇒ Object
private
Parse and check the parameters of the function.
Methods inherited from ExecutableCommand
#check_parameters, #create_logger, #initialize, #run
Constructor Details
This class inherits a constructor from Exec::ExecutableCommand
Instance Method Details
#exec ⇒ Object (private)
Execution of the command
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/exec/service_start.rb', line 39 def exec begin Color::print_log("NONE", "Checking dependencies...", @stdout) Common::ServicesDescription.get_master_components_deps(@values["service"]).each do |dep_master_component| dep_service_name = Common::ServicesDescription.get_service_name_by_comp_name(dep_master_component) data = Command::.new(dep_service_name, @values["cluster"], dep_master_component).exec started = true data["host_components"].each do |host_component| started = false if host_component["HostRoles"]["state"] != "STARTED" end raise MissingDependency.new("Master component #{dep_master_component} has to be started before start #{@values["service"]} service.") unless started end Color::echo_ok(@stdout) rescue CloudboxError => e Color::echo_fail(@stdout) raise e end msg = "Unknown combination of attributes... (should never happend)" cmd = nil if (!@values["host"].nil? && !@values["component"].nil?) || (!@values["service"].nil? && !@values["host"].nil? && !@values["component"].nil?) # 3 # one component on one host msg = "Start components #{@values["component"]} on host #{@values["host"]} (@cluster #{@values["cluster"]})." cmd = Command::.new(@values["cluster"], @values["component"], @values["host"]) elsif !@values["component"].nil? || (!@values["service"].nil? && !@values["component"].nil?) # 1 # one component on all hosts msg = "Start all components (@cluster #{@values["cluster"]})." cmd = Command::.new(@values["cluster"], @values["component"]) elsif !@values["service"].nil? && !@values["host"].nil? # 5 # all component on one host for one service # @todo it is the same case than number 3 msg = "Start components #{@values["component"]} of service #{@values["service"]} on host #{@values["host"]} (@cluster #{@values["cluster"]})." cmd = Command::.new(@values["cluster"], @values["service"], @values["host"]) elsif !@values["host"].nil? # 2 # all component on one host msg = "Start all components on host #{@values["host"]} (@cluster #{@values["cluster"]})." cmd = Command::.new(@values["cluster"], @values["host"]) elsif !@values["service"].nil? # 4 # all component on all hosts for one service msg = "Start all components #{@values["component"]} of service #{@values["service"]} on all hosts (@cluster #{@values["cluster"]})." cmd = Command::.new(@values["cluster"], @values["service"]) elsif @values["service"].nil? && @values["host"].nil? && @values["component"].nil? # 6 # all component on all host for all service msg = "Start all components of all services on all hosts (@cluster #{@values["cluster"]})." cmd = Command::.new(@values["cluster"]) else raise StandardError(msg) end Color::print_log("NONE", msg, @stdout) cmd.exec() Color::echo_ok(@stdout) end |
#set_options ⇒ Object (private)
Parse and check the parameters of the function.
28 29 30 31 32 33 34 35 |
# File 'lib/exec/service_start.rb', line 28 def @logger.info("setting options") .add_option("C", "cluster", "The virtual cluster name.", true, true, method(:check_cluster_name)) .add_option("s", "service", "Limit request to this service.", false, true, method(:check_hadoop_service_name)) .add_option("H", "host", "Limit request to this host.", false, true, method(:check_ambari_host_name)) .add_option("c", "component", "Limit request to this component type.", false, true, method(:check_hadoop_component_name)) .add_option("f", "follow", "Follow completion of the request.", false) end |