myreplicator 1.1.57 → 1.1.58
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/app/controllers/myreplicator/home_controller.rb +1 -1
- data/app/models/myreplicator/sweeper.rb +5 -4
- data/lib/exporter/export_metadata.rb +0 -1
- data/lib/exporter/mysql_exporter.rb +1 -1
- data/lib/exporter/sql_commands.rb +4 -3
- data/lib/loader/loader.rb +64 -3
- data/lib/myreplicator/version.rb +1 -1
- metadata +4 -4
@@ -19,7 +19,7 @@ module Myreplicator
|
|
19
19
|
@tab = 'home'
|
20
20
|
@option = 'errors'
|
21
21
|
@exports = Export.where("error is not null").order('source_schema ASC')
|
22
|
-
@logs = Log.where(:state => 'error').order("started_at DESC")
|
22
|
+
@logs = Log.where(:state => 'error').order("started_at DESC").limit(200)
|
23
23
|
end
|
24
24
|
|
25
25
|
def kill
|
@@ -13,12 +13,13 @@ module Myreplicator
|
|
13
13
|
ActiveRecord::Base.configurations.keys.each do |db|
|
14
14
|
Myreplicator::VerticaLoader.clean_up_temp_tables(db)
|
15
15
|
end
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
|
17
|
+
#removing files that are left in the storage for more than 12 hours
|
18
|
+
folders = [
|
19
|
+
"/home/share/datareplicator",
|
20
|
+
"/home/share/okl/bi_apps/datareplicator/mysqldumps"]
|
19
21
|
|
20
22
|
folders.each do |folder|
|
21
|
-
#cmd = "find #{folder} -mtime +2"
|
22
23
|
cmd = "find #{folder} -mmin +720"
|
23
24
|
l = `#{cmd}`
|
24
25
|
list = l.split(/\n/)
|
@@ -110,7 +110,7 @@ module Myreplicator
|
|
110
110
|
def incremental_export_into_outfile metadata
|
111
111
|
unless @export_obj.is_running?
|
112
112
|
|
113
|
-
if @export_obj.export_type == "incremental"
|
113
|
+
if @export_obj.export_type == "incremental" || (@export_obj.export_type == "all" && @export_obj.export_to == "vertica")
|
114
114
|
max_value = @export_obj.max_value
|
115
115
|
metadata.export_type = "incremental"
|
116
116
|
@export_obj.update_max_val if @export_obj.max_incremental_value.blank?
|
@@ -150,7 +150,7 @@ module Myreplicator
|
|
150
150
|
sql = ""
|
151
151
|
replaces.each do |k,v|
|
152
152
|
if sql.blank?
|
153
|
-
sql = "REPLACE(
|
153
|
+
sql = "REPLACE(\\`#{column}\\`, '#{k}', '#{v}')"
|
154
154
|
else
|
155
155
|
sql = "REPLACE(#{sql}, '#{k}', '#{v}')"
|
156
156
|
end
|
@@ -159,9 +159,10 @@ module Myreplicator
|
|
159
159
|
end
|
160
160
|
result << sql
|
161
161
|
else
|
162
|
-
result << column
|
162
|
+
result << "\\`#{column}\\`"
|
163
163
|
end
|
164
164
|
end
|
165
|
+
Kernel.p result
|
165
166
|
return result
|
166
167
|
end
|
167
168
|
|
@@ -199,7 +200,7 @@ module Myreplicator
|
|
199
200
|
sql += "WHERE #{options[:incremental_col]} >= #{options[:incremental_val].to_i - 10000}" #buffer 10000
|
200
201
|
end
|
201
202
|
end
|
202
|
-
|
203
|
+
Kernel.p sql
|
203
204
|
return sql
|
204
205
|
end
|
205
206
|
|
data/lib/loader/loader.rb
CHANGED
@@ -4,6 +4,7 @@ module Myreplicator
|
|
4
4
|
class Loader
|
5
5
|
|
6
6
|
@queue = :myreplicator_load # Provided for Resque
|
7
|
+
|
7
8
|
|
8
9
|
def initialize *args
|
9
10
|
options = args.extract_options!
|
@@ -52,8 +53,9 @@ module Myreplicator
|
|
52
53
|
all_files = Myreplicator::Loader.metadata_files
|
53
54
|
|
54
55
|
#Kernel.p "===== all_files ====="
|
55
|
-
#Kernel.p all_files
|
56
|
-
|
56
|
+
#Kernel.p all_files
|
57
|
+
|
58
|
+
=begin
|
57
59
|
all_files.each do |m|
|
58
60
|
#Kernel.p m
|
59
61
|
if m.export_type == "initial"
|
@@ -70,7 +72,66 @@ module Myreplicator
|
|
70
72
|
end
|
71
73
|
|
72
74
|
incrementals = all_files # Remaining are all incrementals
|
75
|
+
=end
|
76
|
+
# adding incremetal loading file to redis
|
77
|
+
files_to_metadata = {}
|
78
|
+
@redis = Redis.new(:host => Settings[:redis][:host], :port => Settings[:redis][:port])
|
79
|
+
@load_set = "myreplicator_load_set"
|
80
|
+
@load_hash = "myreplicator_load_hash"
|
81
|
+
|
82
|
+
all_files.each do |m|
|
83
|
+
if !(@redis.hexists(@load_hash, m.filepath))
|
84
|
+
@redis.hset(@load_hash, m.filepath, 0)
|
85
|
+
@redis.sadd(@load_set, m.filepath)
|
86
|
+
else
|
87
|
+
if @redis.hget(@load_hash, m.filepath) == 1
|
88
|
+
@redis.hdel(@load_hash, m.filepath)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
files_to_metadata[m.filepath] = m
|
92
|
+
end
|
93
|
+
|
94
|
+
while @redis.smembers(@load_set).size >= 0
|
95
|
+
filepath = @redis.spop(@load_set)
|
96
|
+
|
97
|
+
metadata = files_to_metadata[filepath]
|
98
|
+
if metadata.blank?
|
99
|
+
next
|
100
|
+
end
|
101
|
+
if metadata.export_type == "initial"
|
102
|
+
Myreplicator::Log.run(:job_type => "loader",
|
103
|
+
:name => "#{metadata.export_type}_import",
|
104
|
+
:file => metadata.filename,
|
105
|
+
:export_id => metadata.export_id) do |log|
|
106
|
+
if Myreplicator::Loader.transfer_completed? metadata
|
107
|
+
if metadata.export_to == "vertica"
|
108
|
+
Myreplicator::Loader.incremental_load metadata
|
109
|
+
else
|
110
|
+
Myreplicator::Loader.initial_load metadata
|
111
|
+
end
|
112
|
+
Myreplicator::Loader.cleanup metadata
|
113
|
+
end
|
114
|
+
end
|
115
|
+
@redis.hset(@load_hash, metadata.filepath, 1)
|
116
|
+
else #if metadata.export_type == "incremental"
|
117
|
+
#1
|
118
|
+
Myreplicator::Log.run(:job_type => "loader",
|
119
|
+
:name => "incremental_import",
|
120
|
+
:file => metadata.filename,
|
121
|
+
:export_id => metadata.export_id) do |log|
|
122
|
+
if Myreplicator::Loader.transfer_completed? metadata
|
123
|
+
Myreplicator::Loader.incremental_load metadata
|
124
|
+
Myreplicator::Loader.cleanup metadata
|
125
|
+
end
|
126
|
+
end
|
127
|
+
#2
|
128
|
+
@redis.hset(@load_hash, metadata.filepath, 1)
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
|
73
133
|
|
134
|
+
=begin
|
74
135
|
#initial_procs = Loader.initial_loads initials
|
75
136
|
#parallel_load initial_procs
|
76
137
|
initials.each do |metadata|
|
@@ -106,7 +167,7 @@ module Myreplicator
|
|
106
167
|
end
|
107
168
|
# end # group
|
108
169
|
#end # groups
|
109
|
-
|
170
|
+
=end
|
110
171
|
end
|
111
172
|
|
112
173
|
def self.parallel_load procs
|
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.58
|
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-07-
|
12
|
+
date: 2013-07-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -355,7 +355,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
355
355
|
version: '0'
|
356
356
|
segments:
|
357
357
|
- 0
|
358
|
-
hash:
|
358
|
+
hash: 3425503714195991273
|
359
359
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
360
360
|
none: false
|
361
361
|
requirements:
|
@@ -364,7 +364,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
364
364
|
version: '0'
|
365
365
|
segments:
|
366
366
|
- 0
|
367
|
-
hash:
|
367
|
+
hash: 3425503714195991273
|
368
368
|
requirements: []
|
369
369
|
rubyforge_project:
|
370
370
|
rubygems_version: 1.8.24
|