flydata 0.5.11 → 0.5.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/flydata.gemspec +3 -3
- data/lib/flydata/command/sync.rb +1 -5
- data/lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb +1 -1
- data/lib/flydata/fluent-plugins/mysql/binlog_record_handler.rb +35 -117
- data/lib/flydata/fluent-plugins/mysql/ddl_query_handler.rb +36 -0
- data/lib/flydata/fluent-plugins/mysql/drop_database_query_handler.rb +1 -2
- data/lib/flydata/fluent-plugins/mysql/truncate_table_query_handler.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82270f47e1280076e3dc0b40a86cc548e0da6636
|
4
|
+
data.tar.gz: bed0f9307f53602e2956369b5419e3173410d8bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e765cd79b44de76a883867a81718e9c7b4ab4834c0ae97d59faa57728bea4e1888bc97d8c993edd6103ea6c5da1786ca33b58f18f532c5eb04c3b6e518f95a2f
|
7
|
+
data.tar.gz: e62f777a303bae1fee4810bc1a1133ef2ca3d12b212ab4932666605e822d57f3ebcaf0ced16433c1b9894e43a286bd824edf30a210f24ab0a764a706420429d4
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.12
|
data/flydata.gemspec
CHANGED
@@ -2,16 +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.5.
|
5
|
+
# stub: flydata 0.5.12 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "flydata"
|
9
|
-
s.version = "0.5.
|
9
|
+
s.version = "0.5.12"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Koichi Fujikawa", "Masashi Miyazaki", "Matthew Luu", "Mak Inada", "Sriram NS"]
|
14
|
-
s.date = "2015-10-
|
14
|
+
s.date = "2015-10-08"
|
15
15
|
s.description = "FlyData Agent"
|
16
16
|
s.email = "sysadmin@flydata.com"
|
17
17
|
s.executables = ["fdmysqldump", "flydata", "serverinfo"]
|
data/lib/flydata/command/sync.rb
CHANGED
@@ -598,15 +598,11 @@ EOS
|
|
598
598
|
complete(de)
|
599
599
|
end
|
600
600
|
|
601
|
+
# Don't call the method unless init sync needs to be run for a table
|
601
602
|
def sync_mysql_to_redshift(de, options = {})
|
602
603
|
dp = flydata.data_port.get
|
603
604
|
sync_fm = create_sync_file_manager(de)
|
604
605
|
|
605
|
-
# Check client condition
|
606
|
-
if @full_initial_sync && !options[:sync_resumed] && File.exists?(sync_fm.binlog_path)
|
607
|
-
raise "Already synchronized. If you want to do initial sync, run 'flydata sync:reset'"
|
608
|
-
end
|
609
|
-
|
610
606
|
# Copy template if not exists
|
611
607
|
unless Flydata::Preference::DataEntryPreference.conf_exists?(de)
|
612
608
|
Flydata::Command::Conf.new.copy_templates
|
@@ -2,7 +2,7 @@ require 'flydata/parser_provider'
|
|
2
2
|
require 'flydata/fluent-plugins/mysql/ddl_query_handler'
|
3
3
|
|
4
4
|
module Mysql
|
5
|
-
class AlterTableQueryHandler <
|
5
|
+
class AlterTableQueryHandler < TableDdlQueryHandler
|
6
6
|
PATTERN = /^ALTER TABLE/i
|
7
7
|
|
8
8
|
def initialize(context)
|
@@ -4,8 +4,14 @@ require 'flydata/mysql/binlog_position'
|
|
4
4
|
require 'flydata-core/record/record'
|
5
5
|
|
6
6
|
module Mysql
|
7
|
-
|
8
7
|
class BinlogRecordHandler
|
8
|
+
TABLE_NAME = :table_name # A Flydata JSON tag to specify a table name
|
9
|
+
TYPE = :type
|
10
|
+
SEQ = :seq
|
11
|
+
RESPECT_ORDER = :respect_order
|
12
|
+
SRC_POS = :src_pos
|
13
|
+
TABLE_REV = :table_rev
|
14
|
+
V = :v # FlyData record format version
|
9
15
|
|
10
16
|
def initialize(context)
|
11
17
|
@context = context
|
@@ -53,7 +59,7 @@ module Mysql
|
|
53
59
|
|
54
60
|
def emit_record(type, record)
|
55
61
|
return unless acceptable_db?(record)
|
56
|
-
return
|
62
|
+
return unless record["table_name"].nil? or acceptable_table?(record, record["table_name"])
|
57
63
|
|
58
64
|
check_empty_binlog
|
59
65
|
|
@@ -62,135 +68,47 @@ module Mysql
|
|
62
68
|
return if records.nil? # skip
|
63
69
|
records = [records] unless records.kind_of?(Array)
|
64
70
|
|
65
|
-
|
66
|
-
|
71
|
+
table = records.first[TABLE_NAME] || record['table_name']
|
72
|
+
raise "Missing table name. #{record}" if table.to_s.empty?
|
73
|
+
return unless acceptable_table?(record, table) && acceptable_event?(type, table)
|
67
74
|
|
68
|
-
|
69
|
-
|
70
|
-
if @context.current_binlog_file.to_s.empty?
|
71
|
-
if @first_empty_binlog
|
72
|
-
$log.warn "Binlog file name is empty. Rotate event not received!"
|
73
|
-
@first_empty_binlog = false
|
74
|
-
end
|
75
|
-
else
|
76
|
-
@first_empty_binlog = true
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
class FlydataJsonHandlerFactory
|
81
|
-
|
82
|
-
def self.create(records, record, context, type, increment_table_rev)
|
83
|
-
table = records.first[:table_name] || record['table_name']
|
84
|
-
database = records.first[:db_name] || record['db_name']
|
85
|
-
|
86
|
-
case table
|
87
|
-
when nil
|
88
|
-
DatabaseFlydataJsonHandler.new(records, record, context, type)
|
89
|
-
else
|
90
|
-
TableFlydataJsonHandler.new(records, record, context, type, increment_table_rev)
|
91
|
-
end
|
92
|
-
end
|
75
|
+
table_rev = @context.table_revs[table]
|
76
|
+
position = record['next_position'] - record['event_length']
|
93
77
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
SRC_POS = :src_pos
|
100
|
-
TABLE_REV = :table_rev
|
101
|
-
V = :v # FlyData record format version
|
102
|
-
DB_NAME = :db_name
|
103
|
-
|
104
|
-
def initialize(records, record, context, type, increment_table_rev=nil)
|
105
|
-
@context = context
|
106
|
-
end
|
107
|
-
|
108
|
-
def emit(timestamp, row)
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
class TableFlydataJsonHandler < FlydataJsonHandler
|
113
|
-
def initialize(records, record, context, type, increment_table_rev=nil)
|
114
|
-
super
|
115
|
-
table = records.first[TABLE_NAME] || record['table_name']
|
116
|
-
raise "Missing table name. #{record}" if table.to_s.empty?
|
117
|
-
|
118
|
-
return unless acceptable_event?(type, table)
|
119
|
-
|
120
|
-
table_rev = @context.table_revs[table]
|
121
|
-
position = record['next_position'] - record['event_length']
|
122
|
-
|
123
|
-
# Add common information to each record
|
124
|
-
records.each do |r|
|
125
|
-
if increment_table_rev
|
126
|
-
table_rev = @context.sync_fm.increment_table_rev(table, table_rev)
|
127
|
-
@context.table_revs[table] = table_rev
|
128
|
-
end
|
129
|
-
r[TYPE] = type
|
130
|
-
r[RESPECT_ORDER] = true
|
131
|
-
r[TABLE_NAME] = table
|
132
|
-
r[SRC_POS] = "#{@context.current_binlog_file}\t#{position}"
|
133
|
-
r[TABLE_REV] = table_rev
|
134
|
-
r[V] = FlydataCore::Record::V2
|
135
|
-
end
|
136
|
-
|
137
|
-
# Use binlog's timestamp
|
138
|
-
timestamp = record["timestamp"].to_i
|
139
|
-
records.each do |row|
|
140
|
-
emit(timestamp, row)
|
78
|
+
# Add common information to each record
|
79
|
+
records.each do |r|
|
80
|
+
if opt[:increment_table_rev]
|
81
|
+
table_rev = @context.sync_fm.increment_table_rev(table, table_rev)
|
82
|
+
@context.table_revs[table] = table_rev
|
141
83
|
end
|
84
|
+
r[TYPE] = type
|
85
|
+
r[RESPECT_ORDER] = true
|
86
|
+
r[TABLE_NAME] = table
|
87
|
+
r[SRC_POS] = "#{@context.current_binlog_file}\t#{position}"
|
88
|
+
r[TABLE_REV] = table_rev
|
89
|
+
r[V] = FlydataCore::Record::V2
|
142
90
|
end
|
143
91
|
|
144
|
-
|
92
|
+
# Use binlog's timestamp
|
93
|
+
timestamp = record["timestamp"].to_i
|
94
|
+
records.each do |row|
|
145
95
|
@context.sync_fm.increment_and_save_table_position(row[TABLE_NAME]) do |seq|
|
146
96
|
row[SEQ] = seq
|
147
97
|
Fluent::Engine.emit(@context.tag, timestamp, row)
|
148
98
|
end
|
149
99
|
end
|
150
|
-
|
151
|
-
private
|
152
|
-
def acceptable_event?(type, table)
|
153
|
-
@context.omit_events[table].nil? || !@context.omit_events[table].include?(type)
|
154
|
-
end
|
155
|
-
|
156
100
|
end
|
157
101
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
position = record['next_position'] - record['event_length']
|
166
|
-
|
167
|
-
# Add common information to each record
|
168
|
-
records.each do |r|
|
169
|
-
r[TYPE] = type
|
170
|
-
r[RESPECT_ORDER] = true
|
171
|
-
r[SRC_POS] = "#{@context.current_binlog_file}\t#{position}"
|
172
|
-
r[V] = FlydataCore::Record::V2
|
173
|
-
end
|
174
|
-
|
175
|
-
# Use binlog's timestamp
|
176
|
-
timestamp = record["timestamp"].to_i
|
177
|
-
records.each do |row|
|
178
|
-
emit(timestamp, row)
|
102
|
+
def check_empty_binlog
|
103
|
+
#Log one warning per consecutive records that have empty binlog filename
|
104
|
+
if @context.current_binlog_file.to_s.empty?
|
105
|
+
if @first_empty_binlog
|
106
|
+
$log.warn "Binlog file name is empty. Rotate event not received!"
|
107
|
+
@first_empty_binlog = false
|
179
108
|
end
|
109
|
+
else
|
110
|
+
@first_empty_binlog = true
|
180
111
|
end
|
181
|
-
|
182
|
-
def emit(timestamp, row)
|
183
|
-
Fluent::Engine.emit(@context.tag, timestamp, row)
|
184
|
-
end
|
185
|
-
|
186
|
-
private
|
187
|
-
#TODO: No support on DS for database records currently so no record should be emitted
|
188
|
-
def acceptable_event?(type)
|
189
|
-
false
|
190
|
-
end
|
191
|
-
|
192
112
|
end
|
193
|
-
|
194
113
|
end
|
195
|
-
|
196
114
|
end
|
@@ -25,4 +25,40 @@ class DdlQueryHandler < BinlogQueryHandler
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
class TableDdlQueryHandler < DdlQueryHandler
|
29
|
+
end
|
30
|
+
|
31
|
+
class DatabaseDdlQueryHandler < DdlQueryHandler
|
32
|
+
def emit_record(type, record)
|
33
|
+
return unless acceptable_db?(record)
|
34
|
+
|
35
|
+
check_empty_binlog
|
36
|
+
|
37
|
+
opt = {}
|
38
|
+
records = yield(opt) # The block may set options as necessary
|
39
|
+
return if records.nil? # skip
|
40
|
+
records = [records] unless records.kind_of?(Array)
|
41
|
+
|
42
|
+
database = records.first[DB_NAME] || record['db_name']
|
43
|
+
|
44
|
+
return unless acceptable_event?(type)
|
45
|
+
|
46
|
+
position = record['next_position'] - record['event_length']
|
47
|
+
|
48
|
+
# Add common information to each record
|
49
|
+
records.each do |r|
|
50
|
+
r[TYPE] = type
|
51
|
+
r[RESPECT_ORDER] = true
|
52
|
+
r[SRC_POS] = "#{@context.current_binlog_file}\t#{position}"
|
53
|
+
r[V] = FlydataCore::Record::V2
|
54
|
+
end
|
55
|
+
|
56
|
+
# Use binlog's timestamp
|
57
|
+
timestamp = record["timestamp"].to_i
|
58
|
+
records.each do |row|
|
59
|
+
Fluent::Engine.emit(@context.tag, timestamp, row)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
28
64
|
end
|
@@ -1,8 +1,7 @@
|
|
1
|
-
require 'flydata/parser_provider'
|
2
1
|
require 'flydata/fluent-plugins/mysql/ddl_query_handler'
|
3
2
|
|
4
3
|
module Mysql
|
5
|
-
class DropDatabaseQueryHandler <
|
4
|
+
class DropDatabaseQueryHandler < DatabaseDdlQueryHandler
|
6
5
|
# For MySQL, database and schema are exchangable
|
7
6
|
PATTERN = /^DROP DATABASE|SCHEMA/i
|
8
7
|
|
@@ -2,7 +2,7 @@ require 'flydata/parser_provider'
|
|
2
2
|
require 'flydata/fluent-plugins/mysql/ddl_query_handler'
|
3
3
|
|
4
4
|
module Mysql
|
5
|
-
class TruncateTableQueryHandler <
|
5
|
+
class TruncateTableQueryHandler < TableDdlQueryHandler
|
6
6
|
PATTERN = /^TRUNCATE/i
|
7
7
|
|
8
8
|
def initialize(context)
|
@@ -22,4 +22,4 @@ module Mysql
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
25
|
-
end
|
25
|
+
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.5.
|
4
|
+
version: 0.5.12
|
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-10-
|
15
|
+
date: 2015-10-08 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rest-client
|