Browse Source

starting with hadoop compatible

pull/778/head
Chris Lu 6 years ago
parent
commit
76cba561cf
  1. 23
      other/java/hdfs/pom.xml
  2. 96
      other/java/hdfs/src/main/java/seaweed/hdfs/SeaweedFileSystem.java

23
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>

96
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;
}
}
Loading…
Cancel
Save