szetszwo commented on code in PR #4825:
URL: https://github.com/apache/ozone/pull/4825#discussion_r1245368336
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java:
##########
@@ -4431,6 +4433,24 @@ public void setTimes(OmKeyArgs keyArgs, long mtime, long
atime)
throws IOException {
}
+ @Override
+ public boolean setSafeMode(SafeModeAction action, boolean isChecked)
+ throws IOException {
+ switch (action) {
+ case ENTER:
+ throw new OMException("Enter safe mode is unsupported",
+ INTERNAL_ERROR);
+ case LEAVE:
+ case FORCE_EXIT:
Review Comment:
Currently, we only support `FORCE_EXIT`. We should support `LEAVE` later.
##########
hadoop-ozone/ozonefs-hadoop3/src/main/java/org/apache/hadoop/fs/ozone/OzoneFileSystem.java:
##########
@@ -120,4 +123,28 @@ public boolean hasPathCapability(final Path path, final
String capability)
}
return super.hasPathCapability(p, capability);
}
+
+ @Override
+ public boolean recoverLease(Path f) throws IOException {
+ LOG.trace("recoverLease() path:{}", f);
+ Path qualifiedPath = makeQualified(f);
+ String key = pathToKey(qualifiedPath);
+ return getAdapter().recoverLease(key);
+ }
+
+ @Override
+ public boolean isFileClosed(Path f) throws IOException {
+ LOG.trace("isFileClosed() path:{}", f);
+ Path qualifiedPath = makeQualified(f);
+ String key = pathToKey(qualifiedPath);
+ return getAdapter().isFileClosed(key);
+ }
+
+ @Override
+ public boolean setSafeMode(SafeModeAction action, boolean isChecked)
+ throws IOException {
+ statistics.incrementWriteOps(1);
Review Comment:
Check if the action is not `GET` before `incrementWriteOps`.
##########
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneClientAdapterImpl.java:
##########
@@ -716,9 +717,37 @@ private SnapshotDiffReportOzone
getSnapshotDiffReportOnceComplete(
return snapshotDiffResponse.getSnapshotDiffReport();
}
+ @Override
+ public boolean recoverLease(final String pathStr) throws IOException {
+ incrementCounter(Statistic.INVOCATION_RECOVER_LEASE, 1);
+
+ return ozoneClient.getProxy().getOzoneManagerClient().recoverLease(
+ volume.getName(), bucket.getName(), pathStr);
+ }
+
@Override
public void setTimes(String key, long mtime, long atime) throws IOException {
incrementCounter(Statistic.INVOCATION_SET_TIMES, 1);
bucket.setTimes(key, mtime, atime);
}
+
+ @Override
+ public boolean isFileClosed(String pathStr) throws IOException {
+ incrementCounter(Statistic.INVOCATION_IS_FILE_CLOSED, 1);
+ OFSPath ofsPath = new OFSPath(pathStr, config);
+ if (!ofsPath.isKey()) {
+ throw new IOException("not a file");
+ }
+ OzoneFileStatus status = bucket.getFileStatus(pathStr);
Review Comment:
We should check `status.isFile()`.
##########
hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/OzoneFileSystem.java:
##########
@@ -120,4 +123,28 @@ public boolean hasPathCapability(final Path path, final
String capability)
}
return super.hasPathCapability(p, capability);
}
+
+ @Override
+ public boolean recoverLease(Path f) throws IOException {
+ LOG.trace("isFileClosed() path:{}", f);
+ Path qualifiedPath = makeQualified(f);
+ String key = pathToKey(qualifiedPath);
+ return getAdapter().recoverLease(key);
+ }
+
+ @Override
+ public boolean isFileClosed(Path f) throws IOException {
+ LOG.trace("isFileClosed() path:{}", f);
+ Path qualifiedPath = makeQualified(f);
+ String key = pathToKey(qualifiedPath);
+ return getAdapter().isFileClosed(key);
+ }
+
+ @Override
+ public boolean setSafeMode(SafeModeAction action, boolean isChecked)
+ throws IOException {
+ statistics.incrementWriteOps(1);
Review Comment:
Check if the action is not `GET` before `incrementWriteOps`.
##########
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java:
##########
@@ -1370,20 +1371,50 @@ private SnapshotDiffReportOzone
getSnapshotDiffReportOnceComplete(
return snapshotDiffResponse.getSnapshotDiffReport();
}
- public boolean recoverLease(final Path f) throws IOException {
- OFSPath ofsPath = new OFSPath(f, config);
+ @Override
+ public boolean isFileClosed(String pathStr) throws IOException {
+ incrementCounter(Statistic.INVOCATION_IS_FILE_CLOSED, 1);
+ OFSPath ofsPath = new OFSPath(pathStr, config);
+ String key = ofsPath.getKeyName();
+ if (ofsPath.isRoot() || ofsPath.isVolume()) {
+ throw new IOException("not a file");
+ } else {
+ OzoneBucket bucket = getBucket(ofsPath, false);
+ if (ofsPath.isSnapshotPath()) {
+ throw new IOException("file is in a snapshot.");
+ } else {
+ OzoneFileStatus status = bucket.getFileStatus(key);
Review Comment:
Check `status.isFile()`.
##########
hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/RootedOzoneFileSystem.java:
##########
@@ -118,4 +121,30 @@ public boolean hasPathCapability(final Path path, final
String capability)
}
return super.hasPathCapability(p, capability);
}
+
+ @Override
+ public boolean recoverLease(final Path f) throws IOException {
+ statistics.incrementWriteOps(1);
+ LOG.trace("recoverLease() path:{}", f);
+ Path qualifiedPath = makeQualified(f);
+ String key = pathToKey(qualifiedPath);
+ return getAdapter().recoverLease(key);
+ }
+
+ @Override
+ public boolean isFileClosed(Path f) throws IOException {
+ statistics.incrementWriteOps(1);
+ LOG.trace("isFileClosed() path:{}", f);
+ Path qualifiedPath = makeQualified(f);
+ String key = pathToKey(qualifiedPath);
+ return getAdapter().isFileClosed(key);
+ }
+
+ @Override
+ public boolean setSafeMode(SafeModeAction action, boolean isChecked)
+ throws IOException {
+ statistics.incrementWriteOps(1);
Review Comment:
Check if the action is not `GET` before `incrementWriteOps`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]