Class: Dag::Job
Instance Attribute Summary collapse
-
#access_key_id ⇒ Object
readonly
Returns the value of attribute access_key_id.
-
#cluster ⇒ Object
readonly
Returns the value of attribute cluster.
-
#cluster_rebooted ⇒ Object
readonly
Returns the value of attribute cluster_rebooted.
-
#dsl ⇒ Object
readonly
Returns the value of attribute dsl.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#input_format ⇒ Object
readonly
Returns the value of attribute input_format.
-
#input_object_keys ⇒ Object
readonly
Returns the value of attribute input_object_keys.
-
#job_id ⇒ Object
readonly
Returns the value of attribute job_id.
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#output_database ⇒ Object
readonly
Returns the value of attribute output_database.
-
#output_format ⇒ Object
readonly
Returns the value of attribute output_format.
-
#output_resource_path ⇒ Object
readonly
Returns the value of attribute output_resource_path.
-
#output_table ⇒ Object
readonly
Returns the value of attribute output_table.
-
#process_engine ⇒ Object
readonly
Returns the value of attribute process_engine.
-
#progress ⇒ Object
readonly
Returns the value of attribute progress.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
-
#stage ⇒ Object
readonly
Returns the value of attribute stage.
-
#start_at ⇒ Object
readonly
Returns the value of attribute start_at.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from Model
Instance Method Summary collapse
- #cluster_rebooted? ⇒ Boolean
- #download_urls(time_limit = 30) ⇒ Object
- #finished? ⇒ Boolean
- #hive? ⇒ Boolean
-
#initialize(api, job_info) ⇒ Job
constructor
A new instance of Job.
- #kill ⇒ Object (also: #cancel)
- #log ⇒ Object
- #reload ⇒ Object
- #running? ⇒ Boolean
- #split? ⇒ Boolean
- #validate_cancel_condition ⇒ Object
- #validate_log_condition ⇒ Object
Constructor Details
#initialize(api, job_info) ⇒ Job
Returns a new instance of Job.
3 4 5 6 |
# File 'lib/dag/client/model/job.rb', line 3 def initialize(api, job_info) super(api) update_parameters(job_info) end |
Instance Attribute Details
#access_key_id ⇒ Object (readonly)
Returns the value of attribute access_key_id.
8 9 10 |
# File 'lib/dag/client/model/job.rb', line 8 def access_key_id @access_key_id end |
#cluster ⇒ Object (readonly)
Returns the value of attribute cluster.
8 9 10 |
# File 'lib/dag/client/model/job.rb', line 8 def cluster @cluster end |
#cluster_rebooted ⇒ Object (readonly)
Returns the value of attribute cluster_rebooted.
8 9 10 |
# File 'lib/dag/client/model/job.rb', line 8 def cluster_rebooted @cluster_rebooted end |
#dsl ⇒ Object (readonly)
Returns the value of attribute dsl.
8 9 10 |
# File 'lib/dag/client/model/job.rb', line 8 def dsl @dsl end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/dag/client/model/job.rb', line 8 def id @id end |
#input_format ⇒ Object (readonly)
Returns the value of attribute input_format.
8 9 10 |
# File 'lib/dag/client/model/job.rb', line 8 def input_format @input_format end |
#input_object_keys ⇒ Object (readonly)
Returns the value of attribute input_object_keys.
8 9 10 |
# File 'lib/dag/client/model/job.rb', line 8 def input_object_keys @input_object_keys end |
#job_id ⇒ Object (readonly)
Returns the value of attribute job_id.
8 9 10 |
# File 'lib/dag/client/model/job.rb', line 8 def job_id @job_id end |
#label ⇒ Object (readonly)
Returns the value of attribute label.
8 9 10 |
# File 'lib/dag/client/model/job.rb', line 8 def label @label end |
#output_database ⇒ Object (readonly)
Returns the value of attribute output_database.
8 9 10 |
# File 'lib/dag/client/model/job.rb', line 8 def output_database @output_database end |
#output_format ⇒ Object (readonly)
Returns the value of attribute output_format.
8 9 10 |
# File 'lib/dag/client/model/job.rb', line 8 def output_format @output_format end |
#output_resource_path ⇒ Object (readonly)
Returns the value of attribute output_resource_path.
8 9 10 |
# File 'lib/dag/client/model/job.rb', line 8 def output_resource_path @output_resource_path end |
#output_table ⇒ Object (readonly)
Returns the value of attribute output_table.
8 9 10 |
# File 'lib/dag/client/model/job.rb', line 8 def output_table @output_table end |
#process_engine ⇒ Object (readonly)
Returns the value of attribute process_engine.
8 9 10 |
# File 'lib/dag/client/model/job.rb', line 8 def process_engine @process_engine end |
#progress ⇒ Object (readonly)
Returns the value of attribute progress.
8 9 10 |
# File 'lib/dag/client/model/job.rb', line 8 def progress @progress end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
8 9 10 |
# File 'lib/dag/client/model/job.rb', line 8 def query @query end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
8 9 10 |
# File 'lib/dag/client/model/job.rb', line 8 def schema @schema end |
#stage ⇒ Object (readonly)
Returns the value of attribute stage.
8 9 10 |
# File 'lib/dag/client/model/job.rb', line 8 def stage @stage end |
#start_at ⇒ Object (readonly)
Returns the value of attribute start_at.
8 9 10 |
# File 'lib/dag/client/model/job.rb', line 8 def start_at @start_at end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
8 9 10 |
# File 'lib/dag/client/model/job.rb', line 8 def status @status end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
8 9 10 |
# File 'lib/dag/client/model/job.rb', line 8 def type @type end |
Instance Method Details
#cluster_rebooted? ⇒ Boolean
28 29 30 |
# File 'lib/dag/client/model/job.rb', line 28 def cluster_rebooted? !!@cluster_rebooted end |
#download_urls(time_limit = 30) ⇒ Object
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 |
# File 'lib/dag/client/model/job.rb', line 44 def download_urls(time_limit = 30) raise Dag::Client::StatusInvalid.new("job status is not finished") unless finished? expire_at = time_limit.minutes.since.to_i object_uri = URI.parse(@output_resource_path) bucket = object_uri.host object_path = object_uri.path[1..-1] object_path += '/' unless object_path.end_with? '/' bucket_objects = @api.objects(bucket, prefix: object_path).objects bucket_objects.map do |object| path = if @api.force_path_style? "/#{bucket}/#{object}" else "/#{object}" end parameters = { "Expires" => expire_at, "IIJGIOAccessKeyId" => @api.apikey, "Signature" => @api.download_signature(expire_at, bucket, path) } uri = URI.parse(@api.storage_api) url = if @api.force_path_style? "http://#{uri.host}" else "http://#{bucket}.#{uri.host}" end url += ":#{uri.port}" unless uri.port == 80 || uri.port == 443 File.join(url, "#{path}?#{parameters.to_param}") end end |
#finished? ⇒ Boolean
12 13 14 |
# File 'lib/dag/client/model/job.rb', line 12 def finished? @status == 'finished' end |
#hive? ⇒ Boolean
24 25 26 |
# File 'lib/dag/client/model/job.rb', line 24 def hive? @type == 'select' end |
#kill ⇒ Object Also known as: cancel
37 38 39 40 |
# File 'lib/dag/client/model/job.rb', line 37 def kill validate_cancel_condition @api.query_cancel(@id) end |
#log ⇒ Object
77 78 79 80 81 |
# File 'lib/dag/client/model/job.rb', line 77 def log validate_log_condition log_info = @api.query_log(@id) log_info ? log_info['log'] : '' end |
#reload ⇒ Object
32 33 34 35 |
# File 'lib/dag/client/model/job.rb', line 32 def reload job_info = @api.query_info(@id) update_parameters(job_info) end |
#running? ⇒ Boolean
16 17 18 |
# File 'lib/dag/client/model/job.rb', line 16 def running? @status == 'running' end |
#split? ⇒ Boolean
20 21 22 |
# File 'lib/dag/client/model/job.rb', line 20 def split? @type == 'split' end |
#validate_cancel_condition ⇒ Object
93 94 95 96 97 |
# File 'lib/dag/client/model/job.rb', line 93 def validate_cancel_condition unless running? raise Dag::Client::StatusInvalid.new("job status is not running") end end |
#validate_log_condition ⇒ Object
83 84 85 86 87 88 89 90 91 |
# File 'lib/dag/client/model/job.rb', line 83 def validate_log_condition if split? raise Dag::Client::JobTypeInvalid.new("job type is not select") end if cluster_rebooted? raise Dag::Client::ClusterRebooted.new("cluster is rebooted") end end |