ayushtkn commented on code in PR #5040:
URL: https://github.com/apache/ozone/pull/5040#discussion_r1260080311
##########
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneClientAdapterImpl.java:
##########
@@ -668,12 +668,22 @@ public void deleteSnapshot(String pathStr, String
snapshotName)
public SnapshotDiffReport getSnapshotDiffReport(Path snapshotDir,
String fromSnapshot, String toSnapshot)
throws IOException, InterruptedException {
- boolean takeTemporarySnapshot = false;
- if (toSnapshot.equals(ACTIVE_FS_SNAPSHOT_NAME)) {
- takeTemporarySnapshot = true;
+ boolean takeTemporaryToSnapshot = false;
+ boolean takeTemporaryFromSnapshot = false;
+ if (toSnapshot.isEmpty()) {
+ // empty toSnapshot implies diff b/w the fromSnapshot &
+ // current state.
+ takeTemporaryToSnapshot = true;
toSnapshot = createSnapshot(snapshotDir.toString(),
"temp" + SnapshotInfo.generateName(Time.now()));
}
+ if (fromSnapshot.isEmpty()) {
+ // empty toSnapshot implies diff b/w the current state
+ // & the toSnapshot
Review Comment:
change ``toSnapshot`` -> ``fromSnapshot``
##########
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneClientAdapterImpl.java:
##########
@@ -692,11 +702,16 @@ public SnapshotDiffReport getSnapshotDiffReport(Path
snapshotDir,
return aggregated;
} finally {
// delete the temp snapshot
- if (takeTemporarySnapshot) {
+ if (takeTemporaryToSnapshot || takeTemporaryFromSnapshot) {
OFSPath snapPath = new OFSPath(snapshotDir.toString(), config);
- ozoneClient.getObjectStore()
- .deleteSnapshot(snapPath.getVolumeName(), snapPath.getBucketName(),
- toSnapshot);
+ if (takeTemporaryToSnapshot) {
+ ozoneClient.getObjectStore().deleteSnapshot(snapPath.getVolumeName(),
Review Comment:
```ozoneClient.getObjectStore()``` can be refactored into a variable & used
in both places
##########
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java:
##########
@@ -1318,12 +1316,22 @@ public void deleteSnapshot(String pathStr, String
snapshotName)
public SnapshotDiffReport getSnapshotDiffReport(Path snapshotDir,
String fromSnapshot, String toSnapshot)
throws IOException, InterruptedException {
- boolean takeTemporarySnapshot = false;
- if (toSnapshot.equals(ACTIVE_FS_SNAPSHOT_NAME)) {
- takeTemporarySnapshot = true;
+ boolean takeTemporaryToSnapshot = false;
+ boolean takeTemporaryFromSnapshot = false;
+ if (toSnapshot.isEmpty()) {
+ // empty toSnapshot implies diff b/w the fromSnapshot &
+ // current state.
+ takeTemporaryToSnapshot = true;
toSnapshot = createSnapshot(snapshotDir.toString(),
"temp" + SnapshotInfo.generateName(Time.now()));
}
+ if (fromSnapshot.isEmpty()) {
+ // empty toSnapshot implies diff b/w the current state
+ // & the toSnapshot
+ takeTemporaryFromSnapshot = true;
+ fromSnapshot = createSnapshot(snapshotDir.toString(),
+ "temp" + SnapshotInfo.generateName(Time.now()));
Review Comment:
in extreme condition, if both snapshots are created, if time comes same, we
would land up in trouble. may be we should consider having different prefix for
both snapshots rather than same "temp"
##########
hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java:
##########
@@ -1318,12 +1316,22 @@ public void deleteSnapshot(String pathStr, String
snapshotName)
public SnapshotDiffReport getSnapshotDiffReport(Path snapshotDir,
String fromSnapshot, String toSnapshot)
throws IOException, InterruptedException {
- boolean takeTemporarySnapshot = false;
- if (toSnapshot.equals(ACTIVE_FS_SNAPSHOT_NAME)) {
- takeTemporarySnapshot = true;
+ boolean takeTemporaryToSnapshot = false;
+ boolean takeTemporaryFromSnapshot = false;
+ if (toSnapshot.isEmpty()) {
+ // empty toSnapshot implies diff b/w the fromSnapshot &
+ // current state.
+ takeTemporaryToSnapshot = true;
toSnapshot = createSnapshot(snapshotDir.toString(),
"temp" + SnapshotInfo.generateName(Time.now()));
}
+ if (fromSnapshot.isEmpty()) {
+ // empty toSnapshot implies diff b/w the current state
+ // & the toSnapshot
Review Comment:
```fromSnapshot```
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystem.java:
##########
@@ -2506,7 +2506,7 @@ public void testSnapshotDiff() throws Exception {
Path file =
new Path(bucketPath1, "key" + RandomStringUtils.randomAlphabetic(5));
ContractTestUtils.touch(fs, file);
- diff = ofs.getSnapshotDiffReport(bucketPath1, toSnap, ".");
+ diff = ofs.getSnapshotDiffReport(bucketPath1, toSnap, "");
Review Comment:
add test for the other case as well
```
ofs.getSnapshotDiffReport(bucketPath1, "", toSnap);
ofs.getSnapshotDiffReport(bucketPath1, "", "");
```
--
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]