lib/fluent/plugin/buf_file.rb in fluentd-1.8.1 vs lib/fluent/plugin/buf_file.rb in fluentd-1.9.0.rc1

- old
+ new

@@ -17,10 +17,11 @@ require 'fileutils' require 'fluent/plugin/buffer' require 'fluent/plugin/buffer/file_chunk' require 'fluent/system_config' +require 'fluent/variable_store' module Fluent module Plugin class FileBuffer < Fluent::Plugin::Buffer Plugin.register_buffer('file', self) @@ -41,23 +42,24 @@ config_set_default :total_limit_size, DEFAULT_TOTAL_LIMIT_SIZE config_param :file_permission, :string, default: nil # '0644' config_param :dir_permission, :string, default: nil # '0755' - @@buffer_paths = {} - def initialize super @symlink_path = nil @multi_workers_available = false @additional_resume_path = nil @buffer_path = nil + @variable_store = nil end def configure(conf) super + @variable_store = Fluent::VariableStore.fetch_or_build(:buf_file) + multi_workers_configured = owner.system_config.workers > 1 ? true : false using_plugin_root_dir = false unless @path if root_dir = owner.plugin_root_dir @@ -67,17 +69,17 @@ raise Fluent::ConfigError, "buffer path is not configured. specify 'path' in <buffer>" end end type_of_owner = Plugin.lookup_type_from_class(@_owner.class) - if @@buffer_paths.has_key?(@path) && !called_in_test? - type_using_this_path = @@buffer_paths[@path] + if @variable_store.has_key?(@path) && !called_in_test? + type_using_this_path = @variable_store[@path] raise ConfigError, "Other '#{type_using_this_path}' plugin already use same buffer path: type = #{type_of_owner}, buffer path = #{@path}" end @buffer_path = @path - @@buffer_paths[@buffer_path] = type_of_owner + @variable_store[@buffer_path] = type_of_owner specified_directory_exists = File.exist?(@path) && File.directory?(@path) unexisting_path_for_directory = !File.exist?(@path) && !@path.include?('.*') if specified_directory_exists || unexisting_path_for_directory # directory @@ -123,10 +125,12 @@ super end def stop - @@buffer_paths.delete(@buffer_path) + if @variable_store + @variable_store.delete(@buffer_path) + end super end def persistent?