Class: TreasureData::Job
Direct Known Subclasses
Constant Summary collapse
- STATUS_QUEUED =
"queued"
- STATUS_BOOTING =
"booting"
- STATUS_RUNNING =
"running"
- STATUS_SUCCESS =
"success"
- STATUS_ERROR =
"error"
- STATUS_KILLED =
"killed"
- FINISHED_STATUS =
[STATUS_SUCCESS, STATUS_ERROR, STATUS_KILLED]
Instance Attribute Summary collapse
-
#db_name ⇒ Object
readonly
Returns the value of attribute db_name.
-
#job_id ⇒ Object
readonly
Returns the value of attribute job_id.
-
#org_name ⇒ Object
readonly
Returns the value of attribute org_name.
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
-
#result_url ⇒ Object
readonly
Returns the value of attribute result_url.
-
#retry_limit ⇒ Object
readonly
Returns the value of attribute retry_limit.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from Model
Instance Method Summary collapse
- #cpu_time ⇒ Object
- #debug ⇒ Object
- #end_at ⇒ Object
- #error? ⇒ Boolean
- #finished? ⇒ Boolean
- #hive_result_schema ⇒ Object
-
#initialize(client, job_id, type, query, status = nil, url = nil, debug = nil, start_at = nil, end_at = nil, cpu_time = nil, result_size = nil, result = nil, result_url = nil, hive_result_schema = nil, priority = nil, retry_limit = nil, org_name = nil, db_name = nil) ⇒ Job
constructor
A new instance of Job.
- #kill! ⇒ Object
- #killed? ⇒ Boolean
- #query ⇒ Object
- #queued? ⇒ Boolean
- #result ⇒ Object
- #result_each(&block) ⇒ Object
- #result_each_with_compr_size(&block) ⇒ Object
- #result_format(format, io = nil, &block) ⇒ Object
- #result_size ⇒ Object
- #running? ⇒ Boolean
- #start_at ⇒ Object
- #status ⇒ Object
- #success? ⇒ Boolean
- #update_progress! ⇒ Object
- #update_status! ⇒ Object
- #url ⇒ Object
- #wait(timeout = nil) ⇒ Object
Constructor Details
#initialize(client, job_id, type, query, status = nil, url = nil, debug = nil, start_at = nil, end_at = nil, cpu_time = nil, result_size = nil, result = nil, result_url = nil, hive_result_schema = nil, priority = nil, retry_limit = nil, org_name = nil, db_name = nil) ⇒ Job
Returns a new instance of Job.
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/td/client/model.rb', line 263 def initialize(client, job_id, type, query, status=nil, url=nil, debug=nil, start_at=nil, end_at=nil, cpu_time=nil, result_size=nil, result=nil, result_url=nil, hive_result_schema=nil, priority=nil, retry_limit=nil, org_name=nil, db_name=nil) super(client) @job_id = job_id @type = type @url = url @query = query @status = status @debug = debug @start_at = start_at @end_at = end_at @cpu_time = cpu_time @result_size = result_size @result = result @result_url = result_url @hive_result_schema = hive_result_schema @priority = priority @retry_limit = retry_limit @db_name = db_name end |
Instance Attribute Details
#db_name ⇒ Object (readonly)
Returns the value of attribute db_name.
286 287 288 |
# File 'lib/td/client/model.rb', line 286 def db_name @db_name end |
#job_id ⇒ Object (readonly)
Returns the value of attribute job_id.
285 286 287 |
# File 'lib/td/client/model.rb', line 285 def job_id @job_id end |
#org_name ⇒ Object (readonly)
Returns the value of attribute org_name.
286 287 288 |
# File 'lib/td/client/model.rb', line 286 def org_name @org_name end |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
286 287 288 |
# File 'lib/td/client/model.rb', line 286 def priority @priority end |
#result_url ⇒ Object (readonly)
Returns the value of attribute result_url.
285 286 287 |
# File 'lib/td/client/model.rb', line 285 def result_url @result_url end |
#retry_limit ⇒ Object (readonly)
Returns the value of attribute retry_limit.
286 287 288 |
# File 'lib/td/client/model.rb', line 286 def retry_limit @retry_limit end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
285 286 287 |
# File 'lib/td/client/model.rb', line 285 def type @type end |
Instance Method Details
#cpu_time ⇒ Object
326 327 328 329 |
# File 'lib/td/client/model.rb', line 326 def cpu_time update_status! unless @cpu_time || finished? @cpu_time end |
#debug ⇒ Object
311 312 313 314 |
# File 'lib/td/client/model.rb', line 311 def debug update_status! unless @debug || finished? @debug end |
#end_at ⇒ Object
321 322 323 324 |
# File 'lib/td/client/model.rb', line 321 def end_at update_status! unless @end_at || finished? @end_at && !@end_at.empty? ? Time.parse(@end_at) : nil end |
#error? ⇒ Boolean
382 383 384 385 |
# File 'lib/td/client/model.rb', line 382 def error? update_progress! unless @status @status == STATUS_ERROR end |
#finished? ⇒ Boolean
372 373 374 375 |
# File 'lib/td/client/model.rb', line 372 def finished? update_progress! unless @status FINISHED_STATUS.include?(@status) end |
#hive_result_schema ⇒ Object
331 332 333 334 |
# File 'lib/td/client/model.rb', line 331 def hive_result_schema update_status! unless @hive_result_schema.instance_of? Array || finished? @hive_result_schema end |
#kill! ⇒ Object
292 293 294 |
# File 'lib/td/client/model.rb', line 292 def kill! # TODO end |
#killed? ⇒ Boolean
387 388 389 390 |
# File 'lib/td/client/model.rb', line 387 def killed? update_progress! unless @status @status == STATUS_KILLED end |
#query ⇒ Object
296 297 298 299 |
# File 'lib/td/client/model.rb', line 296 def query update_status! unless @query || finished? @query end |
#queued? ⇒ Boolean
392 393 394 395 |
# File 'lib/td/client/model.rb', line 392 def queued? update_progress! unless @status @status == STATUS_QUEUED end |
#result ⇒ Object
341 342 343 344 345 346 347 |
# File 'lib/td/client/model.rb', line 341 def result unless @result return nil unless finished? @result = @client.job_result(@job_id) end @result end |
#result_each(&block) ⇒ Object
363 364 365 366 367 368 369 370 |
# File 'lib/td/client/model.rb', line 363 def result_each(&block) if @result @result.each(&block) else @client.job_result_each(@job_id, &block) end nil end |
#result_each_with_compr_size(&block) ⇒ Object
354 355 356 357 358 359 360 361 |
# File 'lib/td/client/model.rb', line 354 def result_each_with_compr_size(&block) if @result @result.each(&block) else @client.job_result_each_with_compr_size(@job_id, &block) end nil end |
#result_format(format, io = nil, &block) ⇒ Object
349 350 351 352 |
# File 'lib/td/client/model.rb', line 349 def result_format(format, io=nil, &block) return nil unless finished? @client.job_result_format(@job_id, format, io, &block) end |
#result_size ⇒ Object
336 337 338 339 |
# File 'lib/td/client/model.rb', line 336 def result_size update_status! unless @result_size || finished? @result_size end |
#running? ⇒ Boolean
397 398 399 400 |
# File 'lib/td/client/model.rb', line 397 def running? update_progress! unless @status @status == STATUS_RUNNING end |
#start_at ⇒ Object
316 317 318 319 |
# File 'lib/td/client/model.rb', line 316 def start_at update_status! unless @start_at || finished? @start_at && !@start_at.empty? ? Time.parse(@start_at) : nil end |
#status ⇒ Object
301 302 303 304 |
# File 'lib/td/client/model.rb', line 301 def status update_status! unless @status || finished? @status end |
#success? ⇒ Boolean
377 378 379 380 |
# File 'lib/td/client/model.rb', line 377 def success? update_progress! unless @status @status == STATUS_SUCCESS end |
#update_progress! ⇒ Object
402 403 404 |
# File 'lib/td/client/model.rb', line 402 def update_progress! @status = @client.job_status(@job_id) end |
#update_status! ⇒ Object
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 |
# File 'lib/td/client/model.rb', line 406 def update_status! type, query, status, url, debug, start_at, end_at, cpu_time, result_size, result_url, hive_result_schema, priority, retry_limit, org_name, db_name = @client.api.show_job(@job_id) @query = query @status = status @url = url @debug = debug @start_at = start_at @end_at = end_at @cpu_time = cpu_time @result_size = result_size @result_url = result_url @hive_result_schema = hive_result_schema @priority = priority @retry_limit = retry_limit @db_name = db_name self end |
#url ⇒ Object
306 307 308 309 |
# File 'lib/td/client/model.rb', line 306 def url update_status! unless @url || finished? @url end |
#wait(timeout = nil) ⇒ Object
288 289 290 |
# File 'lib/td/client/model.rb', line 288 def wait(timeout=nil) # TODO end |