fluent-plugin-mysql-appender 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/example/mysql_multi_table_to_tresure_data.md +2 -0
- data/example/mysql_single_table_to_treasure_data.md +1 -0
- data/fluent-plugin-mysql-appender.gemspec +1 -1
- data/lib/fluent/plugin/in_mysql_appender.rb +21 -15
- data/lib/fluent/plugin/in_mysql_appender_multi.rb +23 -17
- 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: 9bea290735b18887dd55d09efceaa35bc43b0193
|
4
|
+
data.tar.gz: 18d31c5eaea15dbeea7c3e4b95f78ac1ec63fbc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fa61e94df8ce4ba988f60d56a2284230933e49feaf8f3fe17945aca4f19d250aaf226f3f6b5870b543e923bc5d6eefaf4ea5d9080ca74aec3b6a31c3d33c899
|
7
|
+
data.tar.gz: 5c6ff76d81458910aac3b0fa1df2376f276008360126dcb024476a1a3fcca46615dbdfc8dc625dc616185b012261ffb3553f99fdedbd04d626201999d8bea154
|
@@ -50,6 +50,7 @@ Sample "in_tables.yml" is below.
|
|
50
50
|
- column1
|
51
51
|
- column2
|
52
52
|
last_id: -1
|
53
|
+
buffer: 10 # last 10 records don't append (default 0).
|
53
54
|
td_database: sample_datasets
|
54
55
|
|
55
56
|
- table_name: test_tbl2
|
@@ -61,5 +62,6 @@ Sample "in_tables.yml" is below.
|
|
61
62
|
- column1
|
62
63
|
- column2
|
63
64
|
last_id: -1
|
65
|
+
buffer: 10 # last 10 records don't append (default 0).
|
64
66
|
td_database: sample_datasets
|
65
67
|
```
|
@@ -25,6 +25,7 @@ It is a guide to replicate single mysql table to treasure data.
|
|
25
25
|
time_column created_at # specify TIME column.
|
26
26
|
limit 1000 # query limit
|
27
27
|
last_id -1 # specify primary_key start
|
28
|
+
buffer 10 # last 10 records don't append (default 0).
|
28
29
|
</source>
|
29
30
|
|
30
31
|
<match appender.*.*>
|
@@ -26,6 +26,7 @@ module Fluent
|
|
26
26
|
config_param :primary_key, :string, :default => 'id'
|
27
27
|
config_param :interval, :string, :default => '1m'
|
28
28
|
config_param :tag, :string, :default => nil
|
29
|
+
config_param :buffer, :integer, :defalut => 0
|
29
30
|
|
30
31
|
def configure(conf)
|
31
32
|
super
|
@@ -63,22 +64,27 @@ module Fluent
|
|
63
64
|
start_time = Time.now
|
64
65
|
select_query = @query.gsub(/"/,'') + " where #{primary_key} > #{last_id} order by #{primary_key} asc limit #{limit}"
|
65
66
|
rows, con = query(select_query, con)
|
66
|
-
rows.
|
67
|
-
|
68
|
-
|
69
|
-
td_time = Engine.now
|
70
|
-
else
|
71
|
-
if row[@time_column].kind_of?(Time) then
|
72
|
-
td_time = row[@time_column].to_i
|
73
|
-
else
|
74
|
-
td_time = Time.parse(row[@time_column].to_s).to_i
|
75
|
-
end
|
67
|
+
if @buffer < rows.size then
|
68
|
+
if index == (rows.size - @buffer) then
|
69
|
+
break
|
76
70
|
end
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
71
|
+
rows.each_with_index do |row, index|
|
72
|
+
tag = format_tag(@tag, {:event => :insert})
|
73
|
+
if @time_column.nil? then
|
74
|
+
td_time = Engine.now
|
75
|
+
else
|
76
|
+
if row[@time_column].kind_of?(Time) then
|
77
|
+
td_time = row[@time_column].to_i
|
78
|
+
else
|
79
|
+
td_time = Time.parse(row[@time_column].to_s).to_i
|
80
|
+
end
|
81
|
+
end
|
82
|
+
row.each {|k, v| row[k] = v.to_s if v.is_a?(Time) || v.is_a?(Date) || v.is_a?(BigDecimal)}
|
83
|
+
router.emit(tag, td_time, row)
|
84
|
+
rows_count += 1
|
85
|
+
if index == rows.size - @buffer - 1
|
86
|
+
@last_id = row[@primary_key]
|
87
|
+
end
|
82
88
|
end
|
83
89
|
end
|
84
90
|
con.close
|
@@ -29,11 +29,11 @@ module Fluent
|
|
29
29
|
@interval = Config.time_value(@interval)
|
30
30
|
|
31
31
|
if @yaml_path.nil?
|
32
|
-
raise Fluent::ConfigError, "mysql_appender_multi: missing 'yaml_path' parameter
|
32
|
+
raise Fluent::ConfigError, "mysql_appender_multi: missing 'yaml_path' parameter."
|
33
33
|
end
|
34
34
|
|
35
35
|
if !File.exist?(@yaml_path)
|
36
|
-
raise Fluent::ConfigError, "mysql_appender_multi:
|
36
|
+
raise Fluent::ConfigError, "mysql_appender_multi: No such file in 'yaml_path'."
|
37
37
|
end
|
38
38
|
|
39
39
|
if @tag.nil?
|
@@ -66,6 +66,7 @@ module Fluent
|
|
66
66
|
def poll(config)
|
67
67
|
begin
|
68
68
|
tag = format_tag(config)
|
69
|
+
buffer = config['buffer'] || 0
|
69
70
|
@mutex.synchronize {
|
70
71
|
$log.info "mysql_replicator_multi: polling start. :tag=>#{tag}"
|
71
72
|
}
|
@@ -75,21 +76,26 @@ module Fluent
|
|
75
76
|
rows_count = 0
|
76
77
|
start_time = Time.now
|
77
78
|
rows, con = query(get_query(config, last_id), con)
|
78
|
-
rows.
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
79
|
+
if buffer < rows.size then
|
80
|
+
rows.each_with_index do |row, index|
|
81
|
+
if index == (rows.size - buffer) then
|
82
|
+
break
|
83
|
+
end
|
84
|
+
if config['time_column'].nil? then
|
85
|
+
td_time = Engine.now
|
86
|
+
else
|
87
|
+
if row[config['time_column']].kind_of?(Time) then
|
88
|
+
td_time = row[config['time_column']].to_i
|
89
|
+
else
|
90
|
+
td_time = Time.parse(row[config['time_column']].to_s).to_i
|
91
|
+
end
|
92
|
+
end
|
93
|
+
row.each {|k, v| row[k] = v.to_s if v.is_a?(Time) || v.is_a?(Date) || v.is_a?(BigDecimal)}
|
94
|
+
router.emit(tag, td_time, row)
|
95
|
+
rows_count += 1
|
96
|
+
if index == (rows.size - buffer - 1)
|
97
|
+
last_id = row[config['primary_key']]
|
98
|
+
end
|
93
99
|
end
|
94
100
|
end
|
95
101
|
con.close
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-mysql-appender
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TERASAKI Tsuyoshi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|