td-client 0.8.41 → 0.8.42

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,9 @@
1
+ == 2012-01-16 version 0.8.42
2
+
3
+ * Added retry_limit to job and schedule APIs
4
+ * Increased table/database name limit from 32 to 256
5
+
6
+
1
7
  == 2012-01-10 version 0.8.41
2
8
 
3
9
  * Fix API#job_result_format to handle Content-Encoding properly
@@ -120,31 +120,31 @@ class Client
120
120
  end
121
121
 
122
122
  # => Job
123
- def query(db_name, q, result_url=nil, priority=nil)
124
- job_id = @api.hive_query(q, db_name, result_url, priority)
123
+ def query(db_name, q, result_url=nil, priority=nil, retry_limit=nil)
124
+ job_id = @api.hive_query(q, db_name, result_url, priority, retry_limit)
125
125
  Job.new(self, job_id, :hive, q)
126
126
  end
127
127
 
128
128
  # => [Job]
129
129
  def jobs(from=nil, to=nil, status=nil, conditions=nil)
130
130
  result = @api.list_jobs(from, to, status, conditions)
131
- result.map {|job_id,type,status,query,start_at,end_at,result_url,priority,org,db|
132
- Job.new(self, job_id, type, query, status, nil, nil, start_at, end_at, nil, result_url, nil, priority, org, db)
131
+ result.map {|job_id,type,status,query,start_at,end_at,result_url,priority,retry_limit,org,db|
132
+ Job.new(self, job_id, type, query, status, nil, nil, start_at, end_at, nil, result_url, nil, priority, retry_limit, org, db)
133
133
  }
134
134
  end
135
135
 
136
136
  # => Job
137
137
  def job(job_id)
138
138
  job_id = job_id.to_s
139
- type, query, status, url, debug, start_at, end_at, result_url, hive_result_schema, priority, org, db = @api.show_job(job_id)
140
- Job.new(self, job_id, type, query, status, url, debug, start_at, end_at, nil, result_url, hive_result_schema, priority, org, db)
139
+ type, query, status, url, debug, start_at, end_at, result_url, hive_result_schema, priority, retry_limit, org, db = @api.show_job(job_id)
140
+ Job.new(self, job_id, type, query, status, url, debug, start_at, end_at, nil, result_url, hive_result_schema, priority, retry_limit, org, db)
141
141
  end
142
142
 
143
143
  # => type:Symbol, url:String
144
144
  def job_status(job_id)
145
145
  # use v3/job/status instead of v3/job/show to poll finish of a job
146
- type, query, status, url, debug, start_at, end_at, result_url, hive_result_schema, priority, org, db = @api.show_job(job_id)
147
- return query, status, url, debug, start_at, end_at, result_url, hive_result_schema, priority, org, db
146
+ type, query, status, url, debug, start_at, end_at, result_url, hive_result_schema, priority, retry_limit, org, db = @api.show_job(job_id)
147
+ return query, status, url, debug, start_at, end_at, result_url, hive_result_schema, priority, retry_limit, org, db
148
148
  end
149
149
 
150
150
  # => result:[{column:String=>value:Object]
@@ -252,8 +252,8 @@ class Client
252
252
  # [Schedule]
253
253
  def schedules
254
254
  result = @api.list_schedules
255
- result.map {|name,cron,query,database,result_url,timezone,delay,next_time,priority,org_name|
256
- Schedule.new(self, name, cron, query, database, result_url, timezone, delay, next_time, priority, org_name)
255
+ result.map {|name,cron,query,database,result_url,timezone,delay,next_time,priority,retry_limit,org_name|
256
+ Schedule.new(self, name, cron, query, database, result_url, timezone, delay, next_time, priority, retry_limit, org_name)
257
257
  }
258
258
  end
259
259
 
@@ -267,7 +267,7 @@ class Client
267
267
  result = @api.history(name, from, to)
268
268
  result.map {|scheduled_at,job_id,type,status,query,start_at,end_at,result_url,priority,database|
269
269
  # TODO org
270
- ScheduledJob.new(self, scheduled_at, job_id, type, query, status, nil, nil, start_at, end_at, nil, result_url, nil, priority,nil,database)
270
+ ScheduledJob.new(self, scheduled_at, job_id, type, query, status, nil, nil, start_at, end_at, nil, result_url, nil, priority,nil,nil,database)
271
271
  }
272
272
  end
273
273
 
@@ -115,8 +115,8 @@ class API
115
115
  if name.length < 3
116
116
  name += "_"*(3-name.length)
117
117
  end
118
- if 32 < name.length
119
- name = name[0,30]+"__"
118
+ if 256 < name.length
119
+ name = name[0,254]+"__"
120
120
  end
121
121
  name = name.downcase
122
122
  name = name.gsub(/[^a-z0-9_]/, '_')
@@ -359,8 +359,9 @@ class API
359
359
  end_at = m['end_at']
360
360
  result_url = m['result']
361
361
  priority = m['priority']
362
+ retry_limit = m['retry_limit']
362
363
  organization = m['organization']
363
- result << [job_id, type, status, query, start_at, end_at, result_url, priority, organization, database]
364
+ result << [job_id, type, status, query, start_at, end_at, result_url, priority, retry_limit, organization, database]
364
365
  }
365
366
  return result
366
367
  end
@@ -390,8 +391,9 @@ class API
390
391
  hive_result_schema = JSON.parse(hive_result_schema)
391
392
  end
392
393
  priority = js['priority']
394
+ retry_limit = js['retry_limit']
393
395
  organization = js['organization']
394
- return [type, query, status, url, debug, start_at, end_at, result, hive_result_schema, priority, organization, database]
396
+ return [type, query, status, url, debug, start_at, end_at, result, hive_result_schema, priority, retry_limit, organization, database]
395
397
  end
396
398
 
397
399
  def job_result(job_id)
@@ -460,10 +462,11 @@ class API
460
462
  end
461
463
 
462
464
  # => jobId:String
463
- def hive_query(q, db=nil, result_url=nil, priority=nil)
465
+ def hive_query(q, db=nil, result_url=nil, priority=nil, retry_limit=nil)
464
466
  params = {'query' => q}
465
467
  params['result'] = result_url if result_url
466
468
  params['priority'] = priority if priority
469
+ params['retry_limit'] = retry_limit if retry_limit
467
470
  code, body, res = post("/v3/job/issue/hive/#{e db}", params)
468
471
  if code != "200"
469
472
  raise_error("Query failed", res)
@@ -690,8 +693,9 @@ class API
690
693
  delay = m['delay']
691
694
  next_time = m['next_time']
692
695
  priority = m['priority']
696
+ retry_limit = m['retry_limit']
693
697
  organization = m['organization']
694
- result << [name, cron, query, database, result_url, timezone, delay, next_time, priority, organization]
698
+ result << [name, cron, query, database, result_url, timezone, delay, next_time, priority, retry_limit, organization]
695
699
  }
696
700
  return result
697
701
  end
@@ -226,7 +226,7 @@ class Job < Model
226
226
  STATUS_KILLED = "killed"
227
227
  FINISHED_STATUS = [STATUS_SUCCESS, STATUS_ERROR, STATUS_KILLED]
228
228
 
229
- def initialize(client, job_id, type, query, status=nil, url=nil, debug=nil, start_at=nil, end_at=nil, result=nil, result_url=nil, hive_result_schema=nil, priority=nil, org_name=nil, db_name=nil)
229
+ def initialize(client, job_id, type, query, status=nil, url=nil, debug=nil, start_at=nil, end_at=nil, result=nil, result_url=nil, hive_result_schema=nil, priority=nil, retry_limit=nil, org_name=nil, db_name=nil)
230
230
  super(client)
231
231
  @job_id = job_id
232
232
  @type = type
@@ -240,12 +240,13 @@ class Job < Model
240
240
  @result_url = result_url
241
241
  @hive_result_schema = hive_result_schema
242
242
  @priority = priority
243
+ @retry_limit = retry_limit
243
244
  @org_name = org_name
244
245
  @db_name = db_name
245
246
  end
246
247
 
247
248
  attr_reader :job_id, :type, :result_url
248
- attr_reader :hive_result_schema, :priority, :org_name, :db_name
249
+ attr_reader :hive_result_schema, :priority, :retry_limit, :org_name, :db_name
249
250
 
250
251
  def wait(timeout=nil)
251
252
  # TODO
@@ -336,7 +337,7 @@ class Job < Model
336
337
  end
337
338
 
338
339
  def update_status!
339
- query, status, url, debug, start_at, end_at, result_url, hive_result_schema, priority, org_name, db_name = @client.job_status(@job_id)
340
+ query, status, url, debug, start_at, end_at, result_url, hive_result_schema, priority, retry_limit, org_name, db_name = @client.job_status(@job_id)
340
341
  @query = query
341
342
  @status = status
342
343
  @url = url
@@ -344,6 +345,8 @@ class Job < Model
344
345
  @start_at = start_at
345
346
  @end_at = end_at
346
347
  @hive_result_schema = hive_result_schema
348
+ @priority = priority
349
+ @retry_limit = retry_limit
347
350
  @org_name = org_name
348
351
  @db_name = db_name
349
352
  self
@@ -364,7 +367,7 @@ end
364
367
 
365
368
 
366
369
  class Schedule < Model
367
- def initialize(client, name, cron, query, database=nil, result_url=nil, timezone=nil, delay=nil, next_time=nil, priority=nil, org_name=nil)
370
+ def initialize(client, name, cron, query, database=nil, result_url=nil, timezone=nil, delay=nil, next_time=nil, priority=nil, retry_limit=nil, org_name=nil)
368
371
  super(client)
369
372
  @name = name
370
373
  @cron = cron
@@ -375,10 +378,11 @@ class Schedule < Model
375
378
  @delay = delay
376
379
  @next_time = next_time
377
380
  @priority = priority
381
+ @retry_limit = retry_limit
378
382
  @org_name = org_name
379
383
  end
380
384
 
381
- attr_reader :name, :cron, :query, :database, :result_url, :timezone, :delay, :priority, :org_name
385
+ attr_reader :name, :cron, :query, :database, :result_url, :timezone, :delay, :priority, :retry_limit, :org_name
382
386
 
383
387
  def next_time
384
388
  @next_time ? Time.parse(@next_time) : nil
@@ -1,5 +1,5 @@
1
1
  module TreasureData
2
2
 
3
- VERSION = '0.8.41'
3
+ VERSION = '0.8.42'
4
4
 
5
5
  end
@@ -12,7 +12,7 @@ describe API do
12
12
 
13
13
  INVALID_NAMES = {
14
14
  'a' => 'a__',
15
- 'a'*33 => 'a'*30+'__',
15
+ 'a'*257 => 'a'*254+'__',
16
16
  'abcD' => 'abcd',
17
17
  'a-b*' => 'a_b_',
18
18
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: td-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.41
4
+ version: 0.8.42
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-09 00:00:00.000000000 Z
12
+ date: 2013-01-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: msgpack