diff --git a/lib/fluent/load.rb b/lib/fluent/load.rb index 874f3b3b73..200f09c8ec 100644 --- a/lib/fluent/load.rb +++ b/lib/fluent/load.rb @@ -21,7 +21,6 @@ require 'fluent/env' require 'fluent/version' require 'fluent/log' -require 'fluent/status' require 'fluent/config' require 'fluent/engine' require 'fluent/rpc' diff --git a/lib/fluent/output.rb b/lib/fluent/output.rb index 491d8dd34e..fea06dc937 100644 --- a/lib/fluent/output.rb +++ b/lib/fluent/output.rb @@ -227,9 +227,6 @@ def configure(conf) @secondary.secondary_init(self) end - - Status.register(self, "queue_size") { @buffer.queue_size } - Status.register(self, "emit_count") { @emit_count } end def start diff --git a/lib/fluent/plugin/in_status.rb b/lib/fluent/plugin/in_status.rb deleted file mode 100644 index c6aefeb5a9..0000000000 --- a/lib/fluent/plugin/in_status.rb +++ /dev/null @@ -1,76 +0,0 @@ -# -# Fluentd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -module Fluent - class StatusInput < Input - Plugin.register_input('status', self) - - def initialize - super - end - - config_param :emit_interval, :time, :default => 60 - config_param :tag, :string - - class TimerWatcher < Coolio::TimerWatcher - def initialize(interval, repeat, log, &callback) - @callback = callback - @log = log - super(interval, repeat) - end - - def on_timer - @callback.call - rescue - # TODO log? - @log.error $!.to_s - @log.error_backtrace - end - end - - def configure(conf) - super - $log.warn "in_status plugin will be removed v0.14 or later. Use in_monitor_agent instead" - end - - def start - @loop = Coolio::Loop.new - @timer = TimerWatcher.new(@emit_interval, true, log, &method(:on_timer)) - @loop.attach(@timer) - @thread = Thread.new(&method(:run)) - end - - def shutdown - @loop.watchers.each {|w| w.detach } - @loop.stop - @thread.join - end - - def run - @loop.run - rescue - log.error "unexpected error", :error=>$!.to_s - log.error_backtrace - end - - def on_timer - now = Engine.now - Status.each {|record| - router.emit(@tag, now, record) - } - end - end -end diff --git a/lib/fluent/status.rb b/lib/fluent/status.rb deleted file mode 100644 index 5388f09a4c..0000000000 --- a/lib/fluent/status.rb +++ /dev/null @@ -1,48 +0,0 @@ -# -# Fluentd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -module Fluent - class StatusClass - def initialize - @entries = {} - @mutex = Mutex.new - end - - def register(instance, name, &block) - @mutex.synchronize { - (@entries[instance.object_id] ||= {})[name] = block - } - nil - end - - def each(&block) - @mutex.synchronize { - @entries.each {|obj_id,hash| - record = {} - hash.each_pair {|name,block| - record[name] = block.call - } - block.call(record) - } - } - end - end - - # Don't use this class from plugins. - # The interface may be changed - Status = StatusClass.new -end - diff --git a/test/plugin/test_in_status.rb b/test/plugin/test_in_status.rb deleted file mode 100644 index 5ca754ff3f..0000000000 --- a/test/plugin/test_in_status.rb +++ /dev/null @@ -1,39 +0,0 @@ -require_relative '../helper' -require 'fluent/test' - -class StatusInputTest < Test::Unit::TestCase - def setup - Fluent::Test.setup - end - - CONFIG = %[ - emit_interval 1 - tag t1 - ] - - def create_driver(conf=CONFIG) - Fluent::Test::InputTestDriver.new(Fluent::StatusInput).configure(conf) - end - - def test_configure - d = create_driver - assert_equal(1, d.instance.emit_interval) - assert_equal("t1", d.instance.tag) - end - - def test_emit - stub(Fluent::Status).each { |b| - b.call("answer" => "42") - } - - d = create_driver - d.run do - sleep 2 - end - - emits = d.emits - assert(emits.length > 0) - assert_equal({"answer" => "42"}, emits[0][2]) - assert(emits[0][1].is_a?(Fluent::EventTime)) - end -end