andyjeffries-rubyrep 1.2.1
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/History.txt +83 -0
- data/License.txt +20 -0
- data/Manifest.txt +151 -0
- data/README.txt +37 -0
- data/bin/rubyrep +8 -0
- data/lib/rubyrep.rb +72 -0
- data/lib/rubyrep/base_runner.rb +195 -0
- data/lib/rubyrep/command_runner.rb +144 -0
- data/lib/rubyrep/committers/buffered_committer.rb +151 -0
- data/lib/rubyrep/committers/committers.rb +152 -0
- data/lib/rubyrep/configuration.rb +275 -0
- data/lib/rubyrep/connection_extenders/connection_extenders.rb +165 -0
- data/lib/rubyrep/connection_extenders/jdbc_extender.rb +65 -0
- data/lib/rubyrep/connection_extenders/mysql_extender.rb +59 -0
- data/lib/rubyrep/connection_extenders/postgresql_extender.rb +277 -0
- data/lib/rubyrep/database_proxy.rb +52 -0
- data/lib/rubyrep/direct_table_scan.rb +75 -0
- data/lib/rubyrep/generate_runner.rb +105 -0
- data/lib/rubyrep/initializer.rb +39 -0
- data/lib/rubyrep/log_helper.rb +30 -0
- data/lib/rubyrep/logged_change.rb +160 -0
- data/lib/rubyrep/logged_change_loader.rb +197 -0
- data/lib/rubyrep/noisy_connection.rb +80 -0
- data/lib/rubyrep/proxied_table_scan.rb +171 -0
- data/lib/rubyrep/proxy_block_cursor.rb +145 -0
- data/lib/rubyrep/proxy_connection.rb +431 -0
- data/lib/rubyrep/proxy_cursor.rb +44 -0
- data/lib/rubyrep/proxy_row_cursor.rb +43 -0
- data/lib/rubyrep/proxy_runner.rb +89 -0
- data/lib/rubyrep/replication_difference.rb +100 -0
- data/lib/rubyrep/replication_extenders/mysql_replication.rb +271 -0
- data/lib/rubyrep/replication_extenders/postgresql_replication.rb +236 -0
- data/lib/rubyrep/replication_extenders/replication_extenders.rb +26 -0
- data/lib/rubyrep/replication_helper.rb +142 -0
- data/lib/rubyrep/replication_initializer.rb +327 -0
- data/lib/rubyrep/replication_run.rb +142 -0
- data/lib/rubyrep/replication_runner.rb +166 -0
- data/lib/rubyrep/replicators/replicators.rb +42 -0
- data/lib/rubyrep/replicators/two_way_replicator.rb +361 -0
- data/lib/rubyrep/scan_progress_printers/progress_bar.rb +65 -0
- data/lib/rubyrep/scan_progress_printers/scan_progress_printers.rb +65 -0
- data/lib/rubyrep/scan_report_printers/scan_detail_reporter.rb +111 -0
- data/lib/rubyrep/scan_report_printers/scan_report_printers.rb +67 -0
- data/lib/rubyrep/scan_report_printers/scan_summary_reporter.rb +75 -0
- data/lib/rubyrep/scan_runner.rb +25 -0
- data/lib/rubyrep/session.rb +230 -0
- data/lib/rubyrep/sync_helper.rb +121 -0
- data/lib/rubyrep/sync_runner.rb +31 -0
- data/lib/rubyrep/syncers/syncers.rb +112 -0
- data/lib/rubyrep/syncers/two_way_syncer.rb +174 -0
- data/lib/rubyrep/table_scan.rb +54 -0
- data/lib/rubyrep/table_scan_helper.rb +46 -0
- data/lib/rubyrep/table_sorter.rb +70 -0
- data/lib/rubyrep/table_spec_resolver.rb +142 -0
- data/lib/rubyrep/table_sync.rb +90 -0
- data/lib/rubyrep/task_sweeper.rb +77 -0
- data/lib/rubyrep/trigger_mode_switcher.rb +63 -0
- data/lib/rubyrep/type_casting_cursor.rb +31 -0
- data/lib/rubyrep/uninstall_runner.rb +93 -0
- data/lib/rubyrep/version.rb +9 -0
- data/rubyrep +8 -0
- data/rubyrep.bat +4 -0
- data/setup.rb +1585 -0
- data/spec/base_runner_spec.rb +218 -0
- data/spec/buffered_committer_spec.rb +274 -0
- data/spec/command_runner_spec.rb +145 -0
- data/spec/committers_spec.rb +178 -0
- data/spec/configuration_spec.rb +203 -0
- data/spec/connection_extender_interface_spec.rb +141 -0
- data/spec/connection_extenders_registration_spec.rb +164 -0
- data/spec/database_proxy_spec.rb +48 -0
- data/spec/database_rake_spec.rb +40 -0
- data/spec/db_specific_connection_extenders_spec.rb +34 -0
- data/spec/db_specific_replication_extenders_spec.rb +38 -0
- data/spec/direct_table_scan_spec.rb +61 -0
- data/spec/dolphins.jpg +0 -0
- data/spec/generate_runner_spec.rb +84 -0
- data/spec/initializer_spec.rb +46 -0
- data/spec/log_helper_spec.rb +39 -0
- data/spec/logged_change_loader_spec.rb +68 -0
- data/spec/logged_change_spec.rb +470 -0
- data/spec/noisy_connection_spec.rb +78 -0
- data/spec/postgresql_replication_spec.rb +48 -0
- data/spec/postgresql_schema_support_spec.rb +212 -0
- data/spec/postgresql_support_spec.rb +63 -0
- data/spec/progress_bar_spec.rb +77 -0
- data/spec/proxied_table_scan_spec.rb +151 -0
- data/spec/proxy_block_cursor_spec.rb +197 -0
- data/spec/proxy_connection_spec.rb +423 -0
- data/spec/proxy_cursor_spec.rb +56 -0
- data/spec/proxy_row_cursor_spec.rb +66 -0
- data/spec/proxy_runner_spec.rb +70 -0
- data/spec/replication_difference_spec.rb +161 -0
- data/spec/replication_extender_interface_spec.rb +367 -0
- data/spec/replication_extenders_spec.rb +32 -0
- data/spec/replication_helper_spec.rb +178 -0
- data/spec/replication_initializer_spec.rb +509 -0
- data/spec/replication_run_spec.rb +443 -0
- data/spec/replication_runner_spec.rb +254 -0
- data/spec/replicators_spec.rb +36 -0
- data/spec/rubyrep_spec.rb +8 -0
- data/spec/scan_detail_reporter_spec.rb +119 -0
- data/spec/scan_progress_printers_spec.rb +68 -0
- data/spec/scan_report_printers_spec.rb +67 -0
- data/spec/scan_runner_spec.rb +50 -0
- data/spec/scan_summary_reporter_spec.rb +61 -0
- data/spec/session_spec.rb +253 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +305 -0
- data/spec/strange_name_support_spec.rb +135 -0
- data/spec/sync_helper_spec.rb +169 -0
- data/spec/sync_runner_spec.rb +78 -0
- data/spec/syncers_spec.rb +171 -0
- data/spec/table_scan_helper_spec.rb +36 -0
- data/spec/table_scan_spec.rb +49 -0
- data/spec/table_sorter_spec.rb +30 -0
- data/spec/table_spec_resolver_spec.rb +111 -0
- data/spec/table_sync_spec.rb +140 -0
- data/spec/task_sweeper_spec.rb +47 -0
- data/spec/trigger_mode_switcher_spec.rb +83 -0
- data/spec/two_way_replicator_spec.rb +721 -0
- data/spec/two_way_syncer_spec.rb +256 -0
- data/spec/type_casting_cursor_spec.rb +50 -0
- data/spec/uninstall_runner_spec.rb +93 -0
- metadata +190 -0
data/History.txt
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
== 1.2.0 2011-03-07
|
|
2
|
+
|
|
3
|
+
* Feature: compatibility with Rails 3
|
|
4
|
+
* Feature: do not replicate record updates that didn't change any fields (props to daudo)
|
|
5
|
+
* Bug fix: reducing deadlock problems (props to gtanzillo)
|
|
6
|
+
* Bug fix: adding missing schema prefix in PostgreSQL triggers
|
|
7
|
+
* Bug fix: scans / syncs fail due to incorrect handling of case sensitivity of string primary key columns
|
|
8
|
+
* Bug fix: reducing risk of foreign key conflicts during replication (props for root cause analysis to TonyB)
|
|
9
|
+
|
|
10
|
+
== 1.1.2 2009-05-10
|
|
11
|
+
|
|
12
|
+
* Bug fix: escape primary keys in replication triggers
|
|
13
|
+
|
|
14
|
+
== 1.1.1 2009-02-02
|
|
15
|
+
|
|
16
|
+
* Feature: optional use of an SQL logger
|
|
17
|
+
* Bug fix: under postgresql, rubyrep triggers now finds the pending_changes table also if not included in current search path
|
|
18
|
+
|
|
19
|
+
== 1.1.0 2009-12-15
|
|
20
|
+
|
|
21
|
+
* Feature: filtering of sync / replication events with custom specified functionality
|
|
22
|
+
* Feature: compatibility with JRuby 1.4.0 and ActiveRecord 2.3.5
|
|
23
|
+
|
|
24
|
+
== 1.0.9 2009-10-14
|
|
25
|
+
|
|
26
|
+
* Bug fix: ReplicationRun#run should load only one change log record to figure out if there are pending changes
|
|
27
|
+
|
|
28
|
+
== 1.0.8 2009-10-01
|
|
29
|
+
|
|
30
|
+
* Feature: replication more robust against connection failures
|
|
31
|
+
* Feature: initial syncs before replication can be disabled with :initial_sync option
|
|
32
|
+
* Bug fix: better detection of failed update and delete replications
|
|
33
|
+
* Bug fix: fix scenario where replication could be logged as successful even when failed
|
|
34
|
+
* Bug fix: make proxied replication work under JRuby
|
|
35
|
+
|
|
36
|
+
== 1.0.7 2009-07-26
|
|
37
|
+
|
|
38
|
+
* Bug fix: buffered LoggedChangeLoader#update to avoid timeouts with large replication backlogs.
|
|
39
|
+
|
|
40
|
+
== 1.0.6 2009-07-25
|
|
41
|
+
|
|
42
|
+
* Bug fix: do not assume anymore that replication log events appear in sequential order
|
|
43
|
+
* Feature: increased resilience of rubyrep to network timeouts
|
|
44
|
+
* Feature: introduced :after_infrastructure_setup handler
|
|
45
|
+
|
|
46
|
+
== 1.0.5 2009-07-03
|
|
47
|
+
|
|
48
|
+
* Bug fix: rubyrep replication runs should survive update or delete attempts rejected by the database.
|
|
49
|
+
* Bug fix: support for multiple PostgreSQL schemas holding tables of the same name.
|
|
50
|
+
|
|
51
|
+
== 1.0.4 2009-06-20
|
|
52
|
+
|
|
53
|
+
* Bug fix: added missing file (log_helper.rb) to gem manifest
|
|
54
|
+
|
|
55
|
+
== 1.0.3 2009-06-20
|
|
56
|
+
|
|
57
|
+
* Minor enhancements:
|
|
58
|
+
* Added support (and according tests) for non-standard table / column names
|
|
59
|
+
* Verified compatibility with jruby 1.3.0
|
|
60
|
+
* Bug fixes:
|
|
61
|
+
* Also big exception messages should be accommodated in event log table.
|
|
62
|
+
|
|
63
|
+
== 1.0.2 2009-06-13
|
|
64
|
+
|
|
65
|
+
* 3 minor enhancements:
|
|
66
|
+
* Simplified low-level functions to read records from the database
|
|
67
|
+
(easier integration of additional databases)
|
|
68
|
+
* Better replication efficiency with large replication backlogs
|
|
69
|
+
* Reduced costs of an empty replication run
|
|
70
|
+
* Ignore tables that only exist in one database
|
|
71
|
+
(tables created for testing / backup don't block scan / sync / replication)
|
|
72
|
+
|
|
73
|
+
== 1.0.1 2009-03-25
|
|
74
|
+
|
|
75
|
+
* 3 minor enhancements:
|
|
76
|
+
* Verified compatibility with active_record 2.3.2 and jruby 1.2.0
|
|
77
|
+
* Released jruby bunde with the updated activerecord and jruby
|
|
78
|
+
* Catch ctrl+c and execute graceful shutdown
|
|
79
|
+
|
|
80
|
+
== 1.0.0 2009-03-07
|
|
81
|
+
|
|
82
|
+
* 1 major enhancement:
|
|
83
|
+
* Initial release
|
data/License.txt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2007 Arndt Lehmann
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
History.txt
|
|
2
|
+
License.txt
|
|
3
|
+
Manifest.txt
|
|
4
|
+
README.txt
|
|
5
|
+
Rakefile
|
|
6
|
+
bin/rubyrep
|
|
7
|
+
config/hoe.rb
|
|
8
|
+
config/mysql_config.rb
|
|
9
|
+
config/postgres_config.rb
|
|
10
|
+
config/proxied_test_config.rb
|
|
11
|
+
config/redmine_config.rb
|
|
12
|
+
config/rep_config.rb
|
|
13
|
+
config/requirements.rb
|
|
14
|
+
config/test_config.rb
|
|
15
|
+
lib/rubyrep.rb
|
|
16
|
+
lib/rubyrep/base_runner.rb
|
|
17
|
+
lib/rubyrep/command_runner.rb
|
|
18
|
+
lib/rubyrep/committers/buffered_committer.rb
|
|
19
|
+
lib/rubyrep/committers/committers.rb
|
|
20
|
+
lib/rubyrep/configuration.rb
|
|
21
|
+
lib/rubyrep/connection_extenders/connection_extenders.rb
|
|
22
|
+
lib/rubyrep/connection_extenders/jdbc_extender.rb
|
|
23
|
+
lib/rubyrep/connection_extenders/mysql_extender.rb
|
|
24
|
+
lib/rubyrep/connection_extenders/postgresql_extender.rb
|
|
25
|
+
lib/rubyrep/database_proxy.rb
|
|
26
|
+
lib/rubyrep/direct_table_scan.rb
|
|
27
|
+
lib/rubyrep/generate_runner.rb
|
|
28
|
+
lib/rubyrep/initializer.rb
|
|
29
|
+
lib/rubyrep/log_helper.rb
|
|
30
|
+
lib/rubyrep/logged_change.rb
|
|
31
|
+
lib/rubyrep/logged_change_loader.rb
|
|
32
|
+
lib/rubyrep/noisy_connection.rb
|
|
33
|
+
lib/rubyrep/proxied_table_scan.rb
|
|
34
|
+
lib/rubyrep/proxy_block_cursor.rb
|
|
35
|
+
lib/rubyrep/proxy_connection.rb
|
|
36
|
+
lib/rubyrep/proxy_cursor.rb
|
|
37
|
+
lib/rubyrep/proxy_row_cursor.rb
|
|
38
|
+
lib/rubyrep/proxy_runner.rb
|
|
39
|
+
lib/rubyrep/replication_difference.rb
|
|
40
|
+
lib/rubyrep/replication_extenders/mysql_replication.rb
|
|
41
|
+
lib/rubyrep/replication_extenders/postgresql_replication.rb
|
|
42
|
+
lib/rubyrep/replication_extenders/replication_extenders.rb
|
|
43
|
+
lib/rubyrep/replication_helper.rb
|
|
44
|
+
lib/rubyrep/replication_initializer.rb
|
|
45
|
+
lib/rubyrep/replication_run.rb
|
|
46
|
+
lib/rubyrep/replication_runner.rb
|
|
47
|
+
lib/rubyrep/replicators/replicators.rb
|
|
48
|
+
lib/rubyrep/replicators/two_way_replicator.rb
|
|
49
|
+
lib/rubyrep/scan_progress_printers/progress_bar.rb
|
|
50
|
+
lib/rubyrep/scan_progress_printers/scan_progress_printers.rb
|
|
51
|
+
lib/rubyrep/scan_report_printers/scan_detail_reporter.rb
|
|
52
|
+
lib/rubyrep/scan_report_printers/scan_report_printers.rb
|
|
53
|
+
lib/rubyrep/scan_report_printers/scan_summary_reporter.rb
|
|
54
|
+
lib/rubyrep/scan_runner.rb
|
|
55
|
+
lib/rubyrep/session.rb
|
|
56
|
+
lib/rubyrep/sync_helper.rb
|
|
57
|
+
lib/rubyrep/sync_runner.rb
|
|
58
|
+
lib/rubyrep/syncers/syncers.rb
|
|
59
|
+
lib/rubyrep/syncers/two_way_syncer.rb
|
|
60
|
+
lib/rubyrep/table_scan.rb
|
|
61
|
+
lib/rubyrep/table_scan_helper.rb
|
|
62
|
+
lib/rubyrep/table_sorter.rb
|
|
63
|
+
lib/rubyrep/table_spec_resolver.rb
|
|
64
|
+
lib/rubyrep/table_sync.rb
|
|
65
|
+
lib/rubyrep/task_sweeper.rb
|
|
66
|
+
lib/rubyrep/trigger_mode_switcher.rb
|
|
67
|
+
lib/rubyrep/type_casting_cursor.rb
|
|
68
|
+
lib/rubyrep/uninstall_runner.rb
|
|
69
|
+
lib/rubyrep/version.rb
|
|
70
|
+
rubyrep
|
|
71
|
+
rubyrep.bat
|
|
72
|
+
script/destroy
|
|
73
|
+
script/generate
|
|
74
|
+
script/txt2html
|
|
75
|
+
setup.rb
|
|
76
|
+
sims/performance/big_rep_spec.rb
|
|
77
|
+
sims/performance/big_scan_spec.rb
|
|
78
|
+
sims/performance/big_sync_spec.rb
|
|
79
|
+
sims/performance/performance.rake
|
|
80
|
+
sims/sim_helper.rb
|
|
81
|
+
spec/base_runner_spec.rb
|
|
82
|
+
spec/buffered_committer_spec.rb
|
|
83
|
+
spec/command_runner_spec.rb
|
|
84
|
+
spec/committers_spec.rb
|
|
85
|
+
spec/configuration_spec.rb
|
|
86
|
+
spec/connection_extender_interface_spec.rb
|
|
87
|
+
spec/connection_extenders_registration_spec.rb
|
|
88
|
+
spec/database_proxy_spec.rb
|
|
89
|
+
spec/database_rake_spec.rb
|
|
90
|
+
spec/db_specific_connection_extenders_spec.rb
|
|
91
|
+
spec/db_specific_replication_extenders_spec.rb
|
|
92
|
+
spec/direct_table_scan_spec.rb
|
|
93
|
+
spec/dolphins.jpg
|
|
94
|
+
spec/generate_runner_spec.rb
|
|
95
|
+
spec/initializer_spec.rb
|
|
96
|
+
spec/log_helper_spec.rb
|
|
97
|
+
spec/logged_change_loader_spec.rb
|
|
98
|
+
spec/logged_change_spec.rb
|
|
99
|
+
spec/noisy_connection_spec.rb
|
|
100
|
+
spec/postgresql_replication_spec.rb
|
|
101
|
+
spec/postgresql_schema_support_spec.rb
|
|
102
|
+
spec/postgresql_support_spec.rb
|
|
103
|
+
spec/progress_bar_spec.rb
|
|
104
|
+
spec/proxied_table_scan_spec.rb
|
|
105
|
+
spec/proxy_block_cursor_spec.rb
|
|
106
|
+
spec/proxy_connection_spec.rb
|
|
107
|
+
spec/proxy_cursor_spec.rb
|
|
108
|
+
spec/proxy_row_cursor_spec.rb
|
|
109
|
+
spec/proxy_runner_spec.rb
|
|
110
|
+
spec/replication_difference_spec.rb
|
|
111
|
+
spec/replication_extender_interface_spec.rb
|
|
112
|
+
spec/replication_extenders_spec.rb
|
|
113
|
+
spec/replication_helper_spec.rb
|
|
114
|
+
spec/replication_initializer_spec.rb
|
|
115
|
+
spec/replication_run_spec.rb
|
|
116
|
+
spec/replication_runner_spec.rb
|
|
117
|
+
spec/replicators_spec.rb
|
|
118
|
+
spec/rubyrep_spec.rb
|
|
119
|
+
spec/scan_detail_reporter_spec.rb
|
|
120
|
+
spec/scan_progress_printers_spec.rb
|
|
121
|
+
spec/scan_report_printers_spec.rb
|
|
122
|
+
spec/scan_runner_spec.rb
|
|
123
|
+
spec/scan_summary_reporter_spec.rb
|
|
124
|
+
spec/session_spec.rb
|
|
125
|
+
spec/spec.opts
|
|
126
|
+
spec/spec_helper.rb
|
|
127
|
+
spec/strange_name_support_spec.rb
|
|
128
|
+
spec/sync_helper_spec.rb
|
|
129
|
+
spec/sync_runner_spec.rb
|
|
130
|
+
spec/syncers_spec.rb
|
|
131
|
+
spec/table_scan_helper_spec.rb
|
|
132
|
+
spec/table_scan_spec.rb
|
|
133
|
+
spec/table_sorter_spec.rb
|
|
134
|
+
spec/table_spec_resolver_spec.rb
|
|
135
|
+
spec/table_sync_spec.rb
|
|
136
|
+
spec/task_sweeper_spec.rb
|
|
137
|
+
spec/trigger_mode_switcher_spec.rb
|
|
138
|
+
spec/two_way_replicator_spec.rb
|
|
139
|
+
spec/two_way_syncer_spec.rb
|
|
140
|
+
spec/type_casting_cursor_spec.rb
|
|
141
|
+
spec/uninstall_runner_spec.rb
|
|
142
|
+
tasks/database.rake
|
|
143
|
+
tasks/deployment.rake
|
|
144
|
+
tasks/environment.rake
|
|
145
|
+
tasks/java.rake
|
|
146
|
+
tasks/redmine_test.rake
|
|
147
|
+
tasks/rspec.rake
|
|
148
|
+
tasks/rubyrep.tailor
|
|
149
|
+
tasks/stats.rake
|
|
150
|
+
tasks/task_helper.rb
|
|
151
|
+
tasks/website.rake
|
data/README.txt
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
= rubyrep
|
|
2
|
+
|
|
3
|
+
== MISSION:
|
|
4
|
+
|
|
5
|
+
Development of an open-source solution for asynchronous, master-master replication of relational databases that is
|
|
6
|
+
* ridiculously easy to use
|
|
7
|
+
* database independent
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
== MORE INFORMATION:
|
|
11
|
+
|
|
12
|
+
Refer to the project website at http://www.rubyrep.org
|
|
13
|
+
|
|
14
|
+
== LICENSE:
|
|
15
|
+
|
|
16
|
+
(The MIT License)
|
|
17
|
+
|
|
18
|
+
Copyright (c) 2009 Arndt Lehmann
|
|
19
|
+
|
|
20
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
21
|
+
a copy of this software and associated documentation files (the
|
|
22
|
+
'Software'), to deal in the Software without restriction, including
|
|
23
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
24
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
25
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
26
|
+
the following conditions:
|
|
27
|
+
|
|
28
|
+
The above copyright notice and this permission notice shall be
|
|
29
|
+
included in all copies or substantial portions of the Software.
|
|
30
|
+
|
|
31
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
32
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
33
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
34
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
35
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
36
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
37
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/bin/rubyrep
ADDED
data/lib/rubyrep.rb
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
$LOAD_PATH.unshift File.dirname(__FILE__)
|
|
2
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + "/rubyrep"
|
|
3
|
+
|
|
4
|
+
require 'rubygems'
|
|
5
|
+
require 'yaml'
|
|
6
|
+
|
|
7
|
+
gem 'activerecord', '>= 3.0.5'
|
|
8
|
+
require 'active_record'
|
|
9
|
+
|
|
10
|
+
require 'version'
|
|
11
|
+
require 'configuration'
|
|
12
|
+
require 'initializer'
|
|
13
|
+
require 'session'
|
|
14
|
+
require 'connection_extenders/connection_extenders'
|
|
15
|
+
require 'table_scan_helper'
|
|
16
|
+
require 'table_scan'
|
|
17
|
+
require 'type_casting_cursor'
|
|
18
|
+
require 'proxy_cursor'
|
|
19
|
+
require 'proxy_block_cursor'
|
|
20
|
+
require 'proxy_row_cursor'
|
|
21
|
+
require 'direct_table_scan'
|
|
22
|
+
require 'proxied_table_scan'
|
|
23
|
+
require 'database_proxy'
|
|
24
|
+
require 'command_runner'
|
|
25
|
+
require 'proxy_runner'
|
|
26
|
+
require 'proxy_connection'
|
|
27
|
+
require 'table_spec_resolver'
|
|
28
|
+
require 'scan_report_printers/scan_report_printers'
|
|
29
|
+
require 'scan_report_printers/scan_summary_reporter'
|
|
30
|
+
require 'scan_report_printers/scan_detail_reporter'
|
|
31
|
+
require 'scan_progress_printers/scan_progress_printers'
|
|
32
|
+
require 'scan_progress_printers/progress_bar'
|
|
33
|
+
require 'base_runner'
|
|
34
|
+
require 'scan_runner'
|
|
35
|
+
require 'committers/committers'
|
|
36
|
+
require 'committers/buffered_committer'
|
|
37
|
+
require 'log_helper'
|
|
38
|
+
require 'sync_helper'
|
|
39
|
+
require 'table_sorter'
|
|
40
|
+
require 'table_sync'
|
|
41
|
+
require 'syncers/syncers'
|
|
42
|
+
require 'syncers/two_way_syncer'
|
|
43
|
+
require 'sync_runner'
|
|
44
|
+
require 'trigger_mode_switcher'
|
|
45
|
+
require 'logged_change_loader'
|
|
46
|
+
require 'logged_change'
|
|
47
|
+
require 'replication_difference'
|
|
48
|
+
require 'replication_helper'
|
|
49
|
+
require 'replicators/replicators'
|
|
50
|
+
require 'replicators/two_way_replicator'
|
|
51
|
+
require 'task_sweeper'
|
|
52
|
+
require 'replication_run'
|
|
53
|
+
require 'replication_runner'
|
|
54
|
+
require 'uninstall_runner'
|
|
55
|
+
require 'generate_runner'
|
|
56
|
+
require 'noisy_connection'
|
|
57
|
+
|
|
58
|
+
Dir["#{File.dirname(__FILE__)}/rubyrep/connection_extenders/*.rb"].each do |extender|
|
|
59
|
+
# jdbc_extender.rb is only loaded if we are running on jruby
|
|
60
|
+
require extender unless extender =~ /jdbc/ and not RUBY_PLATFORM =~ /java/
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
require 'replication_initializer'
|
|
64
|
+
require 'replication_extenders/replication_extenders'
|
|
65
|
+
|
|
66
|
+
Dir["#{File.dirname(__FILE__)}/rubyrep/replication_extenders/*.rb"].each do |extender|
|
|
67
|
+
require extender
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
module RR
|
|
71
|
+
|
|
72
|
+
end
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
|
2
|
+
|
|
3
|
+
require 'optparse'
|
|
4
|
+
|
|
5
|
+
module RR
|
|
6
|
+
# This class implements the base functionality for runners that process table
|
|
7
|
+
# specs.
|
|
8
|
+
class BaseRunner
|
|
9
|
+
|
|
10
|
+
# Default options if not overriden in command line
|
|
11
|
+
DEFAULT_OPTIONS = {
|
|
12
|
+
:table_specs => []
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
# Provided options. Possible values:
|
|
16
|
+
# * +:config_file+: path to config file
|
|
17
|
+
# * +:table_specs+: array of table specification strings
|
|
18
|
+
attr_accessor :options
|
|
19
|
+
|
|
20
|
+
# The class for the selected report printer
|
|
21
|
+
attr_accessor :report_printer_class
|
|
22
|
+
|
|
23
|
+
# The specified option parameter for the report printer
|
|
24
|
+
attr_accessor :report_printer_arg
|
|
25
|
+
|
|
26
|
+
# Returns the active ScanReportPrinters instance (as selected through the
|
|
27
|
+
# command line options OR if none was selected, the default one).
|
|
28
|
+
def report_printer
|
|
29
|
+
unless @report_printer
|
|
30
|
+
printer_class = report_printer_class || ScanReportPrinters::ScanSummaryReporter
|
|
31
|
+
@report_printer ||= printer_class.new(session, report_printer_arg)
|
|
32
|
+
end
|
|
33
|
+
@report_printer
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Returns the command line selected ScanProgressPrinters class
|
|
37
|
+
attr_accessor :selected_progress_printer
|
|
38
|
+
|
|
39
|
+
# Returns the active ScanProgressPrinter class (as selected through the
|
|
40
|
+
# command line options OR if none was selected, the default one).
|
|
41
|
+
def progress_printer
|
|
42
|
+
if selected_progress_printer
|
|
43
|
+
selected_progress_printer
|
|
44
|
+
else
|
|
45
|
+
printer_key = session.configuration.options[:scan_progress_printer]
|
|
46
|
+
ScanProgressPrinters.printers[printer_key][:printer_class]
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Returns the default command summary description (nothing).
|
|
51
|
+
# Should be overwritten by child classes.
|
|
52
|
+
def summary_description; ""; end
|
|
53
|
+
|
|
54
|
+
# Parses the given command line parameter array.
|
|
55
|
+
# Returns the status (as per UNIX conventions: 1 if parameters were invalid,
|
|
56
|
+
# 0 otherwise)
|
|
57
|
+
def process_options(args)
|
|
58
|
+
status = 0
|
|
59
|
+
self.options = DEFAULT_OPTIONS.clone
|
|
60
|
+
|
|
61
|
+
parser = OptionParser.new do |opts|
|
|
62
|
+
opts.banner = <<EOS
|
|
63
|
+
Usage: #{$0} #{self.class.name.sub(/^.*::(.*)Runner$/, '\\1').downcase} [options] [table_spec] [table_spec] ...
|
|
64
|
+
|
|
65
|
+
#{summary_description}
|
|
66
|
+
|
|
67
|
+
table_spec can be either:
|
|
68
|
+
* a specific table name (e. g. 'users') or
|
|
69
|
+
* a pair of (specific) table names (e. g.: 'users,users_backup')
|
|
70
|
+
(In this case the first table in the 'left' database is compared
|
|
71
|
+
with the second table in the 'right' database.)
|
|
72
|
+
* a regular expression (e. g. '/^user/') [case insensitive match]
|
|
73
|
+
If no table_specs are provided via command line, the ones from the
|
|
74
|
+
configuration file are used.
|
|
75
|
+
EOS
|
|
76
|
+
opts.separator ""
|
|
77
|
+
opts.separator " Specific options:"
|
|
78
|
+
|
|
79
|
+
ScanReportPrinters.on_printer_selection(opts) do |printer_class, arg|
|
|
80
|
+
self.report_printer_class = printer_class
|
|
81
|
+
self.report_printer_arg = arg
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
ScanProgressPrinters.on_printer_selection(opts) do |printer|
|
|
85
|
+
self.selected_progress_printer = printer
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
opts.on("-c", "--config", "=CONFIG_FILE",
|
|
89
|
+
"Mandatory. Path to configuration file.") do |arg|
|
|
90
|
+
options[:config_file] = arg
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
add_specific_options(opts)
|
|
94
|
+
|
|
95
|
+
opts.on_tail("--help", "Show this message") do
|
|
96
|
+
$stderr.puts opts
|
|
97
|
+
self.options = nil
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
begin
|
|
102
|
+
unprocessed_args = parser.parse!(args)
|
|
103
|
+
if options # this will be +nil+ if the --help option is specified
|
|
104
|
+
options[:table_specs] = unprocessed_args
|
|
105
|
+
raise("Please specify configuration file") unless options.include?(:config_file)
|
|
106
|
+
end
|
|
107
|
+
rescue Exception => e
|
|
108
|
+
$stderr.puts "Command line parsing failed: #{e}"
|
|
109
|
+
$stderr.puts parser.help
|
|
110
|
+
self.options = nil
|
|
111
|
+
status = 1
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
return status
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Signals scan completion to the (active) scan report printer if it supports
|
|
118
|
+
# that method.
|
|
119
|
+
def signal_scanning_completion
|
|
120
|
+
if report_printer.respond_to? :scanning_finished
|
|
121
|
+
report_printer.scanning_finished
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# Creates a processor that does something with the given table.
|
|
126
|
+
# A processor needs to implement a +run+ method that yields for progress
|
|
127
|
+
# reporting purposes pairs of diff_type and row as defined under
|
|
128
|
+
# DirectTableScan#run.
|
|
129
|
+
def create_processor(left_table, right_table)
|
|
130
|
+
# not implemented in the base class
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Intended to be overwritten by derived classes that need to add additional
|
|
134
|
+
# options to the provided +OptionParser+ object.
|
|
135
|
+
def add_specific_options(opts)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Intended to be overwritten by derived classes that need to modify the
|
|
139
|
+
# table_pairs.
|
|
140
|
+
# * table_pairs: array of table pairs as returned by TableSpecResolver#resolve
|
|
141
|
+
# Returns the new table pairs array.
|
|
142
|
+
def prepare_table_pairs(table_pairs)
|
|
143
|
+
table_pairs
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# Returns the active +Session+.
|
|
147
|
+
# Loads config file and creates session if necessary.
|
|
148
|
+
def session
|
|
149
|
+
unless @session
|
|
150
|
+
load options[:config_file]
|
|
151
|
+
@session = Session.new Initializer.configuration
|
|
152
|
+
end
|
|
153
|
+
@session
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
attr_writer :session
|
|
157
|
+
|
|
158
|
+
# Returns the table pairs that should be processed.
|
|
159
|
+
# Refer to TableSpecRsolver#resolve for format of return value.
|
|
160
|
+
def table_pairs
|
|
161
|
+
prepare_table_pairs(session.configured_table_pairs(options[:table_specs]))
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# Executes a run based on the established options.
|
|
165
|
+
def execute
|
|
166
|
+
session.configuration.exclude_rubyrep_tables
|
|
167
|
+
table_pairs.each do |table_pair|
|
|
168
|
+
report_printer.scan table_pair[:left], table_pair[:right] do
|
|
169
|
+
processor = create_processor \
|
|
170
|
+
table_pair[:left], table_pair[:right]
|
|
171
|
+
processor.progress_printer = progress_printer
|
|
172
|
+
processor.run do |diff_type, row|
|
|
173
|
+
report_printer.report_difference diff_type, row
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
signal_scanning_completion
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
# Entry points for executing a processing run.
|
|
181
|
+
# args: the array of command line options that were provided by the user.
|
|
182
|
+
def self.run(args)
|
|
183
|
+
runner = new
|
|
184
|
+
|
|
185
|
+
status = runner.process_options(args)
|
|
186
|
+
if runner.options
|
|
187
|
+
runner.execute
|
|
188
|
+
end
|
|
189
|
+
status
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
|