Mohammed El Moumni
Mohammed El Moumni

Reputation: 267

When does hdfs change Access time and modification time of a directory?

Suppose I have a the following hierarchy in my hdfs file system

Dir1
  -> Dir2
     -> File1

If I add a file named File 2 to /Dir1/Dir2, are the access and modification time of Dir1 and Dir2 going to change ? In general, when do these two values change ?

Also How to access those two values through the Hadoop Java API ?

Thank you for your answers

Upvotes: 2

Views: 3563

Answers (1)

Bijoy
Bijoy

Reputation: 113

The time stamp of Dir2 changes but not for Dir1. Only the immediate directory timestamp changes.

You can use the following in Java for getting timestamp :

FileSystem fs = FileSystem.get(URI.create(uri), conf);
long moddificationTime = fs
    .getFileStatus((FileSplit)context.getInputSplit())
    .getPath()).lastModified();

Upvotes: 1

Related Questions