开门见山先说结论:基于inode实现。

分析很简单,logstash是用一个filewatch去监视文件的。在logstash目录里搜索filewatch即可找到该目录

logstash/vendor/bundle/jruby/1.9/gems/filewatch-0.6.7/lib/filewatch

其中的watch.rb文件是我们所关注的重点

    public
    def inode(path,stat)
      if @iswindows
        fileId = Winhelper.GetWindowsUniqueFileIdentifier(path)
        inode = [fileId, 0, 0] # dev_* doesn't make sense on Windows
      else
        inode = [stat.ino.to_s, stat.dev_major, stat.dev_minor]
      end
      return inode
    end

修改文件名并不会改变inode与文件的对应关系,并且打开一个文件以后,系统就以inode号码来识别这个文件,不再考虑文件名。

inode具体原理参考下文:

http://www.cnblogs.com/itech/archive/2012/05/15/2502284.html

 

相关文章:

  • 2021-12-04
  • 2021-06-16
  • 2022-12-23
  • 2021-09-10
  • 2021-07-15
  • 2022-01-27
  • 2021-12-15
猜你喜欢
  • 2021-09-22
  • 2022-12-23
  • 2022-01-19
  • 2021-09-20
  • 2022-12-23
相关资源
相似解决方案