fluent-plugin-mysql-appender 0.2.3 → 0.2.4
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/fluent-plugin-mysql-appender.gemspec +1 -1
- data/lib/fluent/plugin/in_mysql_appender_multi.rb +14 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52f77ca494835a1c58067843c2f4fe8a86335dab
|
4
|
+
data.tar.gz: a83ed3ed13e719326ed0e78f312fd32787e8de5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf9ef3d4bb176d5d33c53cf9faa47b1edd13c9ca0b67f685e03dc640ff214d5d29efdbb4bd4f189fdbdd185b78df8e8314fdcdee1b65d8b78ef10903048b4971
|
7
|
+
data.tar.gz: 1835caa09b49109b27642e0983c649133aa49b92232ecbd69099d57563b8fa505eaba2ddfcf0f1a05e8c610cfc47773b455f81b95f49d308e2ee8e5d04a1ae34
|
@@ -36,6 +36,7 @@ module Fluent
|
|
36
36
|
def start
|
37
37
|
begin
|
38
38
|
@threads = []
|
39
|
+
@mutex = Mutex.new
|
39
40
|
YAML.load_file(@yaml_path).each do |config|
|
40
41
|
@threads << Thread.new {
|
41
42
|
poll(config)
|
@@ -56,12 +57,12 @@ module Fluent
|
|
56
57
|
|
57
58
|
def poll(config)
|
58
59
|
begin
|
59
|
-
|
60
|
-
|
60
|
+
@mutex.synchronize {
|
61
|
+
$log.info "mysql_replicator_multi: polling start. :tag=>#{format_tag(config)}"
|
62
|
+
}
|
61
63
|
con = get_connection()
|
62
64
|
last_id = config['last_id']
|
63
65
|
loop do
|
64
|
-
$log.info "loop start in #{format_tag(config)}."
|
65
66
|
rows_count = 0
|
66
67
|
start_time = Time.now
|
67
68
|
rows, con = query(get_query(config, last_id), con)
|
@@ -85,13 +86,17 @@ module Fluent
|
|
85
86
|
end
|
86
87
|
con.close
|
87
88
|
elapsed_time = sprintf("%0.02f", Time.now - start_time)
|
88
|
-
|
89
|
+
@mutex.synchronize {
|
90
|
+
$log.info "mysql_appender_multi: finished execution :tag=>#{tag} :rows_count=>#{rows_count} :last_id=>#{last_id} :elapsed_time=>#{elapsed_time} sec"
|
91
|
+
}
|
89
92
|
sleep @interval
|
90
93
|
end
|
91
94
|
rescue StandardError => e
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
+
@mutex.synchronize {
|
96
|
+
$log.error "mysql_appender_multi: failed to execute query. :config=>#{masked_config}"
|
97
|
+
$log.error "error: #{e.message}"
|
98
|
+
$log.error e.backtrace.join("\n")
|
99
|
+
}
|
95
100
|
end
|
96
101
|
end
|
97
102
|
|
@@ -112,7 +117,8 @@ module Fluent
|
|
112
117
|
end
|
113
118
|
|
114
119
|
def format_tag(config)
|
115
|
-
|
120
|
+
add_db = config['td_database'] ? config['td_database'] + '.' : ''
|
121
|
+
"#{tag}.#{add_db}#{config['table_name']}"
|
116
122
|
end
|
117
123
|
|
118
124
|
def get_connection
|