flydata 0.3.12 → 0.3.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/flydata.gemspec +4 -4
- data/lib/flydata/command/sender.rb +1 -1
- data/lib/flydata/command/sync.rb +27 -15
- data/lib/flydata/compatibility_check.rb +1 -1
- data/lib/flydata/parser/mysql/dump_parser.rb +1 -1
- data/spec/flydata/command/sync_spec.rb +58 -0
- data/spec/flydata/parser/mysql/dump_parser_spec.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 317626ac900b0a0adf96c84648e554f6d2e7436a
|
4
|
+
data.tar.gz: e54dcf2b46068be7c27e3d6ce63c338d111e0c20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 935c6cc893c91fba078e92306b88a06697195c3a21b5241f0d08936a9cfb8acdff7c9eb32febbdc5c77a04b5dbe9627c757cf123ceee0420ae29784e4e10e1b4
|
7
|
+
data.tar.gz: 593a4ade45a37713981a11c5d98456eaaa04a592870cab4b2aff48a162e17d36c4780a138df5c38636d07bc9c3879d3ddde02e6331c94be916c62cc9b1d2f58a
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.13
|
data/flydata.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: flydata 0.3.
|
5
|
+
# stub: flydata 0.3.13 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "flydata"
|
9
|
-
s.version = "0.3.
|
9
|
+
s.version = "0.3.13"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Koichi Fujikawa", "Masashi Miyazaki", "Matthew Luu", "Mak Inada", "Sriram NS"]
|
14
|
-
s.date = "2015-04-
|
14
|
+
s.date = "2015-04-09"
|
15
15
|
s.description = "FlyData Agent"
|
16
16
|
s.email = "sysadmin@flydata.com"
|
17
17
|
s.executables = ["fdmysqldump", "flydata", "serverinfo"]
|
@@ -172,7 +172,7 @@ Gem::Specification.new do |s|
|
|
172
172
|
]
|
173
173
|
s.homepage = "http://flydata.com/"
|
174
174
|
s.licenses = ["All right reserved."]
|
175
|
-
s.rubygems_version = "2.
|
175
|
+
s.rubygems_version = "2.4.3"
|
176
176
|
s.summary = "FlyData Agent"
|
177
177
|
|
178
178
|
if s.respond_to? :specification_version then
|
@@ -35,7 +35,7 @@ module Flydata
|
|
35
35
|
Flydata::Command::Sync.new.try_mysql_sync
|
36
36
|
|
37
37
|
# Start sender(fluentd) process
|
38
|
-
log_info_stdout("Starting sender process.") unless options[:quiet]
|
38
|
+
log_info_stdout("Starting FlyData Agent sender process.") unless options[:quiet]
|
39
39
|
raw_start(options)
|
40
40
|
|
41
41
|
wait_until_client_ready(options)
|
data/lib/flydata/command/sync.rb
CHANGED
@@ -285,13 +285,15 @@ EOS
|
|
285
285
|
de = data_entry
|
286
286
|
|
287
287
|
unless @new_tables.empty?
|
288
|
-
|
288
|
+
unsynced_table_message = "We've noticed that these tables have not been synced yet: #{@new_tables.join(", ")}\n"
|
289
289
|
unless @ddl_tables.empty?
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
290
|
+
unsynced_table_message <<
|
291
|
+
" WARNING: We've noticed that at least one of these tables have not had their DDL generated yet.\n" +
|
292
|
+
" We recommend you run our 'flydata sync:generate_table_ddl > create_table.sql'\n" +
|
293
|
+
" to generate SQL to run on Redshift to create the correct tables\n" +
|
294
|
+
" Without running this sql on your Redshift cluster, there may be issues with your data"
|
294
295
|
end
|
296
|
+
log_info_stdout(unsynced_table_message)
|
295
297
|
if ask_yes_no("Do you want to run initial sync on all of these tables now?")
|
296
298
|
initial_sync(de)
|
297
299
|
else
|
@@ -308,6 +310,7 @@ EOS
|
|
308
310
|
|
309
311
|
def initial_sync(de)
|
310
312
|
# Load sync information from file
|
313
|
+
log_info_stdout("Checking FlyData Servers for existing buffer data...")
|
311
314
|
load_sync_info(de)
|
312
315
|
validate_initial_sync_status
|
313
316
|
begin
|
@@ -393,7 +396,7 @@ EOM
|
|
393
396
|
if ask_yes_no('Start Sync?')
|
394
397
|
log_info_stdout("Checking MySQL server connection and configuration...")
|
395
398
|
Flydata::MysqlCompatibilityCheck.new(dp, de['mysql_data_entry_preference'], dump_dir: fp, backup_dir: sync_fm.backup_dir).check
|
396
|
-
log_info_stdout("Checking database size...")
|
399
|
+
log_info_stdout("Checking the database size...")
|
397
400
|
|
398
401
|
db_bytesize = Flydata::Parser::Mysql::DatabaseSizeCheck.new(de['mysql_data_entry_preference'].merge('tables' => target_tables)).get_db_bytesize
|
399
402
|
log_info_stdout(" -> #{as_size(db_bytesize)} (#{db_bytesize} byte)")
|
@@ -411,12 +414,20 @@ EOM
|
|
411
414
|
end
|
412
415
|
end
|
413
416
|
|
414
|
-
log_info_stdout("Exporting data from database.")
|
417
|
+
log_info_stdout("Exporting data from the database.")
|
415
418
|
log_info_stdout("This process can take hours depending on data size and load on your database. Please be patient...")
|
416
419
|
if file_dump
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
+
begin
|
421
|
+
binlog_pos = Flydata::Parser::Mysql::MysqlDumpGeneratorNoMasterData.
|
422
|
+
new(de['mysql_data_entry_preference'].merge('tables' => target_tables)).dump(fp)
|
423
|
+
log_info_stdout(" -> Database dump done")
|
424
|
+
rescue Exception => e
|
425
|
+
#Catch all exceptions including SystemExit and Interrupt.
|
426
|
+
log_info_stdout "Quit while running mysqldump, deleting dump file..."
|
427
|
+
sync_fm.delete_dump_file
|
428
|
+
log_info_stdout "Dump file deleted, to restart the FlyData Agent, please run the 'flydata start' command "
|
429
|
+
raise e
|
430
|
+
end
|
420
431
|
call_block_or_return_io(fp, binlog_pos, &block)
|
421
432
|
else
|
422
433
|
Flydata::Parser::Mysql::MysqlDumpGeneratorNoMasterData.
|
@@ -581,15 +592,16 @@ EOM
|
|
581
592
|
|
582
593
|
state = :PROCESS
|
583
594
|
start_time = Time.now
|
584
|
-
log_info_stdout("Uploading data to Redshift...")
|
595
|
+
#log_info_stdout("Uploading data to Redshift...")
|
596
|
+
log_info_stdout("Processing and uploading your data on FlyData Servers...")
|
585
597
|
sleep 10
|
586
598
|
status = nil
|
587
599
|
prev_message =nil
|
588
600
|
while (status = check_server_status(tables))
|
589
601
|
if state == :PROCESS && status['state'] == 'uploading'
|
590
|
-
log_info_stdout(" ->
|
602
|
+
log_info_stdout(" -> Data processing done")
|
591
603
|
state = :UPLOAD
|
592
|
-
log_info_stdout("
|
604
|
+
log_info_stdout("Uploading remaining data chunks...")
|
593
605
|
end
|
594
606
|
|
595
607
|
#TODO This is based on a temporary option
|
@@ -683,8 +695,8 @@ EOM
|
|
683
695
|
end
|
684
696
|
|
685
697
|
def cleanup_sync_server(de, tables = [])
|
686
|
-
print
|
687
|
-
log_info("Cleaning the
|
698
|
+
print("Cleaning the queued items on the FlyData Servers.")
|
699
|
+
log_info("Cleaning the queued items on the FlyData Servers.")
|
688
700
|
worker = Thread.new do
|
689
701
|
begin
|
690
702
|
flydata.data_entry.cleanup_sync(de['id'], tables)
|
@@ -226,7 +226,7 @@ module Flydata
|
|
226
226
|
end
|
227
227
|
rescue Mysql2::Error => e
|
228
228
|
if e.message =~ /command denied to user/
|
229
|
-
log_warn_stderr("[WARNING]Cannot verify RDS retention period on
|
229
|
+
log_warn_stderr("[WARNING]Cannot verify RDS retention period on current MySQL user account.\n" +
|
230
230
|
"To see retention period, please run this on your RDS:\n" +
|
231
231
|
" $> call mysql.rds_show_configuration;\n" +
|
232
232
|
"Please verify that the hours is not nil and is at least #{BINLOG_RETENTION_HOURS} hours\n" +
|
@@ -268,7 +268,7 @@ EOS
|
|
268
268
|
line = buffered_line
|
269
269
|
buffered_line = nil
|
270
270
|
else
|
271
|
-
rawline = dump_io.readline
|
271
|
+
rawline = dump_io.readline.encode('utf-16', :undef => :replace, :invalid => :replace).encode('utf-8')
|
272
272
|
bytesize += rawline.bytesize
|
273
273
|
line = rawline.strip
|
274
274
|
end
|
@@ -65,6 +65,64 @@ module Flydata
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
68
|
+
describe '#generate_mysqldump' do
|
69
|
+
let (:flydata) { double('flydata') }
|
70
|
+
let (:dp) { double('dp') }
|
71
|
+
let (:default_data_port) { double('default_data_port') }
|
72
|
+
let (:default_sync_fm) { double('default_sync_fm') }
|
73
|
+
let (:default_dump_pos) do {
|
74
|
+
status: "DO_NOT_SKIP_DUMP"
|
75
|
+
}
|
76
|
+
end
|
77
|
+
let (:default_fp) { double('default_fp') }
|
78
|
+
let (:default_backup) { double('default_backup') }
|
79
|
+
let (:target_tables) { ["test_table_1"] }
|
80
|
+
let (:db_byte) { 1 }
|
81
|
+
let (:disk_byte) { 100 }
|
82
|
+
before do
|
83
|
+
expect(subject).to receive(:flydata).and_return(flydata)
|
84
|
+
expect(flydata).to receive(:data_port).and_return(dp)
|
85
|
+
expect(dp).to receive(:get).and_return(default_data_port)
|
86
|
+
allow(File).to receive(:exists?).and_return(false)
|
87
|
+
expect(default_sync_fm).to receive(:load_dump_pos).and_return(default_dump_pos)
|
88
|
+
expect(default_sync_fm).to receive(:dump_file_path).and_return(default_fp)
|
89
|
+
expect(default_sync_fm).to receive(:backup_dir).and_return(default_backup)
|
90
|
+
expect(subject).to receive(:target_tables).and_return(target_tables).at_least(:once)
|
91
|
+
expect(subject).to receive(:print)
|
92
|
+
expect(subject).to receive(:log_info)
|
93
|
+
expect(subject).to receive(:log_info_stdout).at_least(:once)
|
94
|
+
expect(subject).to receive(:ask_yes_no).and_return(true).at_least(:once)
|
95
|
+
Flydata::Parser::Mysql::DatabaseSizeCheck.any_instance.should_receive(:get_db_bytesize).and_return(db_byte)
|
96
|
+
Flydata::MysqlCompatibilityCheck.any_instance.should_receive(:check)
|
97
|
+
end
|
98
|
+
context 'with no stream option' do
|
99
|
+
before do
|
100
|
+
expect(subject).to receive(:free_disk_space).and_return(disk_byte)
|
101
|
+
expect(File).to receive(:dirname)
|
102
|
+
end
|
103
|
+
it 'will export to dump file' do
|
104
|
+
expect(subject).to receive(:call_block_or_return_io)
|
105
|
+
Flydata::Parser::Mysql::MysqlDumpGeneratorNoMasterData.any_instance.should_receive(:dump).with(default_fp)
|
106
|
+
|
107
|
+
subject.send(:generate_mysqldump, default_data_entry, default_sync_fm)
|
108
|
+
end
|
109
|
+
it 'will remove dump file on interrupt' do
|
110
|
+
expect(default_sync_fm).to receive(:delete_dump_file)
|
111
|
+
|
112
|
+
expect {
|
113
|
+
Flydata::Parser::Mysql::MysqlDumpGeneratorNoMasterData.any_instance.should_receive(:dump).and_raise(Interrupt)
|
114
|
+
subject.send(:generate_mysqldump, default_data_entry, default_sync_fm)
|
115
|
+
}.to raise_error
|
116
|
+
end
|
117
|
+
end
|
118
|
+
context 'with stream option' do
|
119
|
+
it 'will export to io' do
|
120
|
+
Flydata::Parser::Mysql::MysqlDumpGeneratorNoMasterData.any_instance.should_receive(:dump)
|
121
|
+
|
122
|
+
subject.send(:generate_mysqldump, default_data_entry, default_sync_fm, false)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
68
126
|
describe '#do_generate_table_ddl' do
|
69
127
|
before do
|
70
128
|
allow(subject).to receive(:data_entry).and_return(default_data_entry)
|
@@ -242,7 +242,7 @@ EOT
|
|
242
242
|
end
|
243
243
|
end
|
244
244
|
|
245
|
-
context 'when dump contains create table with multi inserts' do
|
245
|
+
context 'when dump contains create table with multi inserts and invalid utf8 byte sequences' do
|
246
246
|
let(:dump_content) { <<EOT
|
247
247
|
#{DUMP_HEADER}
|
248
248
|
|
@@ -265,7 +265,7 @@ CREATE TABLE `users_login` (
|
|
265
265
|
|
266
266
|
LOCK TABLES `users_login` WRITE;
|
267
267
|
/*!40000 ALTER TABLE `users_login` DISABLE KEYS */;
|
268
|
-
INSERT INTO `users_login` VALUES (15,46,'moodier','2001-10-02 08:18:08','1986-06-11 22:50:10'),(35,6,'missあいうえおteer','1991-10-15 19:38:07','1970-10-01 22:03:10'),(52,33,'sub\\\\field','1972-08-23 20:16:08','1974-10-10 23:28:11');
|
268
|
+
INSERT INTO `users_login` VALUES (15,46,'moodier\xED\xB1\xA2','2001-10-02 08:18:08','1986-06-11 22:50:10'),(35,6,'missあいうえおteer','1991-10-15 19:38:07','1970-10-01 22:03:10'),(52,33,'sub\\\\field','1972-08-23 20:16:08','1974-10-10 23:28:11');
|
269
269
|
INSERT INTO `users_login` VALUES (373,31,'out\\'swearing','1979-10-07 08:10:08','2006-02-22 16:26:04'),(493,8,'schizophrenic','1979-07-06 07:34:07','1970-08-09 01:21:01');
|
270
270
|
/*!40000 ALTER TABLE `users_login` ENABLE KEYS */;
|
271
271
|
UNLOCK TABLES;
|
@@ -284,7 +284,7 @@ EOT
|
|
284
284
|
|
285
285
|
# insert_record_block
|
286
286
|
[
|
287
|
-
[ %
|
287
|
+
[ %W(15 46 moodier\uFFFD\uFFFD\uFFFD 2001-10-02\ 08:18:08 1986-06-11\ 22:50:10),
|
288
288
|
%w(35 6 missあいうえおteer 1991-10-15\ 19:38:07 1970-10-01\ 22:03:10),
|
289
289
|
%w(52 33 sub\\field 1972-08-23\ 20:16:08 1974-10-10\ 23:28:11),],
|
290
290
|
[ %w(373 31 out'swearing 1979-10-07\ 08:10:08 2006-02-22\ 16:26:04),
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flydata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Koichi Fujikawa
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2015-04-
|
15
|
+
date: 2015-04-09 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rest-client
|
@@ -632,7 +632,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
632
632
|
version: '0'
|
633
633
|
requirements: []
|
634
634
|
rubyforge_project:
|
635
|
-
rubygems_version: 2.
|
635
|
+
rubygems_version: 2.4.3
|
636
636
|
signing_key:
|
637
637
|
specification_version: 4
|
638
638
|
summary: FlyData Agent
|