Hadoop dir/file last modification times

前端 未结 2 666
时光取名叫无心
时光取名叫无心 2021-01-23 07:09

Is there a way to get the last modified times of all dirs and files in hdfs? I want to create page that displays the information, but I have no clue how to go about getting the

2条回答
  •  终归单人心
    2021-01-23 07:41

    You probably have to iterate through the files and directories, to get the status of each path - you can use the below code (just sample) - but I'm not sure, how efficient that would be, if you have large set of files and directories.

    Configuration conf = new Configuration();
    conf.set("fs.default.name", "hdfs://");
    conf.set("mapred.job.tracker", ":");
    conf.setBoolean("fs.hdfs.impl.disable.cache", true);
    
    FileSystem lfs = FileSystem.get(l_configuration);
    fs.getFileStatus(new Path("/your/path")).getModificationTime();
    

提交回复
热议问题