diff --git a/other/java/client/pom.xml b/other/java/client/pom.xml
index d2c91b121..70c5dbd31 100644
--- a/other/java/client/pom.xml
+++ b/other/java/client/pom.xml
@@ -5,7 +5,7 @@
com.github.chrislusf
seaweedfs-client
- 1.6.6
+ 1.6.7
org.sonatype.oss
diff --git a/other/java/client/pom.xml.deploy b/other/java/client/pom.xml.deploy
index 7910e2491..82cf5e82b 100644
--- a/other/java/client/pom.xml.deploy
+++ b/other/java/client/pom.xml.deploy
@@ -5,7 +5,7 @@
com.github.chrislusf
seaweedfs-client
- 1.6.6
+ 1.6.7
org.sonatype.oss
diff --git a/other/java/client/pom_debug.xml b/other/java/client/pom_debug.xml
index c3cf904c0..c72c81ab7 100644
--- a/other/java/client/pom_debug.xml
+++ b/other/java/client/pom_debug.xml
@@ -5,7 +5,7 @@
com.github.chrislusf
seaweedfs-client
- 1.6.6
+ 1.6.7
org.sonatype.oss
diff --git a/other/java/client/src/main/java/seaweedfs/client/RemoteUtil.java b/other/java/client/src/main/java/seaweedfs/client/RemoteUtil.java
new file mode 100644
index 000000000..39c17644b
--- /dev/null
+++ b/other/java/client/src/main/java/seaweedfs/client/RemoteUtil.java
@@ -0,0 +1,23 @@
+package seaweedfs.client;
+
+import java.io.IOException;
+
+public class RemoteUtil {
+ public static boolean isInRemoteOnly(FilerProto.Entry entry) {
+ if (entry.getChunksList() == null || entry.getChunksList().isEmpty()) {
+ return entry.getRemoteEntry() != null && entry.getRemoteEntry().getRemoteSize() > 0;
+ }
+ return false;
+ }
+
+ public static FilerProto.Entry downloadRemoteEntry(FilerClient filerClient, String fullpath, FilerProto.Entry entry) throws IOException {
+ String dir = SeaweedOutputStream.getParentDirectory(fullpath);
+ String name = SeaweedOutputStream.getFileName(fullpath);
+
+ final FilerProto.DownloadToLocalResponse downloadToLocalResponse = filerClient.getBlockingStub()
+ .downloadToLocal(FilerProto.DownloadToLocalRequest.newBuilder()
+ .setDirectory(dir).setName(name).build());
+
+ return downloadToLocalResponse.getEntry();
+ }
+}
diff --git a/other/java/client/src/main/java/seaweedfs/client/SeaweedInputStream.java b/other/java/client/src/main/java/seaweedfs/client/SeaweedInputStream.java
index 6097b8d56..9d1fb3417 100644
--- a/other/java/client/src/main/java/seaweedfs/client/SeaweedInputStream.java
+++ b/other/java/client/src/main/java/seaweedfs/client/SeaweedInputStream.java
@@ -19,9 +19,9 @@ public class SeaweedInputStream extends InputStream {
private final FilerClient filerClient;
private final String path;
- private final FilerProto.Entry entry;
private final List visibleIntervalList;
private final long contentLength;
+ private FilerProto.Entry entry;
private long position = 0; // cursor of the file
@@ -35,10 +35,14 @@ public class SeaweedInputStream extends InputStream {
this.entry = filerClient.lookupEntry(
SeaweedOutputStream.getParentDirectory(fullpath),
SeaweedOutputStream.getFileName(fullpath));
- if(entry == null){
+ if (entry == null) {
throw new FileNotFoundException();
}
+ if (RemoteUtil.isInRemoteOnly(entry)) {
+ entry = RemoteUtil.downloadRemoteEntry(filerClient, fullpath, entry);
+ }
+
this.contentLength = SeaweedRead.fileSize(entry);
this.visibleIntervalList = SeaweedRead.nonOverlappingVisibleIntervals(filerClient, entry.getChunksList());
@@ -54,6 +58,11 @@ public class SeaweedInputStream extends InputStream {
this.filerClient = filerClient;
this.path = path;
this.entry = entry;
+
+ if (RemoteUtil.isInRemoteOnly(entry)) {
+ this.entry = RemoteUtil.downloadRemoteEntry(filerClient, path, entry);
+ }
+
this.contentLength = SeaweedRead.fileSize(entry);
this.visibleIntervalList = SeaweedRead.nonOverlappingVisibleIntervals(filerClient, entry.getChunksList());
@@ -111,8 +120,8 @@ public class SeaweedInputStream extends InputStream {
long bytesRead = 0;
int len = buf.remaining();
int start = (int) this.position;
- if (start+len <= entry.getContent().size()) {
- entry.getContent().substring(start, start+len).copyTo(buf);
+ if (start + len <= entry.getContent().size()) {
+ entry.getContent().substring(start, start + len).copyTo(buf);
} else {
bytesRead = SeaweedRead.read(this.filerClient, this.visibleIntervalList, this.position, buf, SeaweedRead.fileSize(entry));
}
diff --git a/other/java/examples/pom.xml b/other/java/examples/pom.xml
index 9a42a0191..26c9bdfdc 100644
--- a/other/java/examples/pom.xml
+++ b/other/java/examples/pom.xml
@@ -11,13 +11,13 @@
com.github.chrislusf
seaweedfs-client
- 1.6.6
+ 1.6.7
compile
com.github.chrislusf
seaweedfs-hadoop2-client
- 1.6.6
+ 1.6.7
compile
diff --git a/other/java/hdfs2/dependency-reduced-pom.xml b/other/java/hdfs2/dependency-reduced-pom.xml
index 1b5a5c3fc..bd31637ce 100644
--- a/other/java/hdfs2/dependency-reduced-pom.xml
+++ b/other/java/hdfs2/dependency-reduced-pom.xml
@@ -301,7 +301,7 @@
- 1.6.6
+ 1.6.7
2.9.2
diff --git a/other/java/hdfs2/pom.xml b/other/java/hdfs2/pom.xml
index 58e51a2a1..f15d24faa 100644
--- a/other/java/hdfs2/pom.xml
+++ b/other/java/hdfs2/pom.xml
@@ -5,7 +5,7 @@
4.0.0
- 1.6.6
+ 1.6.7
2.9.2
diff --git a/other/java/hdfs3/dependency-reduced-pom.xml b/other/java/hdfs3/dependency-reduced-pom.xml
index 58556a9c7..4640b5a84 100644
--- a/other/java/hdfs3/dependency-reduced-pom.xml
+++ b/other/java/hdfs3/dependency-reduced-pom.xml
@@ -309,7 +309,7 @@
- 1.6.6
+ 1.6.7
3.1.1
diff --git a/other/java/hdfs3/pom.xml b/other/java/hdfs3/pom.xml
index bbcc1788d..efcc1e4c0 100644
--- a/other/java/hdfs3/pom.xml
+++ b/other/java/hdfs3/pom.xml
@@ -5,7 +5,7 @@
4.0.0
- 1.6.6
+ 1.6.7
3.1.1