Browse Source

refactor

pull/809/head
Chris Lu 6 years ago
parent
commit
9123d799b8
  1. 11
      other/java/client/pom.xml
  2. 2
      other/java/client/src/main/java/seaweedfs/client/ByteBufferOutputStream.java
  3. 4
      other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java
  4. 4
      other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java
  5. 40
      other/java/client/src/test/java/seaweedfs/client/SeaweedReadTest.java
  6. 11
      other/java/hdfs/pom.xml
  7. 1
      other/java/hdfs/src/main/java/seaweed/hdfs/SeaweedFileSystemStore.java
  8. 1
      other/java/hdfs/src/main/java/seaweed/hdfs/SeaweedInputStream.java
  9. 1
      other/java/hdfs/src/main/java/seaweed/hdfs/SeaweedOutputStream.java

11
other/java/client/pom.xml

@ -50,6 +50,17 @@
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.6</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<distributionManagement>

2
other/java/hdfs/src/main/java/seaweed/hdfs/ByteBufferOutputStream.java → other/java/client/src/main/java/seaweedfs/client/ByteBufferOutputStream.java

@ -1,4 +1,4 @@
package seaweed.hdfs;
package seaweedfs.client;
import java.io.IOException;
import java.io.OutputStream;

4
other/java/hdfs/src/main/java/seaweed/hdfs/SeaweedRead.java → other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java

@ -1,4 +1,4 @@
package seaweed.hdfs;
package seaweedfs.client;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHeaders;
@ -6,8 +6,6 @@ import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder;
import seaweedfs.client.FilerGrpcClient;
import seaweedfs.client.FilerProto;
import java.io.IOException;
import java.io.OutputStream;

4
other/java/hdfs/src/main/java/seaweed/hdfs/SeaweedWrite.java → other/java/client/src/main/java/seaweedfs/client/SeaweedWrite.java

@ -1,4 +1,4 @@
package seaweed.hdfs;
package seaweedfs.client;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
@ -6,8 +6,6 @@ import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import seaweedfs.client.FilerGrpcClient;
import seaweedfs.client.FilerProto;
import java.io.ByteArrayInputStream;
import java.io.IOException;

40
other/java/hdfs/src/test/java/seaweed/hdfs/SeaweedReadTest.java → other/java/client/src/test/java/seaweedfs/client/SeaweedReadTest.java

@ -1,13 +1,11 @@
package seaweed.hdfs;
package seaweedfs.client;
import org.junit.Assert;
import org.junit.Test;
import seaweedfs.client.FilerProto;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
public class SeaweedReadTest {
@Test
@ -31,33 +29,33 @@ public class SeaweedReadTest {
System.out.println("visible:" + visibleInterval);
}
assertEquals(visibleIntervals.size(), 2);
Assert.assertEquals(visibleIntervals.size(), 2);
SeaweedRead.VisibleInterval visibleInterval = visibleIntervals.get(0);
assertEquals(visibleInterval.start, 0);
assertEquals(visibleInterval.stop, 100);
assertEquals(visibleInterval.modifiedTime, 1000);
assertEquals(visibleInterval.fileId, "aaa");
Assert.assertEquals(visibleInterval.start, 0);
Assert.assertEquals(visibleInterval.stop, 100);
Assert.assertEquals(visibleInterval.modifiedTime, 1000);
Assert.assertEquals(visibleInterval.fileId, "aaa");
visibleInterval = visibleIntervals.get(1);
assertEquals(visibleInterval.start, 100);
assertEquals(visibleInterval.stop, 233);
assertEquals(visibleInterval.modifiedTime, 2000);
assertEquals(visibleInterval.fileId, "bbb");
Assert.assertEquals(visibleInterval.start, 100);
Assert.assertEquals(visibleInterval.stop, 233);
Assert.assertEquals(visibleInterval.modifiedTime, 2000);
Assert.assertEquals(visibleInterval.fileId, "bbb");
List<SeaweedRead.ChunkView> chunkViews = SeaweedRead.viewFromVisibles(visibleIntervals, 0, 233);
SeaweedRead.ChunkView chunkView = chunkViews.get(0);
assertEquals(chunkView.offset, 0);
assertEquals(chunkView.size, 100);
assertEquals(chunkView.logicOffset, 0);
assertEquals(chunkView.fileId, "aaa");
Assert.assertEquals(chunkView.offset, 0);
Assert.assertEquals(chunkView.size, 100);
Assert.assertEquals(chunkView.logicOffset, 0);
Assert.assertEquals(chunkView.fileId, "aaa");
chunkView = chunkViews.get(1);
assertEquals(chunkView.offset, 0);
assertEquals(chunkView.size, 133);
assertEquals(chunkView.logicOffset, 100);
assertEquals(chunkView.fileId, "bbb");
Assert.assertEquals(chunkView.offset, 0);
Assert.assertEquals(chunkView.size, 133);
Assert.assertEquals(chunkView.logicOffset, 100);
Assert.assertEquals(chunkView.fileId, "bbb");
}

11
other/java/hdfs/pom.xml

@ -154,17 +154,6 @@
<artifactId>hadoop-common</artifactId>
<version>${hadoop.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.6</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

1
other/java/hdfs/src/main/java/seaweed/hdfs/SeaweedFileSystemStore.java

@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory;
import seaweedfs.client.FilerClient;
import seaweedfs.client.FilerGrpcClient;
import seaweedfs.client.FilerProto;
import seaweedfs.client.SeaweedRead;
import java.io.FileNotFoundException;
import java.io.IOException;

1
other/java/hdfs/src/main/java/seaweed/hdfs/SeaweedInputStream.java

@ -10,6 +10,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import seaweedfs.client.FilerGrpcClient;
import seaweedfs.client.FilerProto;
import seaweedfs.client.SeaweedRead;
import java.io.EOFException;
import java.io.IOException;

1
other/java/hdfs/src/main/java/seaweed/hdfs/SeaweedOutputStream.java

@ -11,6 +11,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import seaweedfs.client.FilerGrpcClient;
import seaweedfs.client.FilerProto;
import seaweedfs.client.SeaweedWrite;
import java.io.IOException;
import java.io.InterruptedIOException;

Loading…
Cancel
Save