myreplicator 1.1.49 → 1.1.50

Sign up to get free protection for your applications and to get access to all the features.
@@ -97,6 +97,13 @@ module Myreplicator
97
97
  format.json { head :no_content }
98
98
  end
99
99
  end
100
+
101
+ def reload
102
+ @export = Export.find(params[:id])
103
+ flash[:notice] = "'#{@export.destination_schema}.#{@export.table_name}' is reloading"
104
+ @export.reload
105
+ redirect_to :action => 'show'
106
+ end
100
107
 
101
108
  private
102
109
 
@@ -44,10 +44,30 @@ module Myreplicator
44
44
  export_obj.export
45
45
  end
46
46
 
47
- end
47
+ end
48
48
 
49
- ##
50
- # Runs the export process using the required Exporter library
49
+ def reload
50
+ Log.run(:job_type => "export", :name => schedule_name,
51
+ :file => filename, :export_id => id) do |log|
52
+ # TRUNCATE TABLE & Rest incremental value if there is any
53
+ sql = "TRUNCATE TABLE '#{@export.destination_schema}'.'#{@export.table_name}';"
54
+ if self.export_to == "vertica"
55
+ Myreplicator::DB.exec_sql("vertica",sql)
56
+ else
57
+ Myreplicator::DB.exec_sql("#{@export.destination_schema}",sql)
58
+ end
59
+
60
+ if self.export_type != "all"
61
+ self.max_incremental_value = nil
62
+ self.save!
63
+ end
64
+
65
+ exporter = MysqlExporter.new
66
+ exporter.export_table self # pass current object to exporter
67
+ end
68
+ end
69
+ ##
70
+ # Runs the export process using the required Exporter library
51
71
  ##
52
72
  def export
53
73
  Log.run(:job_type => "export", :name => schedule_name,
@@ -19,6 +19,7 @@
19
19
  <th><%= sortable "s3_path" %></th>
20
20
  <th><%= sortable "cron" %></th>
21
21
  <th class="center">Actions</th>
22
+ <th class="center">Utils</th>
22
23
  </tr>
23
24
  </thead>
24
25
  <tbody>
@@ -40,6 +41,9 @@
40
41
  <%= link_to 'edit', edit_export_path(export), :class => 'action edit' %>
41
42
  <%= link_to 'destroy', export, method: :delete, data: { confirm: 'Are you sure?' }, :class=> 'action delete' %>
42
43
  </td>
44
+ <td>
45
+ <%= link_to 'reload', reload_export_path(export), :class=> 'action edit' %>
46
+ </td>
43
47
  </tr>
44
48
  <% end %>
45
49
  </tbody>
data/config/routes.rb CHANGED
@@ -8,4 +8,10 @@ Myreplicator::Engine.routes.draw do
8
8
  get :pause, :on => :collection
9
9
  get :resume, :on => :collection
10
10
  end
11
+
12
+ resources :exports do
13
+ member do
14
+ get 'reload'
15
+ end
16
+ end
11
17
  end
@@ -191,6 +191,7 @@ module Myreplicator
191
191
  # Echo is used for writing the file
192
192
  ##
193
193
  def store!
194
+ Kernel.p "$$$$$$$$$$$$$$$$$$ @ssh CHECK $$$$$$$$$$$$$$$$$$"
194
195
  cmd = "echo \"#{self.to_json.gsub("\"","\\\\\"")}\" > #{@filepath}.json"
195
196
  puts cmd
196
197
  result = @ssh.exec!(cmd)
@@ -1,3 +1,3 @@
1
1
  module Myreplicator
2
- VERSION = "1.1.49"
2
+ VERSION = "1.1.50"
3
3
  end
@@ -40,7 +40,7 @@ module Myreplicator
40
40
  # downloads export files concurrently from multiple sources
41
41
  ##
42
42
  def self.transfer
43
- unique_jobs = Export.where("active = 1").group("source_schema")
43
+ unique_jobs = Myreplicator::Export.where("active = 1").group("source_schema")
44
44
  Kernel.p "===== unique_jobs ====="
45
45
  Kernel.p unique_jobs
46
46
  unique_jobs.each do |export|
@@ -246,6 +246,7 @@ module Myreplicator
246
246
  Kernel.p "===== export ====="
247
247
  Kernel.p export
248
248
  cmd = "cd #{Myreplicator.configs[export.source_schema]["ssh_tmp_dir"]}; grep -ls export_completed *.json"
249
+ return cmd
249
250
  end
250
251
 
251
252
  end