Sha256: 71bcc8521a33bf8d8f396f3041879928b8eef65ce1de14a9398bf5bf2246d707

Contents?: true

Size: 1.48 KB

Versions: 53

Compression:

Stored size: 1.48 KB

Contents

#
# Fluent
#
# Copyright (C) 2011 FURUHASHI Sadayuki
#
#    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 ZFileBufferChunk < FileBufferChunk
  def initialize(path)
    super(path)
    @z = Zlib::Deflate.new
  end

  def <<(data)
    zdata = @z.deflate(data, Z_NO_FLUSH)
    unless zdata.empty?
      super(zdata)
    end
  end

  def close_write
    zdata = @z.flush
    unless zdata.empty?
      @file.write(zdata)
      @size += zdata.bytesize
    end
    super
  end

  def close
    @z.close
    super
  end

  def purge
    @z.close
    super
  end

  # TODO
  #def open(&block)
  #end
end


class ZFileBuffer < FileBuffer
  # TODO
  #Plugin.register_buffer('zfile', self)

  def initialize
    require 'zlib'
    super
  end

  def resume_queue
    queue = resume_queue_paths.map {|path|
      ZFileBufferChunk.new(path)
    }
    top = new_chunk
    return queue, top
  end

  def new_chunk
    path = new_chunk_path
    ZFileBufferChunk.new(path)
  end
end


end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
fluentd-0.10.53 lib/fluent/plugin/buf_zfile.rb
fluentd-0.10.52 lib/fluent/plugin/buf_zfile.rb
fluentd-0.10.51 lib/fluent/plugin/buf_zfile.rb
fluentd-0.10.50 lib/fluent/plugin/buf_zfile.rb
fluentd-0.10.49 lib/fluent/plugin/buf_zfile.rb
fluentd-0.10.48 lib/fluent/plugin/buf_zfile.rb
fluentd-0.10.47 lib/fluent/plugin/buf_zfile.rb
fluentd-0.10.46 lib/fluent/plugin/buf_zfile.rb
fluentd-0.10.45 lib/fluent/plugin/buf_zfile.rb
fluentd-0.10.44 lib/fluent/plugin/buf_zfile.rb
fluentd-0.10.43 lib/fluent/plugin/buf_zfile.rb
fluentd-0.10.42 lib/fluent/plugin/buf_zfile.rb
fluentd-0.10.41 lib/fluent/plugin/buf_zfile.rb
fluentd-0.10.40 lib/fluent/plugin/buf_zfile.rb
fluentd-0.10.39 lib/fluent/plugin/buf_zfile.rb
fluentd-0.10.38 lib/fluent/plugin/buf_zfile.rb
fluentd-0.10.37 lib/fluent/plugin/buf_zfile.rb
fluentd-0.10.36 lib/fluent/plugin/buf_zfile.rb
fluentd-0.10.35 lib/fluent/plugin/buf_zfile.rb
fluentd-0.10.34 lib/fluent/plugin/buf_zfile.rb