Class: ClientCommandLine
- Inherits:
-
Object
- Object
- ClientCommandLine
- Defined in:
- lib/load/client_command_line.rb
Instance Attribute Summary collapse
-
#node_info_json ⇒ Object
readonly
Returns the value of attribute node_info_json.
-
#run_id ⇒ Object
readonly
Returns the value of attribute run_id.
Instance Method Summary collapse
- #create_run(node_count, configuration_file_name, wasp_server_address, target_server) ⇒ Object
- #launch(args) ⇒ Object
- #launch_node(run_id, wasp_server_address, node_code) ⇒ Object
- #process_node_command(args) ⇒ Object
- #require_directory(directory_name) ⇒ Object
Instance Attribute Details
#node_info_json ⇒ Object (readonly)
Returns the value of attribute node_info_json.
6 7 8 |
# File 'lib/load/client_command_line.rb', line 6 def node_info_json @node_info_json end |
#run_id ⇒ Object (readonly)
Returns the value of attribute run_id.
6 7 8 |
# File 'lib/load/client_command_line.rb', line 6 def run_id @run_id end |
Instance Method Details
#create_run(node_count, configuration_file_name, wasp_server_address, target_server) ⇒ Object
94 95 96 97 98 |
# File 'lib/load/client_command_line.rb', line 94 def create_run(node_count, configuration_file_name, wasp_server_address, target_server) messenger = HttpReport.new(wasp_server_address) @run_id = messenger.run_create({ node_count: node_count, config_file_name: configuration_file_name, target_server: target_server}) @node_info_json = messenger.run_node_info({run_id: @run_id}) end |
#launch(args) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 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 |
# File 'lib/load/client_command_line.rb', line 17 def launch(args) require_directory("custom") puts "Wasp!" index = 0 main_command = args[0] puts "Command: #{main_command}" index = 1 if (main_command == "run") node_count = 1 configuration_file_name = nil server_address = nil @target_server = nil while (index < args.length) arg = args[index] if (arg == "-n") index += 1 node_count = args[index].to_i end if (arg == "-s") index += 1 server_address = args[index] end if (arg == "-t") index += 1 @target_server = args[index] end if (arg == "-c") index += 1 configuration_file_name = args[index] end index += 1 #puts "Looking at command line param: #{index}" end if (configuration_file_name == nil) raise "Failed to pass a -c parameter for config file" end if (@target_server == nil) raise "Must specify: -t 'target_server' on the command line" end uri = "http://#{server_address}/client" puts "Wasp server: #{uri}" create_run(node_count, configuration_file_name, server_address, @target_server) launch_node_command = "\nTo Start Nodes:\n" @node_info_json.each do |node_config| code = node_config["code"] launch_node_command += " ruby wasp.rb node -c #{code} -s #{server_address} -r #{@run_id}\n" end puts " Run established. Run ID: #{@run_id} Waiting for #{node_count} nodes. Run details page: http://#{server_address}/reports/run_details?run=#{@run_id} #{launch_node_command} " elsif (main_command == "node") @run_id = nil load_node = process_node_command(args) else help_text = "Usage: wasp run -n /node_count/ -d /definition code/ {start with this process being the only node} wasp node m {m is number of nodes, returns the run id for the node start up} wasp node -r /run_id/ {starts one of the nodes for a run} " puts help_text end end |
#launch_node(run_id, wasp_server_address, node_code) ⇒ Object
127 128 129 |
# File 'lib/load/client_command_line.rb', line 127 def launch_node(run_id, wasp_server_address, node_code) load_node = LoadNode.new(run_id, wasp_server_address, node_code) end |
#process_node_command(args) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/load/client_command_line.rb', line 100 def process_node_command(args) while (index < args.length) arg = args[index] if (arg == "-r") index += 1 @run_id = args[index].to_i elsif (arg == "-s") index += 1 server_address = args[index] elsif (arg == "-c") index += 1 node_code = args[index] end index += 1 end if (@run_id == nil) raise "Failed to pass the run_id with -r for the node to run against." end if (server_address == nil) raise "Failed to pass the server address with -s for the node to run against." end load_node = launch_node(@run_id, server_address, node_code) return load_node end |
#require_directory(directory_name) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/load/client_command_line.rb', line 8 def require_directory(directory_name) project_root = File.dirname(File.absolute_path(__FILE__)) parent_directory = project_root + "/#{directory_name}" puts "Parent root: #{parent_directory}" Dir.glob("#{parent_directory}/*") do |file| require file end end |