Skip to content

Commit 09a1093

Browse files
shvachkodeepakdamri
authored andcommitted
HDFS-15567. [SBN Read] HDFS should expose msync() API to allow downstream applications call it explicitly. Contributed by Konstantin V Shvachko.
(cherry picked from commit b3786d6)
1 parent 12b70b0 commit 09a1093

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,19 @@ public abstract FileStatus getFileStatus(final Path f)
865865
throws AccessControlException, FileNotFoundException,
866866
UnresolvedLinkException, IOException;
867867

868+
/**
869+
* Synchronize client metadata state.
870+
* <p/>In some FileSystem implementations such as HDFS metadata
871+
* synchronization is essential to guarantee consistency of read requests
872+
* particularly in HA setting.
873+
* @throws IOException
874+
* @throws UnsupportedOperationException
875+
*/
876+
public void msync() throws IOException, UnsupportedOperationException {
877+
throw new UnsupportedOperationException(getClass().getCanonicalName() +
878+
" does not support method msync");
879+
}
880+
868881
/**
869882
* The specification of this method matches that of
870883
* {@link FileContext#access(Path, FsAction)}

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileContext.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,16 @@ public FileStatus next(final AbstractFileSystem fs, final Path p)
12541254
}.resolve(this, absF);
12551255
}
12561256

1257+
/**
1258+
* Synchronize client metadata state.
1259+
*
1260+
* @throws IOException
1261+
* @throws UnsupportedOperationException
1262+
*/
1263+
public void msync() throws IOException, UnsupportedOperationException {
1264+
defaultFS.msync();
1265+
}
1266+
12571267
/**
12581268
* Checks if the user can access a path. The mode specifies which access
12591269
* checks to perform. If the requested permissions are granted, then the

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFileSystem.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,11 @@ public FileStatus getFileStatus(Path f) throws IOException {
456456
return fs.getFileStatus(f);
457457
}
458458

459+
@Override
460+
public void msync() throws IOException, UnsupportedOperationException {
461+
fs.msync();
462+
}
463+
459464
@Override
460465
public void access(Path path, FsAction mode) throws AccessControlException,
461466
FileNotFoundException, IOException {

hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FilterFs.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ public FileStatus getFileStatus(Path f)
124124
return myFs.getFileStatus(f);
125125
}
126126

127+
@Override
128+
public void msync() throws IOException, UnsupportedOperationException {
129+
myFs.msync();
130+
}
131+
127132
@Override
128133
public void access(Path path, FsAction mode) throws AccessControlException,
129134
FileNotFoundException, UnresolvedLinkException, IOException {

0 commit comments

Comments
 (0)