From 99f7ad76df4d336bc91920244ebbcb871005b48b Mon Sep 17 00:00:00 2001 From: aekom87 Date: Wed, 30 Oct 2024 10:56:59 +0300 Subject: [PATCH] Close internal FS on finilize --- .../main/java/org/apache/hadoop/fs/ozone/BasicOzFs.java | 9 +++++++++ .../src/main/java/org/apache/hadoop/fs/ozone/OzFs.java | 9 +++++++++ .../main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java | 9 +++++++++ .../src/main/java/org/apache/hadoop/fs/ozone/OzFs.java | 9 +++++++++ .../main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java | 9 +++++++++ .../src/main/java/org/apache/hadoop/fs/ozone/OzFs.java | 9 +++++++++ .../main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java | 9 +++++++++ 7 files changed, 63 insertions(+) diff --git a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzFs.java b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzFs.java index acab6d168cc..9f7551aa8f0 100644 --- a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzFs.java +++ b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzFs.java @@ -46,4 +46,13 @@ public BasicOzFs(URI theUri, Configuration conf) public int getUriDefaultPort() { return -1; } + + /** + * Close the file system; the FileContext API doesn't have an explicit close. + */ + @Override + protected void finalize() throws Throwable { + fsImpl.close(); + super.finalize(); + } } diff --git a/hadoop-ozone/ozonefs-hadoop2/src/main/java/org/apache/hadoop/fs/ozone/OzFs.java b/hadoop-ozone/ozonefs-hadoop2/src/main/java/org/apache/hadoop/fs/ozone/OzFs.java index b5012f95c4e..e1cb391da53 100644 --- a/hadoop-ozone/ozonefs-hadoop2/src/main/java/org/apache/hadoop/fs/ozone/OzFs.java +++ b/hadoop-ozone/ozonefs-hadoop2/src/main/java/org/apache/hadoop/fs/ozone/OzFs.java @@ -45,4 +45,13 @@ public OzFs(URI theUri, Configuration conf) public int getUriDefaultPort() { return -1; } + + /** + * Close the file system; the FileContext API doesn't have an explicit close. + */ + @Override + protected void finalize() throws Throwable { + fsImpl.close(); + super.finalize(); + } } diff --git a/hadoop-ozone/ozonefs-hadoop2/src/main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java b/hadoop-ozone/ozonefs-hadoop2/src/main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java index 4cd04da9c86..0f421a85523 100644 --- a/hadoop-ozone/ozonefs-hadoop2/src/main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java +++ b/hadoop-ozone/ozonefs-hadoop2/src/main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java @@ -46,4 +46,13 @@ public RootedOzFs(URI theUri, Configuration conf) public int getUriDefaultPort() { return -1; } + + /** + * Close the file system; the FileContext API doesn't have an explicit close. + */ + @Override + protected void finalize() throws Throwable { + fsImpl.close(); + super.finalize(); + } } diff --git a/hadoop-ozone/ozonefs-hadoop3/src/main/java/org/apache/hadoop/fs/ozone/OzFs.java b/hadoop-ozone/ozonefs-hadoop3/src/main/java/org/apache/hadoop/fs/ozone/OzFs.java index 914832e2cfa..b1e046547fa 100644 --- a/hadoop-ozone/ozonefs-hadoop3/src/main/java/org/apache/hadoop/fs/ozone/OzFs.java +++ b/hadoop-ozone/ozonefs-hadoop3/src/main/java/org/apache/hadoop/fs/ozone/OzFs.java @@ -40,4 +40,13 @@ public OzFs(URI theUri, Configuration conf) super(theUri, new OzoneFileSystem(), conf, OzoneConsts.OZONE_URI_SCHEME, false); } + + /** + * Close the file system; the FileContext API doesn't have an explicit close. + */ + @Override + protected void finalize() throws Throwable { + fsImpl.close(); + super.finalize(); + } } diff --git a/hadoop-ozone/ozonefs-hadoop3/src/main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java b/hadoop-ozone/ozonefs-hadoop3/src/main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java index 076287eaac1..81bbaacd7c8 100644 --- a/hadoop-ozone/ozonefs-hadoop3/src/main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java +++ b/hadoop-ozone/ozonefs-hadoop3/src/main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java @@ -41,4 +41,13 @@ public RootedOzFs(URI theUri, Configuration conf) super(theUri, new RootedOzoneFileSystem(), conf, OzoneConsts.OZONE_OFS_URI_SCHEME, false); } + + /** + * Close the file system; the FileContext API doesn't have an explicit close. + */ + @Override + protected void finalize() throws Throwable { + fsImpl.close(); + super.finalize(); + } } diff --git a/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/OzFs.java b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/OzFs.java index 346b994a3ae..548e11f5d48 100644 --- a/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/OzFs.java +++ b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/OzFs.java @@ -41,4 +41,13 @@ public OzFs(URI theUri, Configuration conf) super(theUri, new OzoneFileSystem(), conf, OzoneConsts.OZONE_URI_SCHEME, false); } + + /** + * Close the file system; the FileContext API doesn't have an explicit close. + */ + @Override + protected void finalize() throws Throwable { + fsImpl.close(); + super.finalize(); + } } diff --git a/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java index 076287eaac1..81bbaacd7c8 100644 --- a/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java +++ b/hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java @@ -41,4 +41,13 @@ public RootedOzFs(URI theUri, Configuration conf) super(theUri, new RootedOzoneFileSystem(), conf, OzoneConsts.OZONE_OFS_URI_SCHEME, false); } + + /** + * Close the file system; the FileContext API doesn't have an explicit close. + */ + @Override + protected void finalize() throws Throwable { + fsImpl.close(); + super.finalize(); + } }