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 @@ + + + 4.0.0 + + seaweed.hadoop + seaweedfs + 1.0-SNAPSHOT + + + 2.2.0 + + + + + org.apache.hadoop + hadoop-client + ${hadoop.version} + + + + 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; + } +}