Class: Fluent::Plugin::TailInput::FilePositionEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/plugin/in_tail.rb

Overview

pos inode fffffffffffffffftffffffffffffffffn

Constant Summary collapse

POS_SIZE =
16
INO_OFFSET =
17
INO_SIZE =
16
LN_OFFSET =
33
SIZE =
34

Instance Method Summary collapse

Constructor Details

#initialize(file, seek) ⇒ FilePositionEntry

Returns a new instance of FilePositionEntry.



857
858
859
860
861
# File 'lib/fluent/plugin/in_tail.rb', line 857

def initialize(file, seek)
  @file = file
  @seek = seek
  @pos = nil
end

Instance Method Details

#read_inodeObject



875
876
877
878
879
# File 'lib/fluent/plugin/in_tail.rb', line 875

def read_inode
  @file.pos = @seek + INO_OFFSET
  raw = @file.read(16)
  raw ? raw.to_i(16) : 0
end

#read_posObject



881
882
883
884
885
886
887
# File 'lib/fluent/plugin/in_tail.rb', line 881

def read_pos
  @pos ||= begin
    @file.pos = @seek
    raw = @file.read(16)
    raw ? raw.to_i(16) : 0
  end
end

#update(ino, pos) ⇒ Object



863
864
865
866
867
# File 'lib/fluent/plugin/in_tail.rb', line 863

def update(ino, pos)
  @file.pos = @seek
  @file.write "%016x\t%016x" % [pos, ino]
  @pos = pos
end

#update_pos(pos) ⇒ Object



869
870
871
872
873
# File 'lib/fluent/plugin/in_tail.rb', line 869

def update_pos(pos)
  @file.pos = @seek
  @file.write "%016x" % pos
  @pos = pos
end