This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new a2916828a5 HDDS-10781. Do not use OFSPath in O3FS
BasicOzoneClientAdapterImpl (#6614)
a2916828a5 is described below
commit a2916828a5a6820c155f72a1d8c08960852b583e
Author: Chung En Lee <[email protected]>
AuthorDate: Fri May 10 04:18:10 2024 +0800
HDDS-10781. Do not use OFSPath in O3FS BasicOzoneClientAdapterImpl (#6614)
---
.../fs/ozone/AbstractOzoneFileSystemTest.java | 22 ++++++++++++++++++++
.../ozone/AbstractOzoneFileSystemTestWithFSO.java | 2 +-
.../fs/ozone/BasicOzoneClientAdapterImpl.java | 24 ++++++++--------------
.../ozone/BasicRootedOzoneClientAdapterImpl.java | 4 ++--
.../apache/hadoop/fs/ozone/OzoneClientUtils.java | 9 ++++----
5 files changed, 37 insertions(+), 24 deletions(-)
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractOzoneFileSystemTest.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractOzoneFileSystemTest.java
index 6d259c2b1b..9f81adc6cc 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractOzoneFileSystemTest.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractOzoneFileSystemTest.java
@@ -2251,4 +2251,26 @@ abstract class AbstractOzoneFileSystemTest {
assertEquals(value, statistics.getLong(key).longValue());
}
+ @Test
+ void testSnapshotRead() throws Exception {
+ // Init data
+ Path snapPath1 = fs.createSnapshot(new Path("/"), "snap1");
+
+ Path file1 = new Path("/key1");
+ Path file2 = new Path("/key2");
+ ContractTestUtils.touch(fs, file1);
+ ContractTestUtils.touch(fs, file2);
+ Path snapPath2 = fs.createSnapshot(new Path("/"), "snap2");
+
+ Path file3 = new Path("/key3");
+ ContractTestUtils.touch(fs, file3);
+ Path snapPath3 = fs.createSnapshot(new Path("/"), "snap3");
+
+ FileStatus[] f1 = fs.listStatus(snapPath1);
+ FileStatus[] f2 = fs.listStatus(snapPath2);
+ FileStatus[] f3 = fs.listStatus(snapPath3);
+ assertEquals(0, f1.length);
+ assertEquals(2, f2.length);
+ assertEquals(3, f3.length);
+ }
}
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractOzoneFileSystemTestWithFSO.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractOzoneFileSystemTestWithFSO.java
index f0ff1ab43b..98039b82db 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractOzoneFileSystemTestWithFSO.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractOzoneFileSystemTestWithFSO.java
@@ -497,7 +497,7 @@ abstract class AbstractOzoneFileSystemTestWithFSO extends
AbstractOzoneFileSyste
@Test
public void testLeaseRecoverable() throws Exception {
// Create a file
- Path parent = new Path("/d1/d2/");
+ Path parent = new Path("/d1");
Path source = new Path(parent, "file1");
LeaseRecoverable fs = (LeaseRecoverable)getFs();
diff --git
a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneClientAdapterImpl.java
b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneClientAdapterImpl.java
index 1916699a42..ba7bfc92b3 100644
---
a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneClientAdapterImpl.java
+++
b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneClientAdapterImpl.java
@@ -45,7 +45,6 @@ import org.apache.hadoop.hdds.scm.OzoneClientConfig;
import org.apache.hadoop.hdds.security.SecurityConfig;
import org.apache.hadoop.hdfs.protocol.SnapshotDiffReport;
import org.apache.hadoop.io.Text;
-import org.apache.hadoop.ozone.OFSPath;
import org.apache.hadoop.ozone.OmUtils;
import org.apache.hadoop.ozone.OzoneConfigKeys;
import org.apache.hadoop.ozone.client.ObjectStore;
@@ -598,18 +597,14 @@ public class BasicOzoneClientAdapterImpl implements
OzoneClientAdapter {
@Override
public String createSnapshot(String pathStr, String snapshotName)
throws IOException {
- OFSPath ofsPath = new OFSPath(pathStr, config);
- return objectStore.createSnapshot(ofsPath.getVolumeName(),
- ofsPath.getBucketName(),
- snapshotName);
+ return objectStore.createSnapshot(volume.getName(), bucket.getName(),
snapshotName);
}
@Override
public void renameSnapshot(String pathStr, String snapshotOldName, String
snapshotNewName)
throws IOException {
- OFSPath ofsPath = new OFSPath(pathStr, config);
- objectStore.renameSnapshot(ofsPath.getVolumeName(),
- ofsPath.getBucketName(),
+ objectStore.renameSnapshot(volume.getName(),
+ bucket.getName(),
snapshotOldName,
snapshotNewName);
}
@@ -617,9 +612,8 @@ public class BasicOzoneClientAdapterImpl implements
OzoneClientAdapter {
@Override
public void deleteSnapshot(String pathStr, String snapshotName)
throws IOException {
- OFSPath ofsPath = new OFSPath(pathStr, config);
- objectStore.deleteSnapshot(ofsPath.getVolumeName(),
- ofsPath.getBucketName(),
+ objectStore.deleteSnapshot(volume.getName(),
+ bucket.getName(),
snapshotName);
}
@@ -662,12 +656,11 @@ public class BasicOzoneClientAdapterImpl implements
OzoneClientAdapter {
} finally {
// delete the temp snapshot
if (takeTemporaryToSnapshot || takeTemporaryFromSnapshot) {
- OFSPath snapPath = new OFSPath(snapshotDir.toString(), config);
if (takeTemporaryToSnapshot) {
- OzoneClientUtils.deleteSnapshot(objectStore, toSnapshot, snapPath);
+ OzoneClientUtils.deleteSnapshot(objectStore, toSnapshot,
volume.getName(), bucket.getName());
}
if (takeTemporaryFromSnapshot) {
- OzoneClientUtils.deleteSnapshot(objectStore, fromSnapshot, snapPath);
+ OzoneClientUtils.deleteSnapshot(objectStore, fromSnapshot,
volume.getName(), bucket.getName());
}
}
}
@@ -706,8 +699,7 @@ public class BasicOzoneClientAdapterImpl implements
OzoneClientAdapter {
@Override
public boolean isFileClosed(String pathStr) throws IOException {
incrementCounter(Statistic.INVOCATION_IS_FILE_CLOSED, 1);
- OFSPath ofsPath = new OFSPath(pathStr, config);
- if (!ofsPath.isKey()) {
+ if (StringUtils.isEmpty(pathStr)) {
throw new IOException("not a file");
}
OzoneFileStatus status = bucket.getFileStatus(pathStr);
diff --git
a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java
b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java
index d92c8c0524..af741994b7 100644
---
a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java
+++
b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java
@@ -1317,10 +1317,10 @@ public class BasicRootedOzoneClientAdapterImpl
} finally {
// delete the temp snapshot
if (takeTemporaryToSnapshot) {
- OzoneClientUtils.deleteSnapshot(objectStore, toSnapshot, ofsPath);
+ OzoneClientUtils.deleteSnapshot(objectStore, toSnapshot, volume,
bucket);
}
if (takeTemporaryFromSnapshot) {
- OzoneClientUtils.deleteSnapshot(objectStore, fromSnapshot, ofsPath);
+ OzoneClientUtils.deleteSnapshot(objectStore, fromSnapshot, volume,
bucket);
}
}
}
diff --git
a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/OzoneClientUtils.java
b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/OzoneClientUtils.java
index 4cb9084b2b..383ad6db49 100644
---
a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/OzoneClientUtils.java
+++
b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/OzoneClientUtils.java
@@ -25,7 +25,6 @@ import org.apache.hadoop.hdds.conf.ConfigurationSource;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
import org.apache.hadoop.fs.FileChecksum;
import org.apache.hadoop.hdds.scm.OzoneClientConfig;
-import org.apache.hadoop.ozone.OFSPath;
import org.apache.hadoop.ozone.client.checksum.BaseFileChecksumHelper;
import org.apache.hadoop.ozone.client.ObjectStore;
import org.apache.hadoop.ozone.client.OzoneBucket;
@@ -270,14 +269,14 @@ public final class OzoneClientUtils {
}
public static void deleteSnapshot(ObjectStore objectStore,
- String snapshot, OFSPath snapPath) {
+ String snapshot, String volumeName, String bucketName) {
try {
- objectStore.deleteSnapshot(snapPath.getVolumeName(),
- snapPath.getBucketName(), snapshot);
+ objectStore.deleteSnapshot(volumeName,
+ bucketName, snapshot);
} catch (IOException exception) {
LOG.warn("Failed to delete the temp snapshot with name {} in bucket"
+ " {} and volume {} after snapDiff op. Exception : {}",
snapshot,
- snapPath.getBucketName(), snapPath.getVolumeName(),
+ bucketName, volumeName,
exception.getMessage());
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]