Skip to content

Commit 4f28738

Browse files
authored
HDFS-15931 : Fix non-static inner classes for better memory management (#2830). Contributed by Viraj Jasani
Signed-off-by: Mingliang Liu <liuml07@apache.org>
1 parent 158758c commit 4f28738

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/MiniRouterDFSCluster.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public class MiniRouterDFSCluster {
152152
/**
153153
* Router context.
154154
*/
155-
public class RouterContext {
155+
public static class RouterContext {
156156
private Router router;
157157
private FileContext fileContext;
158158
private String nameserviceId;

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/blockaliasmap/impl/InMemoryLevelDBAliasMapClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public Iterator<FileRegion> iterator() {
129129
}
130130
}
131131

132-
class LevelDbWriter extends BlockAliasMap.Writer<FileRegion> {
132+
static class LevelDbWriter extends BlockAliasMap.Writer<FileRegion> {
133133

134134
private InMemoryAliasMapProtocol aliasMap;
135135

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/RamDiskReplicaLruTracker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
@InterfaceStability.Unstable
3636
public class RamDiskReplicaLruTracker extends RamDiskReplicaTracker {
3737

38-
private class RamDiskReplicaLru extends RamDiskReplica {
38+
private static class RamDiskReplicaLru extends RamDiskReplica {
3939
long lastUsedTime;
4040

4141
private RamDiskReplicaLru(String bpid, long blockId,
@@ -88,7 +88,7 @@ synchronized void addReplica(final String bpid, final long blockId,
8888
}
8989
RamDiskReplicaLru ramDiskReplicaLru =
9090
new RamDiskReplicaLru(bpid, blockId, transientVolume,
91-
lockedBytesReserved);
91+
lockedBytesReserved);
9292
map.put(blockId, ramDiskReplicaLru);
9393
replicasNotPersisted.add(ramDiskReplicaLru);
9494
}

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ReencryptionHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ protected void readUnlock() {
835835
}
836836
}
837837

838-
private class ZoneTraverseInfo extends TraverseInfo {
838+
private static class ZoneTraverseInfo extends TraverseInfo {
839839
private String ezKeyVerName;
840840

841841
ZoneTraverseInfo(String ezKeyVerName) {

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DebugAdmin.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public class DebugAdmin extends Configured implements Tool {
6565
/**
6666
* All the debug commands we can run.
6767
*/
68-
private DebugCommand DEBUG_COMMANDS[] = {
68+
private final DebugCommand[] DEBUG_COMMANDS = {
6969
new VerifyMetaCommand(),
7070
new ComputeMetaCommand(),
7171
new RecoverLeaseCommand(),
@@ -75,7 +75,7 @@ public class DebugAdmin extends Configured implements Tool {
7575
/**
7676
* The base class for debug commands.
7777
*/
78-
private abstract class DebugCommand {
78+
private abstract static class DebugCommand {
7979
final String name;
8080
final String usageText;
8181
final String helpText;
@@ -94,15 +94,15 @@ private abstract class DebugCommand {
9494
/**
9595
* The command for verifying a block metadata file and possibly block file.
9696
*/
97-
private class VerifyMetaCommand extends DebugCommand {
97+
private static class VerifyMetaCommand extends DebugCommand {
9898
VerifyMetaCommand() {
9999
super("verifyMeta",
100-
"verifyMeta -meta <metadata-file> [-block <block-file>]",
101-
" Verify HDFS metadata and block files. If a block file is specified, we" +
102-
System.lineSeparator() +
103-
" will verify that the checksums in the metadata file match the block" +
104-
System.lineSeparator() +
105-
" file.");
100+
"verifyMeta -meta <metadata-file> [-block <block-file>]",
101+
" Verify HDFS metadata and block files. If a block file is specified, we" +
102+
System.lineSeparator() +
103+
" will verify that the checksums in the metadata file match the block" +
104+
System.lineSeparator() +
105+
" file.");
106106
}
107107

108108
int run(List<String> args) throws IOException {
@@ -210,7 +210,7 @@ int run(List<String> args) throws IOException {
210210
/**
211211
* The command for verifying a block metadata file and possibly block file.
212212
*/
213-
private class ComputeMetaCommand extends DebugCommand {
213+
private static class ComputeMetaCommand extends DebugCommand {
214214
ComputeMetaCommand() {
215215
super("computeMeta",
216216
"computeMeta -block <block-file> -out <output-metadata-file>",

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/MiniDFSCluster.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ protected MiniDFSCluster(Builder builder) throws IOException {
599599
builder.useConfiguredTopologyMappingClass);
600600
}
601601

602-
public class DataNodeProperties {
602+
public static class DataNodeProperties {
603603
final DataNode datanode;
604604
final Configuration conf;
605605
String[] dnArgs;

0 commit comments

Comments
 (0)