myreplicator 1.1.43 → 1.1.44
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/loader/vertica/vertica_loader.rb +31 -27
- data/lib/myreplicator/version.rb +1 -1
- metadata +4 -4
@@ -119,7 +119,7 @@ module Myreplicator
|
|
119
119
|
Kernel.p "===== metadata.export_type ====="
|
120
120
|
Kernel.p metadata.export_type
|
121
121
|
Kernel.p options
|
122
|
-
#options = {:
|
122
|
+
#options = {:table_name => "actucast_appeal", :destination_schema => "public", :source_schema => "raw_sources"}
|
123
123
|
schema_check = Myreplicator::MysqlExporter.schema_changed?(:table => options[:table_name],
|
124
124
|
:destination_schema => options[:destination_schema],
|
125
125
|
:source_schema => options[:source_schema])
|
@@ -149,16 +149,14 @@ module Myreplicator
|
|
149
149
|
Loader.cleanup metadata #Remove incremental file
|
150
150
|
Kernel.p "===== Remove incremental file ====="
|
151
151
|
end
|
152
|
-
elsif exp.nightly_refresh && (exp.nightly_refresh_frequency != 0)
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
exp.export
|
161
|
-
end
|
152
|
+
elsif exp.nightly_refresh && (exp.nightly_refresh_frequency != 0) && ((Time.now() - exp.nightly_refresh_last_run) >= exp.nightly_refresh_frequency.minute)
|
153
|
+
Loader.clear_older_files metadata # clear old incremental files
|
154
|
+
exp.nightly_refresh_last_run = Time.now().change(:min => 0)
|
155
|
+
exp.save!
|
156
|
+
sql = "TRUNCATE TABLE #{options[:db]}.#{options[:destination_schema]}.#{options[:table_name]};"
|
157
|
+
Myreplicator::DB.exec_sql("vertica",sql)
|
158
|
+
# run the export. The next time loader runs, it will load the file
|
159
|
+
exp.export
|
162
160
|
elsif get_analyze_constraints(ops) > 0 # check for primary key/unique keys violations
|
163
161
|
Kernel.p "===== DROP CURRENT TABLE ====="
|
164
162
|
sql = "DROP TABLE IF EXISTS #{options[:db]}.#{options[:destination_schema]}.#{options[:table_name]} CASCADE;"
|
@@ -170,25 +168,31 @@ module Myreplicator
|
|
170
168
|
options[:table] = temp_table
|
171
169
|
Kernel.p "===== COPY TO TEMP TABLE #{temp_table} ====="
|
172
170
|
vertica_copy options
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
Myreplicator::DB.exec_sql("vertica",sql)
|
180
|
-
sql = "ALTER TABLE #{options[:db]}.#{options[:destination_schema]}.#{options[:temp_table]} RENAME TO \"#{options[:table]}\";"
|
181
|
-
Kernel.p sql
|
182
|
-
Myreplicator::DB.exec_sql("vertica",sql)
|
183
|
-
elsif exp.export_type == 'incremental'
|
184
|
-
options.reverse_merge!(:temp_table => "#{temp_table}")
|
185
|
-
options[:table] = options[:table_name]
|
186
|
-
Kernel.p "===== MERGE ====="
|
187
|
-
vertica_merge options
|
188
|
-
#drop the temp table
|
171
|
+
options.reverse_merge!(:temp_table => "#{temp_table}")
|
172
|
+
options[:table] = options[:table_name]
|
173
|
+
sql = "SELECT COUNT(*) FROM #{options[:db]}.#{options[:destination_schema]}.#{options[:temp_table]};"
|
174
|
+
result = Myreplicator::DB.exec_sql("vertica",sql)
|
175
|
+
#temporary fix for racing refresh cause by one worker doing loader for many export jobs. Better fix: each export job starts its own loader worker
|
176
|
+
if result.entries.first[:COUNT] == 0
|
189
177
|
Kernel.p "===== DROP TEMP TABLE ====="
|
190
178
|
sql = "DROP TABLE IF EXISTS #{options[:db]}.#{options[:destination_schema]}.#{temp_table} CASCADE;"
|
191
179
|
Myreplicator::DB.exec_sql("vertica",sql)
|
180
|
+
else
|
181
|
+
if exp.export_type == 'all'
|
182
|
+
Kernel.p "===== DROP CURRENT TABLE ====="
|
183
|
+
sql = "DROP TABLE IF EXISTS #{options[:db]}.#{options[:destination_schema]}.#{options[:table]} CASCADE;"
|
184
|
+
Myreplicator::DB.exec_sql("vertica",sql)
|
185
|
+
sql = "ALTER TABLE #{options[:db]}.#{options[:destination_schema]}.#{options[:temp_table]} RENAME TO \"#{options[:table]}\";"
|
186
|
+
Kernel.p sql
|
187
|
+
Myreplicator::DB.exec_sql("vertica",sql)
|
188
|
+
elsif exp.export_type == 'incremental'
|
189
|
+
Kernel.p "===== MERGE ====="
|
190
|
+
vertica_merge options
|
191
|
+
#drop the temp table
|
192
|
+
Kernel.p "===== DROP TEMP TABLE ====="
|
193
|
+
sql = "DROP TABLE IF EXISTS #{options[:db]}.#{options[:destination_schema]}.#{temp_table} CASCADE;"
|
194
|
+
Myreplicator::DB.exec_sql("vertica",sql)
|
195
|
+
end
|
192
196
|
end
|
193
197
|
end
|
194
198
|
end
|
data/lib/myreplicator/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: myreplicator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.44
|
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-05-
|
12
|
+
date: 2013-05-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -298,7 +298,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
298
298
|
version: '0'
|
299
299
|
segments:
|
300
300
|
- 0
|
301
|
-
hash: -
|
301
|
+
hash: -1682626861292050553
|
302
302
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
303
303
|
none: false
|
304
304
|
requirements:
|
@@ -307,7 +307,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
307
307
|
version: '0'
|
308
308
|
segments:
|
309
309
|
- 0
|
310
|
-
hash: -
|
310
|
+
hash: -1682626861292050553
|
311
311
|
requirements: []
|
312
312
|
rubyforge_project:
|
313
313
|
rubygems_version: 1.8.24
|