SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
1、Add SeaweedFS implementation of Hadoop AbstractFileSystem. The implementation delegates to the existing SeaweedFS FileSystem and is only necessary for use with Hadoop 2.x/3.x. Configuration example in Hadoop core-site.xml file:
李明达74456b3d5e15
diff --git a/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedAbstractFileSystem.java b/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedAbstractFileSystem.javanew file mode 100644index 0000000000..e021401aad--- /dev/null+++ b/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedAbstractFileSystem.java@@ -0,0 +1,35 @@+/**+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this work for additional information+ * regarding copyright ownership. The ASF licenses this file+ * to you under the Apache License, Version 2.0 (the+ * "License"); you may not use this file except in compliance+ * with the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++package seaweed.hdfs;++import org.apache.hadoop.conf.Configuration;+import org.apache.hadoop.fs.DelegateToFileSystem;++import java.io.IOException;+import java.net.URI;+import java.net.URISyntaxException;++public class SeaweedAbstractFileSystem extends DelegateToFileSystem {++ SeaweedAbstractFileSystem(final URI uri, final Configuration conf)+ throws IOException, URISyntaxException {+ super(uri, new SeaweedFileSystem(), conf, "seaweedfs", false);+ }++}diff --git a/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedFileSystem.java b/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedFileSystem.javaindex c12da8261c..85490c1818 100644--- a/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedFileSystem.java+++ b/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedFileSystem.java@@ -10,6 +10,7 @@ import org.apache.hadoop.security.UserGroupInformation;import org.apache.hadoop.util.Progressable;import org.slf4j.Logger;import org.slf4j.LoggerFactory;+import seaweedfs.client.FilerProto;import java.io.FileNotFoundException;import java.io.IOException;@@ -144,7 +145,7 @@ public class SeaweedFileSystem extends FileSystem {}@Override- public boolean rename(Path src, Path dst) {+ public boolean rename(Path src, Path dst) throws IOException {LOG.debug("rename path: {} => {}", src, dst);@@ -155,12 +156,13 @@ public class SeaweedFileSystem extends FileSystem {if (src.equals(dst)) {return true;}- FileStatus dstFileStatus = getFileStatus(dst);+ FilerProto.Entry entry = seaweedFileSystemStore.lookupEntry(dst);- String sourceFileName = src.getName();Path adjustedDst = dst;- if (dstFileStatus != null) {+ if (entry != null) {+ FileStatus dstFileStatus = getFileStatus(dst);+ String sourceFileName = src.getName();if (!dstFileStatus.isDirectory()) {return false;}@@ -175,18 +177,20 @@ public class SeaweedFileSystem extends FileSystem {}@Override- public boolean delete(Path path, boolean recursive) {+ public boolean delete(Path path, boolean recursive) throws IOException {LOG.debug("delete path: {} recursive:{}", path, recursive);path = qualify(path);- FileStatus fileStatus = getFileStatus(path);+ FilerProto.Entry entry = seaweedFileSystemStore.lookupEntry(path);- if (fileStatus == null) {+ if (entry == null) {return true;}+ FileStatus fileStatus = getFileStatus(path);+return seaweedFileSystemStore.deleteEntries(path, fileStatus.isDirectory(), recursive);}@@ -222,9 +226,9 @@ public class SeaweedFileSystem extends FileSystem {path = qualify(path);- FileStatus fileStatus = getFileStatus(path);+ FilerProto.Entry entry = seaweedFileSystemStore.lookupEntry(path);- if (fileStatus == null) {+ if (entry == null) {UserGroupInformation currentUser = UserGroupInformation.getCurrentUser();return seaweedFileSystemStore.createDirectory(path, currentUser,@@ -233,6 +237,8 @@ public class SeaweedFileSystem extends FileSystem {}+ FileStatus fileStatus = getFileStatus(path);+if (fileStatus.isDirectory()) {return true;} else {@@ -241,7 +247,7 @@ public class SeaweedFileSystem extends FileSystem {}@Override- public FileStatus getFileStatus(Path path) {+ public FileStatus getFileStatus(Path path) throws IOException {LOG.debug("getFileStatus path: {}", path);diff --git a/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedFileSystemStore.java b/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedFileSystemStore.javaindex 9617a38be0..f9aaa175ff 100644--- a/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedFileSystemStore.java+++ b/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedFileSystemStore.java@@ -61,7 +61,7 @@ public class SeaweedFileSystemStore {);}- public FileStatus[] listEntries(final Path path) {+ public FileStatus[] listEntries(final Path path) throws IOException {LOG.debug("listEntries path: {}", path);FileStatus pathStatus = getFileStatus(path);@@ -89,11 +89,11 @@ public class SeaweedFileSystemStore {}- public FileStatus getFileStatus(final Path path) {+ public FileStatus getFileStatus(final Path path) throws IOException {FilerProto.Entry entry = lookupEntry(path);if (entry == null) {- return null;+ throw new FileNotFoundException("File does not exist: " + path);}LOG.debug("doGetFileStatus path:{} entry:{}", path, entry);@@ -136,7 +136,7 @@ public class SeaweedFileSystemStore {modification_time, access_time, permission, owner, group, null, path);}- private FilerProto.Entry lookupEntry(Path path) {+ public FilerProto.Entry lookupEntry(Path path) {return filerClient.lookupEntry(getParentDirectory(path), path.getName());