aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2018-11-24 03:22:25 -0800
committerChris Lu <chris.lu@gmail.com>2018-11-24 03:22:25 -0800
commit76cba561cf38ca89c8483dd7ec3c8fa2206d96fd (patch)
treeb55c1143af2d9279c313f75752f82da3dbb7012b
parent871dee4674378ceeef4b68ebfa64fe1d4441cd29 (diff)
downloadseaweedfs-76cba561cf38ca89c8483dd7ec3c8fa2206d96fd.tar.xz
seaweedfs-76cba561cf38ca89c8483dd7ec3c8fa2206d96fd.zip
starting with hadoop compatible
-rw-r--r--other/java/hdfs/pom.xml23
-rw-r--r--other/java/hdfs/src/main/java/seaweed/hdfs/SeaweedFileSystem.java96
2 files changed, 119 insertions, 0 deletions
diff --git a/other/java/hdfs/pom.xml b/other/java/hdfs/pom.xml
new file mode 100644
index 000000000..0892c85e8
--- /dev/null
+++ b/other/java/hdfs/pom.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>seaweed.hadoop</groupId>
+ <artifactId>seaweedfs</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <properties>
+ <hadoop.version>2.2.0</hadoop.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-client</artifactId>
+ <version>${hadoop.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/other/java/hdfs/src/main/java/seaweed/hdfs/SeaweedFileSystem.java b/other/java/hdfs/src/main/java/seaweed/hdfs/SeaweedFileSystem.java
new file mode 100644
index 000000000..9b1a842c8
--- /dev/null
+++ b/other/java/hdfs/src/main/java/seaweed/hdfs/SeaweedFileSystem.java
@@ -0,0 +1,96 @@
+package seaweed.hdfs;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FSDataInputStream;
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsPermission;
+import org.apache.hadoop.util.Progressable;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URI;
+
+public class SeaweedFileSystem extends org.apache.hadoop.fs.FileSystem {
+
+ public static final int FS_SEAWEED_DEFAULT_PORT = 8333;
+ public static final String FS_SEAWEED_HOST = "fs.seaweed.host";
+ public static final String FS_SEAWEED_HOST_PORT = "fs.seaweed.host.port";
+
+ private URI uri;
+ private Path workingDirectory = new Path("/");
+
+ public URI getUri() {
+ return uri;
+ }
+
+ public String getScheme() {
+ return "seaweed";
+ }
+
+ @Override
+ public void initialize(URI uri, Configuration conf) throws IOException { // get
+ super.initialize(uri, conf);
+
+ // get host information from uri (overrides info in conf)
+ String host = uri.getHost();
+ host = (host == null) ? conf.get(FS_SEAWEED_HOST, null) : host;
+ if (host == null) {
+ throw new IOException("Invalid host specified");
+ }
+ conf.set(FS_SEAWEED_HOST, host);
+
+ // get port information from uri, (overrides info in conf)
+ int port = uri.getPort();
+ port = (port == -1) ? FS_SEAWEED_DEFAULT_PORT : port;
+ conf.setInt(FS_SEAWEED_HOST_PORT, port);
+
+ setConf(conf);
+ this.uri = uri;
+ }
+
+ public FSDataInputStream open(Path path, int i) throws IOException {
+ return null;
+ }
+
+ public FSDataOutputStream create(Path path, FsPermission fsPermission, boolean b, int i, short i1, long l, Progressable progressable) throws IOException {
+ return null;
+ }
+
+ public FSDataOutputStream append(Path path, int i, Progressable progressable) throws IOException {
+ return null;
+ }
+
+ public boolean rename(Path path, Path path1) throws IOException {
+ return false;
+ }
+
+ public boolean delete(Path path, boolean b) throws IOException {
+ return false;
+ }
+
+ public FileStatus[] listStatus(Path path) throws FileNotFoundException, IOException {
+ return new FileStatus[0];
+ }
+
+ public Path getWorkingDirectory() {
+ return workingDirectory;
+ }
+
+ public void setWorkingDirectory(Path path) {
+ if (path.isAbsolute()) {
+ workingDirectory = path;
+ } else {
+ workingDirectory = new Path(workingDirectory, path);
+ }
+ }
+
+ public boolean mkdirs(Path path, FsPermission fsPermission) throws IOException {
+ return false;
+ }
+
+ public FileStatus getFileStatus(Path path) throws IOException {
+ return null;
+ }
+}