Class: Fluent::TailPathInput::FilePositionEntry

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

Overview

pos inode fffffffffffffffftffffffffn

Constant Summary collapse

POS_SIZE =
16
INO_OFFSET =
17
INO_SIZE =
8
LN_OFFSET =
25
SIZE =
26

Instance Method Summary collapse

Constructor Details

#initialize(file, seek) ⇒ FilePositionEntry

Returns a new instance of FilePositionEntry.



445
446
447
448
# File 'lib/fluent/plugin/in_tailpath.rb', line 445

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

Instance Method Details

#read_inodeObject



461
462
463
464
465
# File 'lib/fluent/plugin/in_tailpath.rb', line 461

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

#read_posObject



467
468
469
470
471
# File 'lib/fluent/plugin/in_tailpath.rb', line 467

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

#update(ino, pos) ⇒ Object



450
451
452
453
454
# File 'lib/fluent/plugin/in_tailpath.rb', line 450

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

#update_pos(pos) ⇒ Object



456
457
458
459
# File 'lib/fluent/plugin/in_tailpath.rb', line 456

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