aboutsummaryrefslogtreecommitdiff
path: root/other/java/examples/src
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-11-13 11:43:25 -0800
committerChris Lu <chris.lu@gmail.com>2020-11-13 11:43:25 -0800
commit0d5355c6141f4d5ff83933f0b7803e88ae1df90b (patch)
treee1f54faec4544db37853035ca92882e2f5a71e93 /other/java/examples/src
parent7d249808407588431f00424dbb2ca599cc9441c6 (diff)
downloadseaweedfs-0d5355c6141f4d5ff83933f0b7803e88ae1df90b.tar.xz
seaweedfs-0d5355c6141f4d5ff83933f0b7803e88ae1df90b.zip
rename
Diffstat (limited to 'other/java/examples/src')
-rw-r--r--other/java/examples/src/main/java/com/example/test/Example.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/other/java/examples/src/main/java/com/example/test/Example.java b/other/java/examples/src/main/java/com/example/test/Example.java
new file mode 100644
index 000000000..3d22329a8
--- /dev/null
+++ b/other/java/examples/src/main/java/com/example/test/Example.java
@@ -0,0 +1,56 @@
+package com.example.test;
+
+import seaweed.hdfs.SeaweedInputStream;
+import seaweedfs.client.FilerClient;
+import seaweedfs.client.FilerGrpcClient;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+
+public class Example {
+
+ public static FilerClient filerClient = new FilerClient("localhost", 18888);
+ public static FilerGrpcClient filerGrpcClient = new FilerGrpcClient("localhost", 18888);
+
+ public static void main(String[] args) throws IOException {
+
+ long startTime = System.currentTimeMillis();
+ // 本地模式,速度很快
+ parseZip("/Users/chris/tmp/test.zip");
+
+ long startTime2 = System.currentTimeMillis();
+
+ long localProcessTime = startTime2 - startTime;
+
+ // swfs读取,慢
+ SeaweedInputStream seaweedInputStream = new SeaweedInputStream(
+ filerGrpcClient,
+ new org.apache.hadoop.fs.FileSystem.Statistics(""),
+ "/",
+ filerClient.lookupEntry("/", "test.zip")
+ );
+ parseZip(seaweedInputStream);
+
+ long swProcessTime = System.currentTimeMillis() - startTime2;
+
+ System.out.println("Local time: " + localProcessTime);
+ System.out.println("SeaweedFS time: " + swProcessTime);
+
+ }
+
+ public static void parseZip(String filename) throws IOException {
+ FileInputStream fileInputStream = new FileInputStream(filename);
+ parseZip(fileInputStream);
+ }
+
+ public static void parseZip(InputStream is) throws IOException {
+ ZipInputStream zin = new ZipInputStream(is);
+ ZipEntry ze;
+ while ((ze = zin.getNextEntry()) != null) {
+ System.out.println(ze.getName());
+ }
+ }
+}