Class: Cwb::Client
Overview
Serves as cwb-server client library in cloud VMs (if configured against a cwb-server) or as standalone utility otherwise where cwb-server communication (e.g., metric submission) is logged to stdout.
Constant Summary collapse
- VM_INSTANCE =
RESTful endpoints
"virtual_machine_instances"
- METRIC_OBSERVATIONS =
"metric_observations"
Instance Method Summary collapse
-
#deep_fetch(*keys) ⇒ String
Securly access nested attributes.
-
#notify_failed_execution(message = "") ⇒ void
Notifies the cwb-server that the benchmark failed during the execution.
-
#notify_finished_execution ⇒ void
Notifies the cwb-server that the benchmark successfully completed.
-
#reconfigure(config) ⇒ void
private
Reconfigures the Client with a configuration object against a cwb-server.
-
#submit_metric(metric_definition_id, time, value) ⇒ void
Submit a single metric.
-
#submit_metrics(metric_definition_id, csv_file) ⇒ void
Submit a csv file with metrics.
Instance Method Details
#deep_fetch(*keys) ⇒ String
Securly access nested attributes.
39 40 41 |
# File 'lib/cwb/client.rb', line 39 def deep_fetch(*keys) @config.deep_fetch(*keys) end |
#notify_failed_execution(message = "") ⇒ void
The cwb-server will shutdown all VMs of this execution after a timeout (~15’).
This method returns an undefined value.
Notifies the cwb-server that the benchmark failed during the execution
87 88 89 90 91 92 93 |
# File 'lib/cwb/client.rb', line 87 def notify_failed_execution( = "") if @config.complete? post_notify("/#{VM_INSTANCE}/complete_benchmark", false, ) else puts "Notify failure on running. (message suppressed to avoid redundant logging)" end end |
#notify_finished_execution ⇒ void
The cwb-server will shutdown all VMs of this executions.
This method returns an undefined value.
Notifies the cwb-server that the benchmark successfully completed.
76 77 78 79 80 81 82 |
# File 'lib/cwb/client.rb', line 76 def notify_finished_execution if @config.complete? post_notify("/#{VM_INSTANCE}/complete_postprocessing", true) else puts "Notify finished postprocessing." end end |
#reconfigure(config) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Reconfigures the Client with a configuration object against a cwb-server.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cwb/client.rb', line 22 def reconfigure(config) @config = config if @config.complete? @connection = Faraday.new(:url => "http://#{@config.server}") do |f| f.request :multipart f.request :json f.adapter Faraday.default_adapter end end end |
#submit_metric(metric_definition_id, time, value) ⇒ void
This method returns an undefined value.
Submit a single metric
48 49 50 51 52 53 54 |
# File 'lib/cwb/client.rb', line 48 def submit_metric(metric_definition_id, time, value) if @config.complete? submit_remote_metric(metric_definition_id, time, value) else puts "#{metric_definition_id},#{time},#{value}" end end |
#submit_metrics(metric_definition_id, csv_file) ⇒ void
the csv file must:
-
have two columns: ‘time’ [Integer], ‘value’ [String (nominal-scale) or Numeric (otherwise)]
-
be formatted without headers
This method returns an undefined value.
Submit a csv file with metrics
63 64 65 66 67 68 69 70 71 |
# File 'lib/cwb/client.rb', line 63 def submit_metrics(metric_definition_id, csv_file) if @config.complete? submit_remote_metrics(metric_definition_id, csv_file) else CSV.foreach(csv_file) do |row| puts row.join(',') end end end |