td 0.10.17 → 0.10.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +6 -0
- data/lib/td/command/list.rb +1 -0
- data/lib/td/command/sched.rb +8 -2
- data/lib/td/command/table.rb +61 -0
- data/lib/td/version.rb +1 -1
- metadata +13 -13
data/ChangeLog
CHANGED
data/lib/td/command/list.rb
CHANGED
@@ -220,6 +220,7 @@ module List
|
|
220
220
|
add_list 'table:create', %w[db table], 'Create a table', 'table:create example_db table1'
|
221
221
|
add_list 'table:delete', %w[db table], 'Delete a table', 'table:delete example_db table1'
|
222
222
|
add_list 'table:import', %w[db table files_], 'Parse and import files to a table', 'table:import example_db table1 --apache access.log', 'table:import example_db table1 --json -t time - < test.json'
|
223
|
+
add_list 'table:export', %w[db table], 'Dump logs in a table to the specified storage', 'table:export example_db table1 --s3-bucket mybucket'
|
223
224
|
add_list 'table:tail', %w[db table], 'Get recently imported logs', 'table:tail example_db table1', 'table:tail example_db table1 -t "2011-01-02 03:04:05" -n 30'
|
224
225
|
|
225
226
|
add_list 'result:info', %w[], 'Show information of the MySQL server', 'result:info'
|
data/lib/td/command/sched.rb
CHANGED
@@ -210,14 +210,20 @@ module Command
|
|
210
210
|
client = get_client
|
211
211
|
|
212
212
|
begin
|
213
|
-
client.run_schedule(name, t.to_i, num)
|
213
|
+
jobs = client.run_schedule(name, t.to_i, num)
|
214
214
|
rescue NotFoundError
|
215
215
|
cmd_debug_error $!
|
216
216
|
$stderr.puts "Schedule '#{name}' does not exist."
|
217
217
|
$stderr.puts "Use '#{$prog} sched:list' to show list of the schedules."
|
218
218
|
end
|
219
219
|
|
220
|
-
|
220
|
+
rows = []
|
221
|
+
jobs.each_with_index {|job,i|
|
222
|
+
rows << {:JobID => job.job_id, :Time => job.scheduled_at ? job.scheduled_at.localtime : nil}
|
223
|
+
}
|
224
|
+
|
225
|
+
$stderr.puts "Scheduled #{num} jobs from #{t}."
|
226
|
+
puts cmd_render_table(rows, :fields => [:JobID, :Time], :max_width=>500)
|
221
227
|
end
|
222
228
|
|
223
229
|
end
|
data/lib/td/command/table.rb
CHANGED
@@ -135,6 +135,7 @@ module Command
|
|
135
135
|
if s.to_i.to_s == s
|
136
136
|
to = s
|
137
137
|
else
|
138
|
+
require 'time'
|
138
139
|
to = Time.parse(s).to_i
|
139
140
|
end
|
140
141
|
}
|
@@ -142,6 +143,7 @@ module Command
|
|
142
143
|
if s.to_i.to_s == s
|
143
144
|
from = s
|
144
145
|
else
|
146
|
+
require 'time'
|
145
147
|
from = Time.parse(s).to_i
|
146
148
|
end
|
147
149
|
}
|
@@ -178,7 +180,66 @@ module Command
|
|
178
180
|
}
|
179
181
|
end
|
180
182
|
|
183
|
+
def table_export(op)
|
184
|
+
from = nil
|
185
|
+
to = nil
|
186
|
+
s3_bucket = nil
|
187
|
+
wait = false
|
188
|
+
|
189
|
+
## TODO
|
190
|
+
#op.on('-t', '--to TIME', 'end time of logs to get') {|s|
|
191
|
+
# if s.to_i.to_s == s
|
192
|
+
# to = s
|
193
|
+
# else
|
194
|
+
# require 'time'
|
195
|
+
# to = Time.parse(s).to_i
|
196
|
+
# end
|
197
|
+
#}
|
198
|
+
#op.on('-f', '--from TIME', 'start time of logs to get') {|s|
|
199
|
+
# if s.to_i.to_s == s
|
200
|
+
# from = s
|
201
|
+
# else
|
202
|
+
# require 'time'
|
203
|
+
# from = Time.parse(s).to_i
|
204
|
+
# end
|
205
|
+
#}
|
206
|
+
op.on('-w', '--wait', 'wait for finishing the job', TrueClass) {|b|
|
207
|
+
wait = b
|
208
|
+
}
|
209
|
+
op.on('--s3-bucket NAME', 'name of the s3 bucket to output') {|s|
|
210
|
+
s3_bucket = s
|
211
|
+
}
|
212
|
+
|
213
|
+
db_name, table_name = op.cmd_parse
|
214
|
+
|
215
|
+
unless s3_bucket
|
216
|
+
$stderr.puts "--s3-bucket NAME option is required"
|
217
|
+
exit 1
|
218
|
+
end
|
219
|
+
|
220
|
+
client = get_client
|
221
|
+
|
222
|
+
table = get_table(client, db_name, table_name)
|
223
|
+
|
224
|
+
opts = {}
|
225
|
+
opts['s3_bucket'] = s3_bucket
|
226
|
+
opts['s3_file_format'] ='json.gz'
|
227
|
+
opts['from'] = from.to_s if from
|
228
|
+
opts['to'] = to.to_s if to
|
229
|
+
|
230
|
+
job = table.export('s3', opts)
|
231
|
+
|
232
|
+
$stderr.puts "Export job #{job.job_id} is queued."
|
233
|
+
$stderr.puts "Use '#{$prog} job:show #{job.job_id}' to show the status."
|
234
|
+
|
235
|
+
if wait && !job.finished?
|
236
|
+
wait_job(job)
|
237
|
+
puts "Status : #{job.status}"
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
181
241
|
require 'td/command/import' # table:import
|
242
|
+
require 'td/command/job' # wait_job
|
182
243
|
end
|
183
244
|
end
|
184
245
|
|
data/lib/td/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: td
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.18
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-03-
|
12
|
+
date: 2012-03-12 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: msgpack
|
16
|
-
requirement: &
|
16
|
+
requirement: &70130919020280 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.4.4
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70130919020280
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: json
|
27
|
-
requirement: &
|
27
|
+
requirement: &70130919019400 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.4.3
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70130919019400
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: hirb
|
38
|
-
requirement: &
|
38
|
+
requirement: &70130918961080 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,21 +43,21 @@ dependencies:
|
|
43
43
|
version: 0.4.5
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70130918961080
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: td-client
|
49
|
-
requirement: &
|
49
|
+
requirement: &70130918953380 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.8.
|
54
|
+
version: 0.8.12
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70130918953380
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: td-logger
|
60
|
-
requirement: &
|
60
|
+
requirement: &70130918942840 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: 0.3.8
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70130918942840
|
69
69
|
description:
|
70
70
|
email:
|
71
71
|
executables:
|