diff --git a/lib/fluent/engine.rb b/lib/fluent/engine.rb index afac3167ca..5e45084a39 100644 --- a/lib/fluent/engine.rb +++ b/lib/fluent/engine.rb @@ -136,6 +136,10 @@ def flush! @root_agent.flush! end + def shift_to_limited_mode! + @root_agent.shift_to_limited_mode! + end + def now # TODO thread update Fluent::EventTime.now diff --git a/lib/fluent/plugin/in_tcp.rb b/lib/fluent/plugin/in_tcp.rb index bd2ea83e5b..ccc28209ec 100644 --- a/lib/fluent/plugin/in_tcp.rb +++ b/lib/fluent/plugin/in_tcp.rb @@ -101,6 +101,10 @@ def multi_workers_ready? true end + def limited_mode_ready? + true + end + def start super diff --git a/lib/fluent/plugin/in_udp.rb b/lib/fluent/plugin/in_udp.rb index c2d436115f..dd65526ffa 100644 --- a/lib/fluent/plugin/in_udp.rb +++ b/lib/fluent/plugin/in_udp.rb @@ -65,6 +65,10 @@ def multi_workers_ready? true end + def limited_mode_ready? + true + end + def start super diff --git a/lib/fluent/plugin/input.rb b/lib/fluent/plugin/input.rb index 7a6909f7a9..347e742f7c 100644 --- a/lib/fluent/plugin/input.rb +++ b/lib/fluent/plugin/input.rb @@ -70,6 +70,15 @@ def metric_callback(es) def multi_workers_ready? false end + + def limited_mode_ready? + false + end + + def shift_to_limited_mode! + raise "BUG: use shift_to_limited_mode although this plugin is not ready for the limited mode" unless limited_mode_ready? + event_emitter_force_limited_router + end end end end diff --git a/lib/fluent/plugin_helper/event_emitter.rb b/lib/fluent/plugin_helper/event_emitter.rb index ba089e485a..5c573d7299 100644 --- a/lib/fluent/plugin_helper/event_emitter.rb +++ b/lib/fluent/plugin_helper/event_emitter.rb @@ -26,6 +26,9 @@ module EventEmitter def router @_event_emitter_used_actually = true + + return Engine.root_agent.limited_router if @_event_emitter_force_limited_router + if @_event_emitter_lazy_init @router = @primary_instance.router end @@ -48,6 +51,10 @@ def event_emitter_used_actually? @_event_emitter_used_actually end + def event_emitter_force_limited_router + @_event_emitter_force_limited_router = true + end + def event_emitter_router(label_name) if label_name if label_name == "@ROOT" @@ -72,6 +79,7 @@ def initialize super @_event_emitter_used_actually = false @_event_emitter_lazy_init = false + @_event_emitter_force_limited_router = false @router = nil end diff --git a/lib/fluent/root_agent.rb b/lib/fluent/root_agent.rb index 1165dbadcf..513b6700bb 100644 --- a/lib/fluent/root_agent.rb +++ b/lib/fluent/root_agent.rb @@ -29,13 +29,13 @@ module Fluent # # RootAgent # | - # +------------+-------------+-------------+ - # | | | | - #