sdbcli 1.1.0 → 1.1.1
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/README +1 -1
- data/bin/sdbcli +19 -9
- metadata +1 -1
data/README
CHANGED
@@ -23,7 +23,7 @@ https://bitbucket.org/winebarrel/sdbcli
|
|
23
23
|
--import=DOMAIN,FILE
|
24
24
|
--import-replace=DOMAIN,FILE
|
25
25
|
--export=DOMAIN,FILE
|
26
|
-
--
|
26
|
+
--retry=NUM
|
27
27
|
shell> export AWS_ACCESS_KEY_ID='...'
|
28
28
|
shell> export AWS_SECRET_ACCESS_KEY='...'
|
29
29
|
shell> export SDB_ENDPOINT='sdb.ap-northeast-1.amazonaws.com' # or SDB_REGION=ap-northeast-1
|
data/bin/sdbcli
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
3
3
|
|
4
|
-
Version = '1.1.
|
4
|
+
Version = '1.1.1'
|
5
5
|
HISTORY_FILE = File.join((ENV['HOME'] || ENV['USERPROFILE'] || '.'), '.sdbcli_history')
|
6
6
|
HISTSIZE = 500
|
7
7
|
SELECT_LIMIT = 2500
|
@@ -24,7 +24,7 @@ $format = :yaml
|
|
24
24
|
$consistent = false
|
25
25
|
import = nil
|
26
26
|
export = nil
|
27
|
-
|
27
|
+
import_export_retry = 3
|
28
28
|
timeout = 60
|
29
29
|
|
30
30
|
ARGV.options do |opt|
|
@@ -38,7 +38,7 @@ ARGV.options do |opt|
|
|
38
38
|
opt.on('' , '--import=DOMAIN,FILE') {|v| import = v.split(/\s*,\s*/, 2) + [false] }
|
39
39
|
opt.on('' , '--import-replace=DOMAIN,FILE') {|v| import = v.split(/\s*,\s*/, 2) + [true] }
|
40
40
|
opt.on('' , '--export=DOMAIN,FILE') {|v| export = v.split(/\s*,\s*/, 2) }
|
41
|
-
opt.on('' , '--
|
41
|
+
opt.on('' , '--retry=NUM', Integer) {|v| import_export_retry = v.to_i }
|
42
42
|
opt.parse!
|
43
43
|
|
44
44
|
unless access_key_id and secret_access_key and sdb_endpoint
|
@@ -184,12 +184,12 @@ if export
|
|
184
184
|
loop do
|
185
185
|
items = nil
|
186
186
|
|
187
|
-
|
187
|
+
import_export_retry.times do |i|
|
188
188
|
begin
|
189
189
|
items = $runner.execute(query + query_expr, true, $consistent)
|
190
190
|
break
|
191
191
|
rescue Timeout::Error => e
|
192
|
-
raise e if i >= (
|
192
|
+
raise e if i >= (import_export_retry - 1)
|
193
193
|
end
|
194
194
|
|
195
195
|
output_error("Retry...", true)
|
@@ -281,10 +281,20 @@ if import
|
|
281
281
|
until (chunk = items.slice!(0, SELECT_LIMIT)).empty?
|
282
282
|
rownum += chunk.length
|
283
283
|
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
284
|
+
import_export_retry.times do |i|
|
285
|
+
begin
|
286
|
+
if import_as_replace
|
287
|
+
$runner.driver.update(import_domain, chunk)
|
288
|
+
else
|
289
|
+
$runner.driver.insert(import_domain, chunk)
|
290
|
+
end
|
291
|
+
|
292
|
+
break
|
293
|
+
rescue Timeout::Error => e
|
294
|
+
raise e if i >= (import_export_retry - 1)
|
295
|
+
end
|
296
|
+
|
297
|
+
output_error("Retry...", true)
|
288
298
|
end
|
289
299
|
|
290
300
|
output_error("#{rownum} #{rownum > 1 ? 'rows' : 'row'} was inputted...", true)
|