Class: Flydata::Parser::Mysql::MysqlDumpGeneratorMasterData

Inherits:
MysqlDumpGenerator show all
Defined in:
lib/flydata/parser/mysql/dump_parser.rb

Instance Method Summary collapse

Methods inherited from MysqlDumpGenerator

#initialize

Constructor Details

This class inherits a constructor from Flydata::Parser::Mysql::MysqlDumpGenerator

Instance Method Details

#dump(file_path) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/flydata/parser/mysql/dump_parser.rb', line 57

def dump(file_path)
  cmd = "#{@dump_cmd} -r #{file_path}"
  o, e, s = Open3.capture3(cmd)
  e.to_s.each_line {|l|  puts l unless /^Warning:/ =~ l } unless e.to_s.empty?
  unless s.exitstatus == 0
    if File.exists?(file_path)
      File.open(file_path, 'r') {|f| f.each_line{|l| puts l}}
      FileUtils.rm(file_path)
    end
    raise "Failed to run mysqldump command."
  end
  unless File.exists?(file_path)
    raise "mysqldump file does not exist. Something wrong..."
  end
  if File.size(file_path) == 0
    raise "mysqldump file is empty. Something wrong..."
  end
  true
end

#generate_dump_cmd(conf) ⇒ Object



77
78
79
# File 'lib/flydata/parser/mysql/dump_parser.rb', line 77

def generate_dump_cmd(conf)
  Util::MysqlUtil.generate_mysqldump_with_master_data_cmd(conf)
end