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.



751
752
753
754
# File 'lib/fluent/plugin/in_tail.rb', line 751

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

Instance Method Details

#read_inodeObject



766
767
768
769
770
# File 'lib/fluent/plugin/in_tail.rb', line 766

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

#read_posObject



772
773
774
775
776
# File 'lib/fluent/plugin/in_tail.rb', line 772

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

#update(ino, pos) ⇒ Object



756
757
758
759
# File 'lib/fluent/plugin/in_tail.rb', line 756

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

#update_pos(pos) ⇒ Object



761
762
763
764
# File 'lib/fluent/plugin/in_tail.rb', line 761

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