Skip to content

Commit ef5fe72

Browse files
aekom87adoroszlai
authored andcommitted
HDDS-11635. Memory leak when using Ozone FS via Hadoop FileContext API (#7382)
(cherry picked from commit c7a196f)
1 parent bc9832c commit ef5fe72

File tree

7 files changed

+63
-0
lines changed

7 files changed

+63
-0
lines changed

hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzFs.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,13 @@ public BasicOzFs(URI theUri, Configuration conf)
4646
public int getUriDefaultPort() {
4747
return -1;
4848
}
49+
50+
/**
51+
* Close the file system; the FileContext API doesn't have an explicit close.
52+
*/
53+
@Override
54+
protected void finalize() throws Throwable {
55+
fsImpl.close();
56+
super.finalize();
57+
}
4958
}

hadoop-ozone/ozonefs-hadoop2/src/main/java/org/apache/hadoop/fs/ozone/OzFs.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,13 @@ public OzFs(URI theUri, Configuration conf)
4545
public int getUriDefaultPort() {
4646
return -1;
4747
}
48+
49+
/**
50+
* Close the file system; the FileContext API doesn't have an explicit close.
51+
*/
52+
@Override
53+
protected void finalize() throws Throwable {
54+
fsImpl.close();
55+
super.finalize();
56+
}
4857
}

hadoop-ozone/ozonefs-hadoop2/src/main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,13 @@ public RootedOzFs(URI theUri, Configuration conf)
4646
public int getUriDefaultPort() {
4747
return -1;
4848
}
49+
50+
/**
51+
* Close the file system; the FileContext API doesn't have an explicit close.
52+
*/
53+
@Override
54+
protected void finalize() throws Throwable {
55+
fsImpl.close();
56+
super.finalize();
57+
}
4958
}

hadoop-ozone/ozonefs-hadoop3/src/main/java/org/apache/hadoop/fs/ozone/OzFs.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,13 @@ public OzFs(URI theUri, Configuration conf)
4040
super(theUri, new OzoneFileSystem(), conf,
4141
OzoneConsts.OZONE_URI_SCHEME, false);
4242
}
43+
44+
/**
45+
* Close the file system; the FileContext API doesn't have an explicit close.
46+
*/
47+
@Override
48+
protected void finalize() throws Throwable {
49+
fsImpl.close();
50+
super.finalize();
51+
}
4352
}

hadoop-ozone/ozonefs-hadoop3/src/main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,13 @@ public RootedOzFs(URI theUri, Configuration conf)
4141
super(theUri, new RootedOzoneFileSystem(), conf,
4242
OzoneConsts.OZONE_OFS_URI_SCHEME, false);
4343
}
44+
45+
/**
46+
* Close the file system; the FileContext API doesn't have an explicit close.
47+
*/
48+
@Override
49+
protected void finalize() throws Throwable {
50+
fsImpl.close();
51+
super.finalize();
52+
}
4453
}

hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/OzFs.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,13 @@ public OzFs(URI theUri, Configuration conf)
4141
super(theUri, new OzoneFileSystem(), conf,
4242
OzoneConsts.OZONE_URI_SCHEME, false);
4343
}
44+
45+
/**
46+
* Close the file system; the FileContext API doesn't have an explicit close.
47+
*/
48+
@Override
49+
protected void finalize() throws Throwable {
50+
fsImpl.close();
51+
super.finalize();
52+
}
4453
}

hadoop-ozone/ozonefs/src/main/java/org/apache/hadoop/fs/ozone/RootedOzFs.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,13 @@ public RootedOzFs(URI theUri, Configuration conf)
4141
super(theUri, new RootedOzoneFileSystem(), conf,
4242
OzoneConsts.OZONE_OFS_URI_SCHEME, false);
4343
}
44+
45+
/**
46+
* Close the file system; the FileContext API doesn't have an explicit close.
47+
*/
48+
@Override
49+
protected void finalize() throws Throwable {
50+
fsImpl.close();
51+
super.finalize();
52+
}
4453
}

0 commit comments

Comments
 (0)