fluent-output-router 0.9.2 → 0.9.3
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 +8 -8
- data/lib/fluent/plugin/out_router.rb +31 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWRhOGYwN2Y4MjUwNjYyYjViNDA2ZjA2NzMzZDk0NWRmZWI2NTFiNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTg0ZjM5NmY2MDcxOGMwMzdjOWU4NDlkMDk4ZjM5MGQyNDM0NGY3Yg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NjcyNWZlY2EyMmFjZjJlODNhZDgxNzRhYjIxOTU0ZWQ3MWYzMTcwMGZlMTU0
|
10
|
+
ZTk4Y2ZlMGMxODRmMTliODYyZmQxMzI0ODA3YjZmYTBhOWY4YmUyMWExMTA1
|
11
|
+
ZjE3ZTllNzQ5M2Y2MTY2YThjM2U5Y2RlNjBhNjdmZWQzOGY1YmE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGI0OGU0NTYwODNlNjljOTA4NTYxMTZjMmJhNmY3N2Y5MzIzZDcxNzBiZmU5
|
14
|
+
ZTUwZDJmMjk5N2Q1OTc2NDdmMmI1MWRhN2I0MGUzM2FiY2RmZDE5MmEyN2M0
|
15
|
+
NjFjNmJjNjc4OGQwYzY1MDdiZDlkMTZhOWJkYTRmZDkzZTUxNzM=
|
@@ -17,12 +17,13 @@
|
|
17
17
|
require 'erb'
|
18
18
|
require 'rubygems'
|
19
19
|
require 'json'
|
20
|
+
require 'thread'
|
20
21
|
|
21
22
|
module Fluent
|
22
23
|
class RouterOutput < Fluent::Output
|
23
24
|
|
24
25
|
Fluent::Plugin.register_output('router', self)
|
25
|
-
MIN_REAPER_INTERVAL =
|
26
|
+
MIN_REAPER_INTERVAL = 15 #sec
|
26
27
|
ROUTER_STATE_FILE = "router_state.json"
|
27
28
|
|
28
29
|
def initialize
|
@@ -30,6 +31,7 @@ module Fluent
|
|
30
31
|
@outputs = {}
|
31
32
|
@last_used_time = {}
|
32
33
|
@last_reaper_run = Time.now
|
34
|
+
@semaphore = Mutex.new
|
33
35
|
end
|
34
36
|
|
35
37
|
def configure(conf)
|
@@ -71,18 +73,25 @@ module Fluent
|
|
71
73
|
|
72
74
|
private
|
73
75
|
|
76
|
+
# start_output is synchroned with a mutex
|
77
|
+
# to avoid any concurrency problems if the input plugin is multithreaded
|
78
|
+
# for example: the scribe input plugin is multitreaded by default
|
74
79
|
def start_output(key)
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
80
|
+
@semaphore.synchronize do
|
81
|
+
unless @outputs[key]
|
82
|
+
log "Starting a new output of type " + @output_config['type'] +
|
83
|
+
" for key #{key}"
|
84
|
+
@outputs[key] = Fluent::Plugin.new_output @output_config['type']
|
85
|
+
@last_used_time[key] = Time.now
|
86
|
+
config = @output_config.clone
|
87
|
+
template! config, :key => key
|
88
|
+
out = @outputs[key]
|
89
|
+
out.configure config
|
90
|
+
out.start
|
91
|
+
@state_serializer.store(@outputs.keys)
|
92
|
+
end
|
93
|
+
@outputs[key]
|
94
|
+
end
|
86
95
|
end
|
87
96
|
|
88
97
|
def stop_output(key)
|
@@ -99,7 +108,6 @@ module Fluent
|
|
99
108
|
conf.elements.each { |e| mark_used e }
|
100
109
|
end
|
101
110
|
|
102
|
-
# MUTABLE. WHICH ALSO MEANS IT IS TERRIBLE.
|
103
111
|
def template!(conf, keys)
|
104
112
|
conf.each do |k,v|
|
105
113
|
case v
|
@@ -120,13 +128,18 @@ module Fluent
|
|
120
128
|
|
121
129
|
# This is the reaper that is used to avoids resource leaks
|
122
130
|
# It will stop any active output plugin that does not get any input
|
131
|
+
# The code in run_reaper is synchroned with a mutex
|
132
|
+
# to avoid any concurrency problems if the input plugin is multithreaded
|
133
|
+
# for example: the scribe input plugin is multitreaded by default
|
123
134
|
def run_reaper(now)
|
124
135
|
if now - @last_reaper_run > MIN_REAPER_INTERVAL then
|
125
|
-
@
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
136
|
+
@last_reaper_run = now
|
137
|
+
@semaphore.synchronize do
|
138
|
+
@last_used_time.each {|key, stored_time|
|
139
|
+
if now - stored_time > @inactivity_timeout then
|
140
|
+
stop_output(key)
|
141
|
+
end }
|
142
|
+
end
|
130
143
|
end
|
131
144
|
end
|
132
145
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-output-router
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Almroth
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|