flydata 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/bin/flydata +1 -0
  4. data/flydata-core/lib/flydata-core/core_ext/module.rb +1 -1
  5. data/flydata-core/lib/flydata-core/core_ext/object.rb +1 -1
  6. data/flydata.gemspec +21 -5
  7. data/lib/flydata.rb +5 -8
  8. data/lib/flydata/api/data_entry.rb +2 -0
  9. data/lib/flydata/api/data_port.rb +2 -0
  10. data/lib/flydata/api/redshift_cluster.rb +2 -0
  11. data/lib/flydata/api_client.rb +3 -0
  12. data/lib/flydata/cli.rb +13 -2
  13. data/lib/flydata/command/base.rb +6 -0
  14. data/lib/flydata/command/conf.rb +3 -0
  15. data/lib/flydata/command/crontab.rb +3 -0
  16. data/lib/flydata/command/encrypt.rb +3 -0
  17. data/lib/flydata/command/kill_all.rb +3 -0
  18. data/lib/flydata/command/login.rb +2 -0
  19. data/lib/flydata/command/restart.rb +3 -0
  20. data/lib/flydata/command/routine.rb +3 -0
  21. data/lib/flydata/command/sender.rb +2 -0
  22. data/lib/flydata/command/setlogdel.rb +4 -1
  23. data/lib/flydata/command/setup.rb +7 -2
  24. data/lib/flydata/command/start.rb +3 -0
  25. data/lib/flydata/command/status.rb +3 -0
  26. data/lib/flydata/command/stop.rb +3 -0
  27. data/lib/flydata/command/sync.rb +10 -3
  28. data/lib/flydata/command/version.rb +2 -0
  29. data/lib/flydata/{command_logger.rb → command_loggable.rb} +0 -0
  30. data/lib/flydata/compatibility_check.rb +1 -1
  31. data/lib/flydata/credentials.rb +2 -0
  32. data/lib/flydata/fluent-plugins/in_mysql_binlog_flydata.rb +8 -9
  33. data/lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb +1 -1
  34. data/lib/flydata/fluent-plugins/mysql/binlog_query_dispatcher.rb +1 -1
  35. data/lib/flydata/fluent-plugins/mysql/binlog_query_handler.rb +1 -1
  36. data/lib/flydata/fluent-plugins/mysql/binlog_record_dispatcher.rb +2 -2
  37. data/lib/flydata/fluent-plugins/mysql/binlog_record_handler.rb +1 -1
  38. data/lib/flydata/fluent-plugins/mysql/ddl_query_handler.rb +1 -1
  39. data/lib/flydata/fluent-plugins/mysql/dml_record_handler.rb +1 -1
  40. data/lib/flydata/helpers.rb +0 -10
  41. data/lib/flydata/heroku.rb +3 -0
  42. data/lib/flydata/output/forwarder.rb +1 -1
  43. data/lib/flydata/parser/mysql/dump_parser.rb +29 -31
  44. data/lib/flydata/sync_file_manager.rb +230 -232
  45. data/spec/fly_data_model_spec.rb +1 -0
  46. data/spec/flydata/api/data_entry_spec.rb +1 -0
  47. data/spec/flydata/api_client_spec.rb +18 -0
  48. data/spec/flydata/cli_spec.rb +1 -0
  49. data/spec/flydata/command/base_spec.rb +44 -0
  50. data/spec/flydata/command/conf_spec.rb +21 -0
  51. data/spec/flydata/command/crontab_spec.rb +17 -0
  52. data/spec/flydata/command/encrypt_spec.rb +28 -0
  53. data/spec/flydata/command/kill_all_spec.rb +17 -0
  54. data/spec/flydata/command/login_spec.rb +21 -0
  55. data/spec/flydata/command/restart_spec.rb +17 -0
  56. data/spec/flydata/command/routine_spec.rb +29 -0
  57. data/spec/flydata/command/sender_spec.rb +7 -2
  58. data/spec/flydata/command/setlogdel_spec.rb +18 -0
  59. data/spec/flydata/command/setup_spec.rb +44 -0
  60. data/spec/flydata/command/start_spec.rb +17 -0
  61. data/spec/flydata/command/status_spec.rb +17 -0
  62. data/spec/flydata/command/stop_spec.rb +17 -0
  63. data/spec/flydata/command/sync_spec.rb +1 -0
  64. data/spec/flydata/command/version_spec.rb +14 -0
  65. data/spec/flydata/fluent-plugins/in_mysql_binlog_flydata_spec.rb +1 -1
  66. data/spec/flydata/parser/mysql/dump_parser_spec.rb +23 -73
  67. data/spec/flydata/sync_file_manager_spec.rb +150 -152
  68. metadata +19 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3aabc1598aa6770f9f4238bae95ef42b1577c0aa
4
- data.tar.gz: 5ba322b53b34ffaf0986542a8071c103c4d2d881
3
+ metadata.gz: 2f947592ebedab5272b94129436953e9fac61c46
4
+ data.tar.gz: b676c7dd72b765244ef0b99d9cd44c584c0126c1
5
5
  SHA512:
6
- metadata.gz: a1b6059f259512e9d7f190f9bc37c51905979adab22310f4782e92b3ebbc7156673ce48259d7f7ba6a43ae2d40755b2836b59adffd3b36d035a8ceb0ff1b9c4b
7
- data.tar.gz: 129df374f7bbba7ed5dc70eb23bd52b46ee683521cd391c7fa0c9440f9c56649d2761210be0eca31cb8d1c05c5ed55a9ba8aadacec84085d73460af1b950303f
6
+ metadata.gz: 9ed77e0b82c8d0c2dbe3e2be510a0fe0b9f3d9bfef08788443b26085989cfaa566348e7537c393786b8d451a5d687dc3f5c9b32c7d8a9c45508f0f7d014099b3
7
+ data.tar.gz: d3073aba50dff2fbf45a613c5e64c15297bc65f380c284511acddd3af775cd33f8dbaf7acdaed023b2426c9459922b321482a2121968a53afb43ed060d680f57
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.5
1
+ 0.3.6
data/bin/flydata CHANGED
@@ -5,6 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  require 'rubygems'
7
7
  require 'flydata'
8
+ require 'flydata/cli'
8
9
 
9
10
  args = ARGV.dup
10
11
  ARGV.clear # for 'gets'
@@ -1 +1 @@
1
- require_relative 'module/include'
1
+ require 'flydata-core/core_ext/module/include'
@@ -1 +1 @@
1
- require_relative 'object/prepend'
1
+ require 'flydata-core/core_ext/object/prepend'
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.3.6 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "flydata"
8
- s.version = "0.3.5"
9
+ s.version = "0.3.6"
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-02-28"
14
+ s.date = "2015-03-04"
13
15
  s.description = "FlyData Agent"
14
16
  s.email = "sysadmin@flydata.com"
15
17
  s.executables = ["fdmysqldump", "flydata", "serverinfo"]
@@ -89,7 +91,7 @@ Gem::Specification.new do |s|
89
91
  "lib/flydata/command/stop.rb",
90
92
  "lib/flydata/command/sync.rb",
91
93
  "lib/flydata/command/version.rb",
92
- "lib/flydata/command_logger.rb",
94
+ "lib/flydata/command_loggable.rb",
93
95
  "lib/flydata/compatibility_check.rb",
94
96
  "lib/flydata/credentials.rb",
95
97
  "lib/flydata/cron.rb",
@@ -127,9 +129,24 @@ Gem::Specification.new do |s|
127
129
  "spec/fluent_plugins_spec_helper.rb",
128
130
  "spec/fly_data_model_spec.rb",
129
131
  "spec/flydata/api/data_entry_spec.rb",
132
+ "spec/flydata/api_client_spec.rb",
130
133
  "spec/flydata/cli_spec.rb",
134
+ "spec/flydata/command/base_spec.rb",
135
+ "spec/flydata/command/conf_spec.rb",
136
+ "spec/flydata/command/crontab_spec.rb",
137
+ "spec/flydata/command/encrypt_spec.rb",
138
+ "spec/flydata/command/kill_all_spec.rb",
139
+ "spec/flydata/command/login_spec.rb",
140
+ "spec/flydata/command/restart_spec.rb",
141
+ "spec/flydata/command/routine_spec.rb",
131
142
  "spec/flydata/command/sender_spec.rb",
143
+ "spec/flydata/command/setlogdel_spec.rb",
144
+ "spec/flydata/command/setup_spec.rb",
145
+ "spec/flydata/command/start_spec.rb",
146
+ "spec/flydata/command/status_spec.rb",
147
+ "spec/flydata/command/stop_spec.rb",
132
148
  "spec/flydata/command/sync_spec.rb",
149
+ "spec/flydata/command/version_spec.rb",
133
150
  "spec/flydata/compatibility_check_spec.rb",
134
151
  "spec/flydata/fluent-plugins/idle_event_detector_spec.rb",
135
152
  "spec/flydata/fluent-plugins/in_mysql_binlog_flydata_spec.rb",
@@ -150,8 +167,7 @@ Gem::Specification.new do |s|
150
167
  ]
151
168
  s.homepage = "http://flydata.com/"
152
169
  s.licenses = ["All right reserved."]
153
- s.require_paths = ["lib"]
154
- s.rubygems_version = "2.0.14"
170
+ s.rubygems_version = "2.4.3"
155
171
  s.summary = "FlyData Agent"
156
172
 
157
173
  if s.respond_to? :specification_version then
data/lib/flydata.rb CHANGED
@@ -1,25 +1,22 @@
1
1
  # load_path settings
2
2
  def append_load_path_if_not_exist(new_lib_path)
3
- absolute_path = File.realpath(new_lib_path)
4
- $LOAD_PATH.unshift absolute_path unless $LOAD_PATH.include? absolute_path
3
+ expanded_path = File.expand_path(new_lib_path)
4
+ $LOAD_PATH.unshift expanded_path unless $LOAD_PATH.include? expanded_path
5
5
  end
6
- flydata_top_dir = File.realpath('../../', __FILE__)
6
+ flydata_top_dir = File.expand_path('../../', __FILE__)
7
7
  flydata_core_dir = File.join(flydata_top_dir, 'flydata-core')
8
- flydata_core_lib_dir = File.realpath('lib', flydata_core_dir)
8
+ flydata_core_lib_dir = File.expand_path('lib', flydata_core_dir)
9
9
  append_load_path_if_not_exist(flydata_core_lib_dir)
10
10
 
11
11
  # require common libs
12
12
  require 'active_support/core_ext/string'
13
- require 'active_support/dependencies'
14
13
  require 'active_support/time'
15
14
  require 'highline/import'
16
15
  require 'readline'
17
16
  require 'json'
18
17
  require 'pp'
19
18
 
20
- # require all flydata libs
21
- lib_dir = File.absolute_path(File.dirname(__FILE__))
22
- ActiveSupport::Dependencies.autoload_paths << lib_dir
19
+ require 'flydata/heroku'
23
20
 
24
21
  module Flydata
25
22
  FLYDATA_DEBUG = !!(ENV['FLYDATA_DEBUG'])
@@ -1,3 +1,5 @@
1
+ require 'flydata/api/base'
2
+
1
3
  module Flydata
2
4
  module Api
3
5
  class DataEntry < Base
@@ -1,3 +1,5 @@
1
+ require 'flydata/api/base'
2
+
1
3
  module Flydata
2
4
  module Api
3
5
  class DataPort < Base
@@ -1,3 +1,5 @@
1
+ require 'flydata/api/base'
2
+
1
3
  module Flydata
2
4
  module Api
3
5
  class RedshiftCluster < Base
@@ -1,5 +1,7 @@
1
1
  require 'rest_client'
2
2
  require 'singleton'
3
+ require 'flydata/credentials'
4
+ require 'flydata/helpers'
3
5
 
4
6
  module Flydata
5
7
  FLYDATA_API_HOST = ENV['FLYDATA_API_HOST'] || 'https://flydata.co'
@@ -39,6 +41,7 @@ module Flydata
39
41
  # high level api
40
42
  def method_missing(cls_name, *args, &block)
41
43
  method_name = args.shift.to_s
44
+ require File.join("flydata/api", cls_name.to_s)
42
45
  api_cls = "Flydata::Api::#{cls_name.to_s.camelize}".constantize
43
46
  api_cls.new(self)
44
47
  end
data/lib/flydata/cli.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'slop'
2
- require_relative 'command_logger'
3
- require_relative 'errors'
2
+ require 'flydata/command_loggable'
3
+ require 'flydata/errors'
4
+ require 'flydata/helpers'
4
5
 
5
6
  module Flydata
6
7
  class Cli
@@ -29,6 +30,7 @@ module Flydata
29
30
  first_arg = @args.shift
30
31
  cmd, sub_cmd = parse_command(first_arg)
31
32
  begin
33
+ require_command_source(cmd)
32
34
  cmd_cls = "Flydata::Command::#{cmd.capitalize}".constantize
33
35
  rescue NameError
34
36
  # NameError is raised when the constant is not defined in its target
@@ -66,5 +68,14 @@ module Flydata
66
68
  def parse_command(cmd)
67
69
  cmd.split(':')
68
70
  end
71
+ COMMAND_DIR = 'flydata/command'
72
+ def require_command_source(cmd)
73
+ source_path = File.join(COMMAND_DIR, cmd)
74
+ begin
75
+ require source_path
76
+ rescue LoadError
77
+ # ignore
78
+ end
79
+ end
69
80
  end
70
81
  end
@@ -1,5 +1,8 @@
1
1
  require 'slop'
2
2
  require 'flydata/api_client'
3
+ require 'flydata/command_loggable'
4
+ require 'flydata/preference/data_entry_preference'
5
+
3
6
 
4
7
  module Flydata
5
8
  module Command
@@ -22,6 +25,7 @@ module Flydata
22
25
  if Flydata::Preference::DataEntryPreference.conf_exists?(de)
23
26
  Flydata::Preference::DataEntryPreference.load_conf(de)
24
27
  else
28
+ Flydata::Preference::DataEntryPreference.filter_data_entry(de)
25
29
  de
26
30
  end
27
31
  end
@@ -29,6 +33,8 @@ module Flydata
29
33
  def register_crontab
30
34
  data_entries = retrieve_data_entries
31
35
  if data_entries.any?{|e| e['log_deletion']}
36
+ # require on demand to avoid mutual require issue
37
+ require 'flydata/command/crontab'
32
38
  Flydata::Command::Crontab.new.run
33
39
  end
34
40
  end
@@ -1,3 +1,6 @@
1
+ require 'flydata/command/base'
2
+ require 'flydata/preference/data_entry_preference'
3
+
1
4
  module Flydata
2
5
  module Command
3
6
  class Conf < Base
@@ -1,3 +1,6 @@
1
+ require 'flydata/command/base'
2
+ require 'flydata/cron'
3
+
1
4
  module Flydata
2
5
  module Command
3
6
  class Crontab < Base
@@ -1,3 +1,6 @@
1
+ require 'flydata/command/base'
2
+ require 'flydata/util/encryptor'
3
+
1
4
  module Flydata
2
5
  module Command
3
6
  class Encrypt < Base
@@ -1,3 +1,6 @@
1
+ require 'flydata/command/base'
2
+ require 'flydata/command/sender'
3
+
1
4
  module Flydata
2
5
  module Command
3
6
  class Kill_all < Base
@@ -1,3 +1,5 @@
1
+ require 'flydata/command/base'
2
+
1
3
  module Flydata
2
4
  module Command
3
5
  class Login < Base
@@ -1,3 +1,6 @@
1
+ require 'flydata/command/base'
2
+ require 'flydata/command/sender'
3
+
1
4
  module Flydata
2
5
  module Command
3
6
  class Restart < Base
@@ -1,3 +1,6 @@
1
+ require 'flydata/command/base'
2
+ require 'flydata/log_monitor'
3
+
1
4
  module Flydata
2
5
  module Command
3
6
  class Routine < Base
@@ -1,4 +1,6 @@
1
1
  require 'flydata/compatibility_check'
2
+ require 'flydata/command/base'
3
+ require 'flydata/command/sync'
2
4
 
3
5
  module Flydata
4
6
  module Command
@@ -1,3 +1,6 @@
1
+ require 'flydata/command/base'
2
+ require 'flydata/command/login'
3
+
1
4
  module Flydata
2
5
  module Command
3
6
  class Setlogdel < Base
@@ -16,7 +19,7 @@ module Flydata
16
19
  data_entries = retrieve_data_entries
17
20
  if data_entries.size < 1
18
21
  puts("There are no registered entries.")
19
- puts("You need to create a data entry by flydata setup command.")
22
+ puts("You need to create a data entry with flydata setup command.")
20
23
  return nil
21
24
  end
22
25
  choices = data_entries.map {|e|
@@ -1,4 +1,9 @@
1
- require_relative 'sync'
1
+ require 'flydata/command/base'
2
+ require 'flydata/command/conf'
3
+ require 'flydata/command/login'
4
+ require 'flydata/command/sender'
5
+ require 'flydata/helpers'
6
+ require 'flydata/sync_file_manager'
2
7
 
3
8
  module Flydata
4
9
  module Command
@@ -92,7 +97,7 @@ What's next?
92
97
  true
93
98
  elsif has_registered_redshift_mysql_data_entries?
94
99
  de = retrieve_data_entries.first
95
- if File.exists?(Flydata::FileUtil::SyncFileManager.new(de).binlog_path)
100
+ if File.exists?(Flydata::SyncFileManager.new(de).binlog_path)
96
101
  sender = Flydata::Command::Sender.new
97
102
  if sender.process_exist?
98
103
  sender.stop(quiet: true)
@@ -1,3 +1,6 @@
1
+ require 'flydata/command/base'
2
+ require 'flydata/command/sender'
3
+
1
4
  module Flydata
2
5
  module Command
3
6
  class Start < Base
@@ -1,3 +1,6 @@
1
+ require 'flydata/command/base'
2
+ require 'flydata/command/sender'
3
+
1
4
  module Flydata
2
5
  module Command
3
6
  class Status < Base
@@ -1,3 +1,6 @@
1
+ require 'flydata/command/base'
2
+ require 'flydata/command/sender'
3
+
1
4
  module Flydata
2
5
  module Command
3
6
  class Stop < Base
@@ -2,11 +2,18 @@ require 'fiber'
2
2
  require 'msgpack'
3
3
  require 'open3'
4
4
  require 'mysql2'
5
+ require 'rest_client'
5
6
  require 'sys/filesystem'
6
- require 'flydata/sync_file_manager'
7
+ require 'flydata/command/base'
8
+ require 'flydata/command/conf'
9
+ require 'flydata/command/sender'
7
10
  require 'flydata/compatibility_check'
11
+ require 'flydata/errors'
12
+ require 'flydata/helpers'
8
13
  require 'flydata/output/forwarder'
9
14
  require 'flydata/parser/mysql/dump_parser'
15
+ require 'flydata/preference/data_entry_preference'
16
+ require 'flydata/sync_file_manager'
10
17
  require 'flydata/util/mysql_util'
11
18
  require 'flydata-core/table_def'
12
19
  #require 'ruby-prof'
@@ -603,7 +610,7 @@ EOM
603
610
  start_time = Time.now
604
611
  log_info_stdout("Waiting for the server buffer to get empty.")
605
612
  prev_message =nil
606
- while (status = check_server_status(tables)) && (status['state'] == 'processing')
613
+ while (status = check_server_status(tables)) && (status['state'].nil? || status['state'] == 'processing')
607
614
  prev_message = status['message']
608
615
  if timeout > 0 && Time.now - start_time > timeout
609
616
  raise ServerDataProcessingTimeout.new
@@ -815,7 +822,7 @@ Thank you for using FlyData!
815
822
  end
816
823
 
817
824
  def create_sync_file_manager(de = data_entry)
818
- Flydata::FileUtil::SyncFileManager.new(de)
825
+ SyncFileManager.new(de)
819
826
  end
820
827
 
821
828
  def verify_input_tables(input_tables, all_tables)
@@ -1,3 +1,5 @@
1
+ require 'flydata/command/base'
2
+
1
3
  module Flydata
2
4
  module Command
3
5
  class Version < Base
@@ -1,5 +1,5 @@
1
1
  require 'mysql2'
2
- require 'flydata/command_logger'
2
+ require 'flydata/command_loggable'
3
3
  require 'flydata/util/mysql_util'
4
4
 
5
5
  module Flydata
@@ -1,3 +1,5 @@
1
+ require 'flydata/helpers'
2
+
1
3
  module Flydata
2
4
  class Credentials
3
5
  include Helpers
@@ -5,18 +5,17 @@ require 'binlog'
5
5
  require 'kodama'
6
6
 
7
7
  # Load client library(flydata/cli/lib)
8
- lib = File.absolute_path(File.dirname(__FILE__) + '/../..')
8
+ lib = File.expand_path(File.dirname(__FILE__), '/../..')
9
9
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
10
10
  require 'flydata'
11
11
  require 'flydata/sync_file_manager'
12
12
  require 'flydata/util/mysql_util'
13
-
14
- require_relative 'preference'
15
- require_relative 'mysql/binlog_position_file'
16
- require_relative 'mysql/binlog_record_dispatcher'
17
- require_relative 'mysql/context'
18
- require_relative 'idle_event_detector'
19
- require_relative 'mysql/table_meta'
13
+ require 'flydata/fluent-plugins/preference'
14
+ require 'flydata/fluent-plugins/mysql/binlog_position_file'
15
+ require 'flydata/fluent-plugins/mysql/binlog_record_dispatcher'
16
+ require 'flydata/fluent-plugins/mysql/context'
17
+ require 'flydata/fluent-plugins/idle_event_detector'
18
+ require 'flydata/fluent-plugins/mysql/table_meta'
20
19
 
21
20
  #Monkey-patch fluentd class (EngineClass) to support shutdown for input plugin.
22
21
  #This will be called when USR1 signal is received
@@ -73,7 +72,7 @@ class MysqlBinlogFlydataInput < MysqlBinlogInput
73
72
  @tables << table unless @tables.include?(table)
74
73
  @omit_events[table] = [:delete]
75
74
  end
76
- @sync_fm = Flydata::FileUtil::SyncFileManager.new(nil) # Passing nil for data_entry as this class does not use methods which require data_entry
75
+ @sync_fm = Flydata::SyncFileManager.new(nil) # Passing nil for data_entry as this class does not use methods which require data_entry
77
76
 
78
77
  #Remove tables that do not have pos files
79
78
  new_tables = @sync_fm.get_new_table_list(@tables, "pos")