Class: DruidConfig::Entities::Task

Inherits:
Object
  • Object
show all
Includes:
Util, HTTParty
Defined in:
lib/druid_config/entities/task.rb

Overview

Init a DataSource

Constant Summary collapse

STATUS =

Statuses constants

{
  running: 'RUNNING',
  pending: 'PENDING',
  success: 'SUCCESS',
  waiting: 'WAITING',
  failed: 'FAILED'
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util

#pop_uri, #query_overlord, #secure_query, #stash_uri

Constructor Details

#initialize(id, status, extended_info = {}) ⇒ Task

Initialize a task

Parameters:

id

String with identifier

status

Current status of the task



46
47
48
49
50
51
52
53
54
55
# File 'lib/druid_config/entities/task.rb', line 46

def initialize(id, status, extended_info = {})
  @id = id
  @status = status.downcase.to_sym
  @created_time = extended_info[:created_time]
  @query_insertion_time = extended_info[:query_insertion_time]
  # Set end point for HTTParty
  self.class.base_uri(
    "#{DruidConfig.client.overlord}"\
    "druid/indexer/#{DruidConfig::Version::API_VERSION}/task")
end

Instance Attribute Details

#created_timeObject (readonly)

Returns the value of attribute created_time.



22
23
24
# File 'lib/druid_config/entities/task.rb', line 22

def created_time
  @created_time
end

#idObject (readonly)

Returns the value of attribute id.



22
23
24
# File 'lib/druid_config/entities/task.rb', line 22

def id
  @id
end

#query_insertion_timeObject (readonly)

Returns the value of attribute query_insertion_time.



22
23
24
# File 'lib/druid_config/entities/task.rb', line 22

def query_insertion_time
  @query_insertion_time
end

#statusObject (readonly)

Returns the value of attribute status.



22
23
24
# File 'lib/druid_config/entities/task.rb', line 22

def status
  @status
end

Class Method Details

.find(id) ⇒ Object

Find a task based on id



27
28
29
30
31
32
33
34
35
# File 'lib/druid_config/entities/task.rb', line 27

def self.find(id)
  # Set end point for HTTParty
  base_uri(
    "#{DruidConfig.client.overlord}"\
    "druid/indexer/#{DruidConfig::Version::API_VERSION}/task")
  # Get data
  status = get("/#{id}/status")
  new(id, status['status']['status'])
end

Instance Method Details

#datasourceObject

Get the dataSource of this task



85
86
87
# File 'lib/druid_config/entities/task.rb', line 85

def datasource
  payload['dataSource']
end

#group_idObject

Group of the task



92
93
94
# File 'lib/druid_config/entities/task.rb', line 92

def group_id
  payload['groupId']
end

#logObject

Current log of a task



78
79
80
# File 'lib/druid_config/entities/task.rb', line 78

def log
  self.class.get("/#{@id}/log")
end

#payloadObject

Get payload of the task



71
72
73
# File 'lib/druid_config/entities/task.rb', line 71

def payload
  @payload ||= self.class.get("/#{@id}")['payload']
end