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.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
- #job_id ⇒ Object readonly
-
#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
Attributes inherited from Model
Instance Method Summary collapse
- #cpu_time ⇒ String
- #debug ⇒ Boolean
- #end_at ⇒ Time?
- #error? ⇒ Boolean
- #finished? ⇒ Boolean
- #hive_result_schema ⇒ Array
-
#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, duration = nil) ⇒ Job
constructor
A new instance of Job.
- #kill! ⇒ Object
- #killed? ⇒ Boolean
- #query ⇒ String
- #queued? ⇒ Boolean
- #result ⇒ Array
- #result_each {|result| ... } ⇒ nil
- #result_each_with_compr_size {|result| ... } ⇒ nil
- #result_format(format, io = nil, &block) ⇒ nil, String
- #result_size ⇒ String
- #running? ⇒ Boolean
- #start_at ⇒ Time?
- #status ⇒ String
- #success? ⇒ Boolean
- #update_progress! ⇒ Object
- #update_status! ⇒ Object
- #url ⇒ String
- #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, duration = nil) ⇒ Job
Returns a new instance of Job.
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 |
# File 'lib/td/client/model.rb', line 385 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, duration=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 @duration = duration end |
Instance Attribute Details
#db_name ⇒ Object (readonly)
Returns the value of attribute db_name.
416 |
# File 'lib/td/client/model.rb', line 416 attr_reader :job_id, :type, :result_url |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
416 |
# File 'lib/td/client/model.rb', line 416 attr_reader :job_id, :type, :result_url |
#job_id ⇒ Object (readonly)
416 417 418 |
# File 'lib/td/client/model.rb', line 416 def job_id @job_id end |
#org_name ⇒ Object (readonly)
Returns the value of attribute org_name.
416 |
# File 'lib/td/client/model.rb', line 416 attr_reader :job_id, :type, :result_url |
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
416 |
# File 'lib/td/client/model.rb', line 416 attr_reader :job_id, :type, :result_url |
#result_url ⇒ Object (readonly)
Returns the value of attribute result_url.
416 |
# File 'lib/td/client/model.rb', line 416 attr_reader :job_id, :type, :result_url |
#retry_limit ⇒ Object (readonly)
Returns the value of attribute retry_limit.
416 |
# File 'lib/td/client/model.rb', line 416 attr_reader :job_id, :type, :result_url |
#type ⇒ Object (readonly)
416 |
# File 'lib/td/client/model.rb', line 416 attr_reader :job_id, :type, :result_url |
Instance Method Details
#cpu_time ⇒ String
465 466 467 468 |
# File 'lib/td/client/model.rb', line 465 def cpu_time update_status! unless @cpu_time || finished? @cpu_time end |
#debug ⇒ Boolean
447 448 449 450 |
# File 'lib/td/client/model.rb', line 447 def debug update_status! unless @debug || finished? @debug end |
#end_at ⇒ Time?
459 460 461 462 |
# File 'lib/td/client/model.rb', line 459 def end_at update_status! unless @end_at || finished? @end_at && !@end_at.empty? ? Time.parse(@end_at) : nil end |
#error? ⇒ Boolean
535 536 537 538 |
# File 'lib/td/client/model.rb', line 535 def error? update_progress! unless @status @status == STATUS_ERROR end |
#finished? ⇒ Boolean
523 524 525 526 |
# File 'lib/td/client/model.rb', line 523 def finished? update_progress! unless @status FINISHED_STATUS.include?(@status) end |
#hive_result_schema ⇒ Array
471 472 473 474 |
# File 'lib/td/client/model.rb', line 471 def hive_result_schema update_status! unless @hive_result_schema.instance_of? Array || finished? @hive_result_schema end |
#kill! ⇒ Object
424 425 426 |
# File 'lib/td/client/model.rb', line 424 def kill! # TODO end |
#killed? ⇒ Boolean
541 542 543 544 |
# File 'lib/td/client/model.rb', line 541 def killed? update_progress! unless @status @status == STATUS_KILLED end |
#query ⇒ String
429 430 431 432 |
# File 'lib/td/client/model.rb', line 429 def query update_status! unless @query || finished? @query end |
#queued? ⇒ Boolean
547 548 549 550 |
# File 'lib/td/client/model.rb', line 547 def queued? update_progress! unless @status @status == STATUS_QUEUED end |
#result ⇒ Array
483 484 485 486 487 488 489 |
# File 'lib/td/client/model.rb', line 483 def result unless @result return nil unless finished? @result = @client.job_result(@job_id) end @result end |
#result_each {|result| ... } ⇒ nil
513 514 515 516 517 518 519 520 |
# File 'lib/td/client/model.rb', line 513 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 {|result| ... } ⇒ nil
502 503 504 505 506 507 508 509 |
# File 'lib/td/client/model.rb', line 502 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) ⇒ nil, String
495 496 497 498 |
# File 'lib/td/client/model.rb', line 495 def result_format(format, io=nil, &block) return nil unless finished? @client.job_result_format(@job_id, format, io, &block) end |
#result_size ⇒ String
477 478 479 480 |
# File 'lib/td/client/model.rb', line 477 def result_size update_status! unless @result_size || finished? @result_size end |
#running? ⇒ Boolean
553 554 555 556 |
# File 'lib/td/client/model.rb', line 553 def running? update_progress! unless @status @status == STATUS_RUNNING end |
#start_at ⇒ Time?
453 454 455 456 |
# File 'lib/td/client/model.rb', line 453 def start_at update_status! unless @start_at || finished? @start_at && !@start_at.empty? ? Time.parse(@start_at) : nil end |
#status ⇒ String
435 436 437 438 |
# File 'lib/td/client/model.rb', line 435 def status update_status! unless @status || finished? @status end |
#success? ⇒ Boolean
529 530 531 532 |
# File 'lib/td/client/model.rb', line 529 def success? update_progress! unless @status @status == STATUS_SUCCESS end |
#update_progress! ⇒ Object
558 559 560 |
# File 'lib/td/client/model.rb', line 558 def update_progress! @status = @client.job_status(@job_id) end |
#update_status! ⇒ Object
562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 |
# File 'lib/td/client/model.rb', line 562 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 ⇒ String
441 442 443 444 |
# File 'lib/td/client/model.rb', line 441 def url update_status! unless @url || finished? @url end |
#wait(timeout = nil) ⇒ Object
420 421 422 |
# File 'lib/td/client/model.rb', line 420 def wait(timeout=nil) # TODO end |