myreplicator 1.1.15 → 1.1.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -124,7 +124,7 @@ module Myreplicator
124
124
  if log.nil?
125
125
  return false
126
126
  else
127
- return true if log.state != "running"
127
+ return true if log.state == "completed"
128
128
  end
129
129
 
130
130
  return false
@@ -281,11 +281,11 @@ module Myreplicator
281
281
 
282
282
  def on_export_success metadata
283
283
  metadata.on_success do |m|
284
+ zipfile(metadata)
284
285
  update_export(:state => "export_completed",
285
286
  :export_finished_at => Time.now,
286
287
  :error => metadata.error)
287
288
  metadata.state = "export_completed"
288
- zipfile(metadata)
289
289
  end
290
290
  end
291
291
 
data/lib/loader/loader.rb CHANGED
@@ -293,9 +293,9 @@ module Myreplicator
293
293
  puts "&&&&&&&&&&&&&&&&&&&&&&&&&&"
294
294
  Kernel.p file
295
295
  puts "&&&&&&&&&&&&&&&&&&&&&&&&&&"
296
- if job.state == "transport_completed"
296
+ #if job.state == "transport_completed"
297
297
  result << file
298
- end
298
+ #end
299
299
  puts "^^^^^^^^^^^^^^^^^^^^^^^^^^"
300
300
  Kernel.p result
301
301
  puts "^^^^^^^^^^^^^^^^^^^^^^^^^^"
@@ -153,7 +153,7 @@ module Myreplicator
153
153
  options[:table] = options[:table_name]
154
154
  Kernel.p "===== MERGE ====="
155
155
  vertica_merge options
156
- #drop the temp table
156
+ drop the temp table
157
157
  Kernel.p "===== DROP TEMP TABLE ====="
158
158
  sql = "DROP TABLE IF EXISTS #{options[:db]}.#{options[:destination_schema]}.#{temp_table} CASCADE;"
159
159
  VerticaDb::Base.connection.execute sql
@@ -211,11 +211,11 @@ module Myreplicator
211
211
  # special case for NULL MySQL datetime/date type but the column is defined NOT NULL
212
212
  extension = file.split('.').last
213
213
  if value == '0000-00-00'
214
- cmd1 = "sed -i .dat 's/#{value}/1900-01-01/g' #{file}"
214
+ cmd1 = "sed -i 's/#{value}/1900-01-01/g' #{file}"
215
215
  Kernel.p cmd1
216
216
  system(cmd1)
217
217
  else
218
- cmd1 = "sed -i .dat 's/#{value}/#{null_value}/g' #{file}"
218
+ cmd1 = "sed -i 's/#{value}/#{null_value}/g' #{file}"
219
219
  Kernel.p cmd1
220
220
  system(cmd1)
221
221
  end
@@ -232,19 +232,14 @@ module Myreplicator
232
232
  temp_file = "tmp/temp_#{file.split('.').first.split('/').last}.txt"
233
233
 
234
234
  cmd = "gunzip -f #{file} -c > #{temp_file}"
235
+ Kernel.p cmd
235
236
  system(cmd)
236
237
  # sed
237
238
  replace_null("#{temp_file}", list_of_nulls, null_value)
238
239
  # zip
239
- cmd4 = "cp #{temp_file}.dat #{temp_file}"
240
- Kernel.p cmd4
241
- system(cmd4)
242
240
  cmd2 = "gzip #{temp_file} -c > #{file}"
243
241
  Kernel.p cmd2
244
242
  system(cmd2)
245
- cmd5 = "rm #{temp_file}.dat"
246
- Kernel.p cmd5
247
- system(cmd5)
248
243
  cmd3 = "rm #{temp_file}"
249
244
  Kernel.p cmd3
250
245
  system(cmd3)
@@ -329,7 +324,7 @@ module Myreplicator
329
324
  end
330
325
  count += 1
331
326
  end
332
- sql+= ";"
327
+ sql+= "; COMMIT;"
333
328
  cmd = "#{prepared_options[:vsql]} -h #{prepared_options[:host]} -U #{prepared_options[:user]} -w #{prepared_options[:pass]} -d #{prepared_options[:db]} -c \"#{sql}\""
334
329
  return cmd
335
330
  end
@@ -1,3 +1,3 @@
1
1
  module Myreplicator
2
- VERSION = "1.1.15"
2
+ VERSION = "1.1.16"
3
3
  end
@@ -39,7 +39,7 @@ module Myreplicator
39
39
  # downloads export files concurrently from multiple sources
40
40
  ##
41
41
  def self.transfer
42
- unique_jobs = Export.where("active = 1 and state = 'export_completed'").group("source_schema")
42
+ unique_jobs = Export.where("active = 1").group("source_schema")
43
43
  Kernel.p "===== unique_jobs ====="
44
44
  Kernel.p unique_jobs
45
45
  unique_jobs.each do |export|
@@ -105,7 +105,7 @@ module Myreplicator
105
105
  local_dump_file = File.join(tmp_dir, dump_file.split("/").last)
106
106
  sftp.download!(dump_file, local_dump_file)
107
107
  Transporter.remove!(export, json_file, dump_file)
108
- export.update_attributes!({:state => 'transport_completed'})
108
+ #export.update_attributes!({:state => 'transport_completed'})
109
109
  # store back up as well
110
110
  unless metadata.store_in.blank?
111
111
  Transporter.backup_files(metadata.backup_path, json_local_path, local_dump_file)
@@ -151,7 +151,8 @@ module Myreplicator
151
151
  return []
152
152
  end
153
153
  files = done_files.split("\n")
154
- jobs = Export.where("active = 1 and state = 'export_completed' and source_schema = '#{export.source_schema}'")
154
+
155
+ jobs = Export.where("active = 1 and source_schema = '#{export.source_schema}'")
155
156
  #jobs.each do |j|
156
157
  # j.update_attributes!({:state => "transporting"})
157
158
  #end
@@ -161,7 +162,7 @@ module Myreplicator
161
162
  jobs.each do |job|
162
163
  if file.include?(job.table_name)
163
164
  flag = job
164
- job.update_attributes!({:state => 'transporting'})
165
+ #job.update_attributes!({:state => 'transporting'})
165
166
  end
166
167
  end
167
168
  if flag
@@ -171,6 +172,10 @@ module Myreplicator
171
172
  Kernel.p "===== done_files ====="
172
173
  Kernel.p result
173
174
  return result
175
+
176
+ #Kernel.p "===== done_files ====="
177
+ #Kernel.p files
178
+ #return files
174
179
  end
175
180
 
176
181
  def self.metadata_obj json_path