flydata 0.2.27 → 0.2.28
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 +5 -4
- data/lib/flydata/command/sync.rb +15 -10
- data/lib/flydata/compatibility_check.rb +4 -5
- data/lib/flydata/sync_file_manager.rb +24 -6
- data/spec/flydata/sync_file_manager_spec.rb +1 -0
- 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: bde8ac1d5079ec1086baca972d51548f98e5b96b
|
4
|
+
data.tar.gz: 5d6ddbacb6f4e16e9f502623f6c8a197efdf03f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 922db0c489085b5b86160658965b8154701f09ab826c5b5eed58547dcc61b13c89ebc1bbe98aba9eb44c63615dafb9039ca0e4214fbc31b6215466b82722ba3b
|
7
|
+
data.tar.gz: fdafc2ffdd7995f6c7c91e8af09845c58e3ac682924c79f23b2f5ce1108bc9a671f435ff7af985e55b74ed69e8f8b5ad22d8cd92ad73001f00c1b9353f1f7daa
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.28
|
data/flydata.gemspec
CHANGED
@@ -2,14 +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.2.28 ruby lib
|
5
6
|
|
6
7
|
Gem::Specification.new do |s|
|
7
8
|
s.name = "flydata"
|
8
|
-
s.version = "0.2.
|
9
|
+
s.version = "0.2.28"
|
9
10
|
|
10
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
11
13
|
s.authors = ["Koichi Fujikawa", "Masashi Miyazaki", "Matthew Luu", "Mak Inada", "Sriram NS"]
|
12
|
-
s.date = "2015-01-
|
14
|
+
s.date = "2015-01-16"
|
13
15
|
s.description = "FlyData Agent"
|
14
16
|
s.email = "sysadmin@flydata.com"
|
15
17
|
s.executables = ["fdmysqldump", "flydata", "serverinfo"]
|
@@ -144,8 +146,7 @@ Gem::Specification.new do |s|
|
|
144
146
|
]
|
145
147
|
s.homepage = "http://flydata.com/"
|
146
148
|
s.licenses = ["All right reserved."]
|
147
|
-
s.
|
148
|
-
s.rubygems_version = "2.0.14"
|
149
|
+
s.rubygems_version = "2.2.2"
|
149
150
|
s.summary = "FlyData Agent"
|
150
151
|
|
151
152
|
if s.respond_to? :specification_version then
|
data/lib/flydata/command/sync.rb
CHANGED
@@ -86,6 +86,8 @@ module Flydata
|
|
86
86
|
sync_fm.mysql_table_marshal_dump_path,
|
87
87
|
sync_fm.sync_info_file,
|
88
88
|
sync_fm.table_position_file_paths(*tables),
|
89
|
+
sync_fm.table_binlog_pos_paths(*tables),
|
90
|
+
sync_fm.table_binlog_pos_init_paths(*tables),
|
89
91
|
sync_fm.table_rev_file_paths(*tables)
|
90
92
|
]
|
91
93
|
delete_files << sync_fm.binlog_path if tables.empty?
|
@@ -352,20 +354,23 @@ EOM
|
|
352
354
|
db_bytesize = Flydata::Parser::Mysql::DatabaseSizeCheck.new(de['mysql_data_entry_preference']).get_db_bytesize
|
353
355
|
log_info_stdout(" -> #{as_size(db_bytesize)} (#{db_bytesize} byte)")
|
354
356
|
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
357
|
+
if file_dump
|
358
|
+
# check free disk space
|
359
|
+
free_disk_bytesize = free_disk_space(File.dirname(fp))
|
360
|
+
if (free_disk_bytesize - db_bytesize) < (1024 * 1024 * 1024) # 1GB
|
361
|
+
log_warn_stderr("!!WARNING There may not be enough disk space for a DB dump. We recommend 1GB free disk space after the dump. free disk space:#{as_size(free_disk_bytesize)}(#{free_disk_bytesize} byte) /" +
|
362
|
+
" db size:#{as_size(db_bytesize)}(#{db_bytesize} byte)")
|
363
|
+
unless ask_yes_no('Do you want to continue?')
|
364
|
+
log_warn_stderr("To change the dump file directory, delete '#' and modify the path of 'mysqldump_dir:' in '#{Preference::DataEntryPreference.conf_path(de)}'")
|
365
|
+
exit 1
|
366
|
+
end
|
363
367
|
end
|
364
368
|
end
|
365
369
|
|
370
|
+
|
366
371
|
log_info_stdout("Exporting data from database.")
|
367
372
|
log_info_stdout("This process can take hours depending on data size and load on your database. Please be patient...")
|
368
|
-
Flydata::MysqlCompatibilityCheck.new(dp, de['mysql_data_entry_preference'], fp).check
|
373
|
+
Flydata::MysqlCompatibilityCheck.new(dp, de['mysql_data_entry_preference'], dump_dir: fp, backup_dir: sync_fm.backup_dir).check
|
369
374
|
if file_dump
|
370
375
|
Flydata::Parser::Mysql::MysqlDumpGeneratorNoMasterData.
|
371
376
|
new(de['mysql_data_entry_preference']).dump(fp)
|
@@ -541,7 +546,7 @@ Thank you for using FlyData!
|
|
541
546
|
if de['mysql_data_entry_preference']['initial_sync']
|
542
547
|
sync_fm.save_binlog(info[:binlog_pos])
|
543
548
|
end
|
544
|
-
sync_fm.
|
549
|
+
sync_fm.install_table_binlog_files(de['mysql_data_entry_preference']['tables'].split(','))
|
545
550
|
sync_fm.reset_table_position_files(de['mysql_data_entry_preference']['tables'].split(','))
|
546
551
|
sync_fm.delete_dump_file
|
547
552
|
sync_fm.backup_dump_dir
|
@@ -81,7 +81,8 @@ module Flydata
|
|
81
81
|
def initialize(dp_hash, de_hash, options={})
|
82
82
|
super
|
83
83
|
@db_opts = [:host, :port, :username, :password, :database].inject({}) {|h, sym| h[sym] = de_hash[sym.to_s]; h}
|
84
|
-
@dump_dir = options[
|
84
|
+
@dump_dir = options[:dump_dir] || nil
|
85
|
+
@backup_dir = options[:backup_dir] || nil
|
85
86
|
end
|
86
87
|
|
87
88
|
def print_errors
|
@@ -187,10 +188,11 @@ module Flydata
|
|
187
188
|
write_errors = []
|
188
189
|
paths_to_check = ["~/.flydata"]
|
189
190
|
paths_to_check << @dump_dir unless @dump_dir.to_s.empty?
|
191
|
+
paths_to_check << @backup_dir unless @backup_dir.to_s.empty?
|
190
192
|
paths_to_check.each do |path|
|
191
193
|
full_path = File.expand_path(path)
|
192
194
|
full_path = File.dirname(full_path) unless File.directory?(full_path)
|
193
|
-
write_errors << full_path unless File.writable?(full_path)
|
195
|
+
write_errors << full_path unless File.writable?(full_path) and File.executable?(full_path)
|
194
196
|
end
|
195
197
|
unless write_errors.empty?
|
196
198
|
error_dir = write_errors.join(", ")
|
@@ -242,6 +244,3 @@ module Flydata
|
|
242
244
|
end
|
243
245
|
|
244
246
|
end
|
245
|
-
|
246
|
-
|
247
|
-
|
@@ -79,6 +79,16 @@ module Flydata
|
|
79
79
|
tables.map{|table| File.join(table_positions_dir_path, table + '.pos')}
|
80
80
|
end
|
81
81
|
|
82
|
+
def table_binlog_pos_paths(*tables)
|
83
|
+
tables.empty? ? Dir.glob(File.join(table_positions_dir_path, '*.binlog.pos')) :
|
84
|
+
tables.map{|table| File.join(table_positions_dir_path, table + '.binlog.pos')}
|
85
|
+
end
|
86
|
+
|
87
|
+
def table_binlog_pos_init_paths(*tables)
|
88
|
+
tables.empty? ? Dir.glob(File.join(table_positions_dir_path, '*.binlog.pos.init')) :
|
89
|
+
tables.map{|table| File.join(table_positions_dir_path, table + '.binlog.pos.init')}
|
90
|
+
end
|
91
|
+
|
82
92
|
# Read a sequence number from the table's position file,
|
83
93
|
# increment the number and pass the number to a block.
|
84
94
|
# After executing the block, saves the value to the position
|
@@ -184,14 +194,18 @@ module Flydata
|
|
184
194
|
end
|
185
195
|
end
|
186
196
|
|
187
|
-
def
|
197
|
+
def install_table_binlog_files(tables)
|
188
198
|
FileUtils.mkdir_p(table_positions_dir_path) unless Dir.exists?(table_positions_dir_path)
|
189
199
|
tables.each do |table_name|
|
190
|
-
|
191
|
-
|
192
|
-
|
200
|
+
file_name = table_name + ".binlog.pos"
|
201
|
+
src_file = File.join(dump_dir, file_name)
|
202
|
+
if ! File.exists?(src_file)
|
203
|
+
raise "#{src_file} does not exist. Error!!"
|
193
204
|
end
|
194
|
-
FileUtils.mv(
|
205
|
+
FileUtils.mv(src_file, table_positions_dir_path)
|
206
|
+
# save the position at initial sync. this is used for repair if
|
207
|
+
# necessary.
|
208
|
+
FileUtils.cp(File.join(table_positions_dir_path, file_name), File.join(table_positions_dir_path, file_name + ".init"))
|
195
209
|
end
|
196
210
|
end
|
197
211
|
|
@@ -204,7 +218,11 @@ module Flydata
|
|
204
218
|
FileUtils.mkdir_p(backup_dir) unless Dir.exists?(backup_dir)
|
205
219
|
dest_dir = File.join(backup_dir, Time.now.strftime("%Y%m%d%H%M%S"))
|
206
220
|
FileUtils.mkdir(dest_dir)
|
207
|
-
FileUtils.mv(dump_dir, dest_dir)
|
221
|
+
FileUtils.mv(Dir.glob("#{dump_dir}/*"), dest_dir)
|
222
|
+
end
|
223
|
+
|
224
|
+
def backup_dir
|
225
|
+
BACKUP_DIR
|
208
226
|
end
|
209
227
|
|
210
228
|
private
|
@@ -60,6 +60,7 @@ module Flydata
|
|
60
60
|
default_data_entry['mysql_data_entry_preference'].delete('mysqldump_dir')
|
61
61
|
end
|
62
62
|
it do
|
63
|
+
stub_const('Flydata::FileUtil::SyncFileManager::DUMP_DIR', File.join(Flydata::FLYDATA_HOME, 'dump'))
|
63
64
|
expect(default_sfm.dump_file_path).to eq(
|
64
65
|
File.join(Flydata::FLYDATA_HOME, 'dump', 'flydata_sync_mysql.dump'))
|
65
66
|
end
|
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.2.
|
4
|
+
version: 0.2.28
|
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-01-
|
15
|
+
date: 2015-01-16 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rest-client
|
@@ -566,7 +566,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
566
566
|
version: '0'
|
567
567
|
requirements: []
|
568
568
|
rubyforge_project:
|
569
|
-
rubygems_version: 2.
|
569
|
+
rubygems_version: 2.2.2
|
570
570
|
signing_key:
|
571
571
|
specification_version: 4
|
572
572
|
summary: FlyData Agent
|