embulk-output-vertica 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d6a6bc55961d3c9ee7f0eeac61c4c845f408fe43
4
- data.tar.gz: 709e04e684eeeadc11b461e834a8406de183f1d5
3
+ metadata.gz: ffcbf6b8e38f5b340f40ef6276d1d60eec24e7d1
4
+ data.tar.gz: 1db857854d517fa3121c212e779cc7cb7fd1a888
5
5
  SHA512:
6
- metadata.gz: 3a7a9383471db1bfb5c4b2f8d05d0dcbdd9e6f731bad883c03c17167cba706a9ea99c75f8eda99b5c622b247ccca7846245b3f8ee2e82d28482a775722dd242d
7
- data.tar.gz: 01f088c282721e8f231fa58574f2ac3459780e7ef0af274c78f6d7e45e7a6665314d58b3597492fafa072a95fed39e13d9e6a124834cfa37195cf5688789f311
6
+ metadata.gz: 465771451e26a38c2d50278422aec461856b3301cc0dc4bf3a06a57e4520723c88a75abfa94e284e0195903015404d32377555722fc92a3e7c0a5a85004a8fb5
7
+ data.tar.gz: 0eed14f90d9a8ea9e3080282a653e90f90120fdb347f2cd5958d6e11f497b75d95e656bc2174559ba93452c0324194cc33b5c3d976350b0f27944cd52ce087f5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # 0.5.2 (2016/01/09)
2
+
3
+ Fixes:
4
+
5
+ * Add nil check for timestamp converter
6
+ * Fix error handling of output thread
7
+
1
8
  # 0.5.1 (2015/12/04)
2
9
 
3
10
  Fixes:
data/Gemfile CHANGED
@@ -1,7 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
- gem 'embulk'
5
4
  gem 'embulk-input-random'
6
5
  gem 'embulk-filter-stdout'
7
6
  gem 'pry'
data/README.md CHANGED
@@ -71,8 +71,8 @@ out:
71
71
  Run example:
72
72
 
73
73
  ```
74
- $ bundle install
75
- $ bundle exec embulk run -l debug example.yml
74
+ $ embulk bundle install --path vendor/bundle
75
+ $ embulk -J-O -R--dev run -b . run -l debug example.yml
76
76
  ```
77
77
 
78
78
  Release gem:
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "embulk-output-vertica"
3
- spec.version = "0.5.1"
3
+ spec.version = "0.5.2"
4
4
  spec.authors = ["eiji.sekiya", "Naotoshi Seo"]
5
5
  spec.email = ["eiji.sekiya.0326@gmail.com", "sonots@gmail.com"]
6
6
  spec.summary = "Vertica output plugin for Embulk"
@@ -35,15 +35,17 @@ module Embulk
35
35
  @num_input_rows = 0
36
36
  @num_output_rows = 0
37
37
  @num_rejected_rows = 0
38
+ @outer_thread = Thread.current
39
+ @thread_active = false
38
40
  end
39
41
 
40
42
  def enqueue(page)
41
- if @thread.status.nil? # thread died by an error
42
- @thread.join # raise the same error raised inside thread
43
- end
44
- if @thread.alive?
43
+ if @thread_active and @thread.alive?
45
44
  Embulk.logger.trace { "embulk-output-vertica: enqueued" }
46
45
  @queue.push(page)
46
+ else
47
+ Embulk.logger.info { "embulk-output-vertica: thread is dead, but still trying to enqueue" }
48
+ raise RuntimeError, "embulk-output-vertica: thread is died, but still trying to enqueue"
47
49
  end
48
50
  end
49
51
 
@@ -81,18 +83,34 @@ module Embulk
81
83
  Embulk.logger.warn "embulk-output-vertica: ROLLBACK!"
82
84
  end
83
85
  raise e # die transaction
86
+ rescue => e
87
+ Embulk.logger.warn "embulk-output-vertica: ROLLBACK!"
88
+ jv.rollback
89
+ raise e
84
90
  end
85
91
  end
92
+ rescue => e
93
+ @thread_active = false # not to be enqueued any more
94
+ while @queue.size > 0
95
+ @queue.pop # dequeue all because some might be still trying @queue.push and get blocked, need to release
96
+ end
97
+ @outer_thread.raise e.class.new("#{e.message}\n #{e.backtrace.join("\n ")}")
86
98
  end
87
99
 
88
100
  def start
89
101
  @thread = Thread.new(&method(:run))
102
+ @thread_active = true
90
103
  end
91
104
 
92
105
  def commit
93
- @queue.push('finish') if @thread.alive?
94
- Thread.pass
95
- @thread.join # the same error with run would be raised at here
106
+ @thread_active = false
107
+ if @thread.alive?
108
+ @queue.push('finish')
109
+ Thread.pass
110
+ @thread.join
111
+ else
112
+ raise RuntimeError, "embulk-output-vertica: thread died accidently"
113
+ end
96
114
 
97
115
  task_report = {
98
116
  'num_input_rows' => @num_input_rows,
@@ -61,7 +61,7 @@ module Embulk
61
61
  when 'long' then Proc.new {|val| val }
62
62
  when 'double' then Proc.new {|val| val.to_f }
63
63
  when 'string' then Proc.new {|val| val.to_s }
64
- when 'timestamp' then Proc.new {|val| Time.at(val).localtime(zone_offset) }
64
+ when 'timestamp' then Proc.new {|val| val ? Time.at(val).localtime(zone_offset) : nil }
65
65
  else raise NotSupportedType, "embulk-output-vertica cannot take column value_type #{value_type} for long column"
66
66
  end
67
67
  end
@@ -72,7 +72,7 @@ module Embulk
72
72
  when 'long' then Proc.new {|val| val.to_i }
73
73
  when 'double' then Proc.new {|val| val }
74
74
  when 'string' then Proc.new {|val| val.to_s }
75
- when 'timestamp' then Proc.new {|val| Time.at(val).localtime(zone_offset) }
75
+ when 'timestamp' then Proc.new {|val| val ? Time.at(val).localtime(zone_offset) : nil }
76
76
  else raise NotSupportedType, "embulk-output-vertica cannot take column value_type #{value_type} for double column"
77
77
  end
78
78
  end
@@ -83,7 +83,7 @@ module Embulk
83
83
  when 'long' then Proc.new {|val| val.to_i }
84
84
  when 'double' then Proc.new {|val| val.to_f }
85
85
  when 'string' then Proc.new {|val| val }
86
- when 'timestamp' then Proc.new {|val| strptime_with_zone(val, timestamp_format, zone_offset) }
86
+ when 'timestamp' then Proc.new {|val| val ? strptime_with_zone(val, timestamp_format, zone_offset) : nil }
87
87
  else raise NotSupportedType, "embulk-output-vertica cannot take column value_type #{value_type} for string column"
88
88
  end
89
89
  end
@@ -93,8 +93,8 @@ module Embulk
93
93
  when 'boolean' then Proc.new {|val| !!val }
94
94
  when 'long' then Proc.new {|val| val.to_i }
95
95
  when 'double' then Proc.new {|val| val.to_f }
96
- when 'string' then Proc.new {|val| val.localtime(zone_offset).strftime(timestamp_format) }
97
- when 'timestamp' then Proc.new {|val| val.localtime(zone_offset) }
96
+ when 'string' then Proc.new {|val| val ? val.localtime(zone_offset).strftime(timestamp_format) : nil }
97
+ when 'timestamp' then Proc.new {|val| val ? val.localtime(zone_offset) : nil }
98
98
  else raise NotSupportedType, "embulk-output-vertica cannot take column value_type #{value_type} for timesatmp column"
99
99
  end
100
100
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-output-vertica
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - eiji.sekiya
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-12-04 00:00:00.000000000 Z
12
+ date: 2016-01-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jvertica