Class: Flydata::SourceMysql::GenerateSourceDump

Inherits:
Flydata::Source::GenerateSourceDump show all
Defined in:
lib/flydata/source_mysql/generate_source_dump.rb

Instance Attribute Summary

Attributes inherited from Flydata::Source::GenerateSourceDump

#dp

Instance Method Summary collapse

Methods inherited from Flydata::Source::GenerateSourceDump

inherited, #initialize

Methods inherited from Flydata::Source::Component

#initialize

Constructor Details

This class inherits a constructor from Flydata::Source::GenerateSourceDump

Instance Method Details

#confirmation_itemsObject



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/flydata/source_mysql/generate_source_dump.rb', line 23

def confirmation_items
  mp = de['mysql_data_entry_preference']
  items = {
    "host"     => mp['host'],
    "port"     => mp['port'],
    "username" => mp['username'],
    "database" => mp['database'],
  }
  items["ssl"] = "Yes" if mp['ssl_ca']

  items
end

#dump(tables, file_path = nil, &src_pos_callback) ⇒ Object



41
42
43
44
45
46
47
48
49
50
# File 'lib/flydata/source_mysql/generate_source_dump.rb', line 41

def dump(tables, file_path = nil, &src_pos_callback)
  opts = de['mysql_data_entry_preference'].merge({"tables" => tables})
  dump_generator = Parser::MysqlDumpGeneratorNoMasterData.new(opts)

  dump_generator.dump(file_path) do |io, binlog_hash|
    source_pos = FlydataCore::Mysql::BinlogPos.new(binlog_hash)
    src_pos_callback.call(io, source_pos)
  end
  nil
end

#dump_size(tables) ⇒ Object



36
37
38
39
# File 'lib/flydata/source_mysql/generate_source_dump.rb', line 36

def dump_size(tables)
  opts = de['mysql_data_entry_preference'].merge({"tables" => tables})
  SyncDatabaseSizeCheck.new(opts).get_db_bytesize
end

#run_compatibility_check(dump_dir, backup_dir) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/flydata/source_mysql/generate_source_dump.rb', line 12

def run_compatibility_check(dump_dir, backup_dir)
  %w(host username database).each do |k|
    if de['mysql_data_entry_preference'][k].to_s.empty?
      raise "'#{k}' is required. Set the value in the conf file " +
            "-> #{Flydata::Preference::DataEntryPreference.conf_path(de)}"
    end
  end

  MysqlCompatibilityCheck.new(dp, de['mysql_data_entry_preference'], dump_dir: dump_dir, backup_dir: backup_dir).check
end