Class: Flydata::Command::Sync
- Includes:
- Helpers
- Defined in:
- lib/flydata/command/sync.rb
Constant Summary collapse
- CREATE_TABLE_OPTION =
!!(ENV['FLYDATA_CREATE_TABLE_OPTION']) || false
- INSERT_PROGRESS_INTERVAL =
1000
- STATUS_PARSING =
for dump.pos file
'PARSING'
- STATUS_COMPLETE =
'COMPLETE'
Instance Method Summary collapse
- #check ⇒ Object
- #complete ⇒ Object
- #reset ⇒ Object
- #run ⇒ Object
-
#skip ⇒ Object
skip initial sync.
Methods included from Helpers
development?, env_mode, env_suffix, flydata_api_host_file, flydata_conf_file, format_menu_list, parse_command, print_usage, to_command_class
Methods inherited from Base
#ask_input_table_name, #ask_yes_no, #choose_one, #flydata, #initialize, #newline, #register_crontab, #retrieve_data_entries, #separator
Constructor Details
This class inherits a constructor from Flydata::Command::Base
Instance Method Details
#check ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/flydata/command/sync.rb', line 36 def check de = retrieve_data_entries.first ret = do_check(de) if ret['complete'] puts "No buffer data on FlyData. #{ret.inspect}" true else puts "Now processing data on FlyData. #{ret.inspect}" false end end |
#complete ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/flydata/command/sync.rb', line 48 def complete de = retrieve_data_entries.first sync_fm = Flydata::FileUtil::SyncFileManager.new(de) info = sync_fm.load_dump_pos if info[:status] == STATUS_COMPLETE sync_fm.save_binlog(info[:binlog_pos]) Flydata::Command::Sender.new.start else raise "Initial sync status is not complete. Try running 'flydata sync'." end end |
#reset ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/flydata/command/sync.rb', line 28 def reset de = retrieve_data_entries.first sync_fm = Flydata::FileUtil::SyncFileManager.new(de) [sync_fm.dump_file_path, sync_fm.dump_pos_path, sync_fm.binlog_path, sync_fm.mysql_table_marshal_dump_path, sync_fm.table_position_file_paths].flatten.each do |path| FileUtils.rm(path) if File.exists?(path) end end |
#run ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/flydata/command/sync.rb', line 17 def run de = retrieve_data_entries.first raise "There are no data entry." unless de case de['type'] when 'RedshiftMysqlDataEntry' sync_mysql_to_redshift(de) else raise "No supported data entry. Only mysql-redshift sync is supported." end end |
#skip ⇒ Object
skip initial sync
61 62 63 64 65 66 67 68 69 |
# File 'lib/flydata/command/sync.rb', line 61 def skip de = retrieve_data_entries.first sync_fm = Flydata::FileUtil::SyncFileManager.new(de) binlog_path = sync_fm.binlog_path `touch #{binlog_path}` puts "Created an empty binlog position file." puts "-> #{binlog_path}" puts "Run 'flydata start' to start continuous sync." end |