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

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

Overview

pos inode fffffffffffffffftffffffffffffffffn

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, file_mutex, seek, pos, inode) ⇒ FilePositionEntry

Returns a new instance of FilePositionEntry.



207
208
209
210
211
212
213
# File 'lib/fluent/plugin/in_tail/position_file.rb', line 207

def initialize(file, file_mutex, seek, pos, inode)
  @file = file
  @file_mutex = file_mutex
  @seek = seek
  @pos = pos
  @inode = inode
end

Instance Attribute Details

#seek=(value) ⇒ Object (writeonly)

Sets the attribute seek

Parameters:

  • value

    the value to set the attribute seek to.



215
216
217
# File 'lib/fluent/plugin/in_tail/position_file.rb', line 215

def seek=(value)
  @seek = value
end

Instance Method Details

#read_inodeObject



234
235
236
# File 'lib/fluent/plugin/in_tail/position_file.rb', line 234

def read_inode
  @inode
end

#read_posObject



238
239
240
# File 'lib/fluent/plugin/in_tail/position_file.rb', line 238

def read_pos
  @pos
end

#update(ino, pos) ⇒ Object



217
218
219
220
221
222
223
224
# File 'lib/fluent/plugin/in_tail/position_file.rb', line 217

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

#update_pos(pos) ⇒ Object



226
227
228
229
230
231
232
# File 'lib/fluent/plugin/in_tail/position_file.rb', line 226

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