Module: Fluent::Plugin::FileOutput::SymlinkBufferMixin

Defined in:
lib/fluent/plugin/out_file.rb

Instance Method Summary collapse

Instance Method Details

#generate_chunk(metadata) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/fluent/plugin/out_file.rb', line 94

def generate_chunk()
  chunk = super
  # "symlink" feature is to link from symlink_path to the latest file chunk. Records with latest
  # timekey will be appended into that file chunk. On the other side, resumed file chunks might NOT
  # have timekey, especially in the cases that resumed file chunks are generated by Fluentd v0.12.
  # These chunks will be enqueued immediately, and will be flushed soon.
  if chunk. == @latest_metadata
    sym_path = @_output_plugin_for_symlink.extract_placeholders(@_symlink_path, chunk)
    FileUtils.mkdir_p(File.dirname(sym_path), mode: @_output_plugin_for_symlink.dir_perm)
    if @_output_plugin_for_symlink.symlink_path_use_relative
      relative_path = Pathname.new(chunk.path).relative_path_from(Pathname.new(File.dirname(sym_path)))
      FileUtils.ln_sf(relative_path, sym_path)
    else
      FileUtils.ln_sf(chunk.path, sym_path)
    end
  end
  chunk
end

#metadata(timekey: nil, tag: nil, variables: nil) ⇒ Object



75
76
77
78
79
80
81
82
83
84
# File 'lib/fluent/plugin/out_file.rb', line 75

def (timekey: nil, tag: nil, variables: nil)
   = super

  @latest_metadata ||= (timekey: 0)
  if .timekey && (.timekey >= @latest_metadata.timekey)
    @latest_metadata = 
  end

  
end

#output_plugin_for_symlink=(output_plugin) ⇒ Object



86
87
88
# File 'lib/fluent/plugin/out_file.rb', line 86

def output_plugin_for_symlink=(output_plugin)
  @_output_plugin_for_symlink = output_plugin
end


90
91
92
# File 'lib/fluent/plugin/out_file.rb', line 90

def symlink_path=(path)
  @_symlink_path = path
end