From c709059b690e2e5c70b262f4c884bb784cd1781a Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 3 Nov 2020 00:46:00 -0800 Subject: [PATCH] HCFS: add close() to SeaweedFileSystem.java --- .../src/main/java/seaweed/hdfs/SeaweedFileSystem.java | 6 ++++++ .../main/java/seaweed/hdfs/SeaweedFileSystemStore.java | 8 ++++++++ .../src/main/java/seaweed/hdfs/SeaweedFileSystem.java | 6 ++++++ .../main/java/seaweed/hdfs/SeaweedFileSystemStore.java | 8 ++++++++ 4 files changed, 28 insertions(+) diff --git a/other/java/hdfs2/src/main/java/seaweed/hdfs/SeaweedFileSystem.java b/other/java/hdfs2/src/main/java/seaweed/hdfs/SeaweedFileSystem.java index ca67c3874..69df55cf1 100644 --- a/other/java/hdfs2/src/main/java/seaweed/hdfs/SeaweedFileSystem.java +++ b/other/java/hdfs2/src/main/java/seaweed/hdfs/SeaweedFileSystem.java @@ -65,6 +65,12 @@ public class SeaweedFileSystem extends FileSystem { } + @Override + public void close() throws IOException { + this.seaweedFileSystemStore.close(); + super.close(); + } + @Override public FSDataInputStream open(Path path, int bufferSize) throws IOException { diff --git a/other/java/hdfs2/src/main/java/seaweed/hdfs/SeaweedFileSystemStore.java b/other/java/hdfs2/src/main/java/seaweed/hdfs/SeaweedFileSystemStore.java index 23556a578..cec309b3e 100644 --- a/other/java/hdfs2/src/main/java/seaweed/hdfs/SeaweedFileSystemStore.java +++ b/other/java/hdfs2/src/main/java/seaweed/hdfs/SeaweedFileSystemStore.java @@ -36,6 +36,14 @@ public class SeaweedFileSystemStore { this.conf = conf; } + public void close() { + try { + this.filerGrpcClient.shutdown(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + public static String getParentDirectory(Path path) { return path.isRoot() ? "/" : path.getParent().toUri().getPath(); } diff --git a/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedFileSystem.java b/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedFileSystem.java index ca67c3874..69df55cf1 100644 --- a/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedFileSystem.java +++ b/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedFileSystem.java @@ -65,6 +65,12 @@ public class SeaweedFileSystem extends FileSystem { } + @Override + public void close() throws IOException { + this.seaweedFileSystemStore.close(); + super.close(); + } + @Override public FSDataInputStream open(Path path, int bufferSize) throws IOException { diff --git a/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedFileSystemStore.java b/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedFileSystemStore.java index 23556a578..cec309b3e 100644 --- a/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedFileSystemStore.java +++ b/other/java/hdfs3/src/main/java/seaweed/hdfs/SeaweedFileSystemStore.java @@ -36,6 +36,14 @@ public class SeaweedFileSystemStore { this.conf = conf; } + public void close() { + try { + this.filerGrpcClient.shutdown(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + public static String getParentDirectory(Path path) { return path.isRoot() ? "/" : path.getParent().toUri().getPath(); }