Skip to content

Commit 5458ebf

Browse files
virajjasaniliuml07
authored andcommitted
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 93517ba commit 5458ebf

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
@@ -140,7 +140,7 @@ public class MiniRouterDFSCluster {
140140
/**
141141
* Router context.
142142
*/
143-
public class RouterContext {
143+
public static class RouterContext {
144144
private Router router;
145145
private FileContext fileContext;
146146
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
@@ -130,7 +130,7 @@ public Iterator<FileRegion> iterator() {
130130
}
131131
}
132132

133-
class LevelDbWriter extends BlockAliasMap.Writer<FileRegion> {
133+
static class LevelDbWriter extends BlockAliasMap.Writer<FileRegion> {
134134

135135
private InMemoryAliasMapProtocol aliasMap;
136136

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
@@ -64,7 +64,7 @@ public class DebugAdmin extends Configured implements Tool {
6464
/**
6565
* All the debug commands we can run.
6666
*/
67-
private DebugCommand DEBUG_COMMANDS[] = {
67+
private final DebugCommand[] DEBUG_COMMANDS = {
6868
new VerifyMetaCommand(),
6969
new ComputeMetaCommand(),
7070
new RecoverLeaseCommand(),
@@ -74,7 +74,7 @@ public class DebugAdmin extends Configured implements Tool {
7474
/**
7575
* The base class for debug commands.
7676
*/
77-
private abstract class DebugCommand {
77+
private abstract static class DebugCommand {
7878
final String name;
7979
final String usageText;
8080
final String helpText;
@@ -93,15 +93,15 @@ private abstract class DebugCommand {
9393
/**
9494
* The command for verifying a block metadata file and possibly block file.
9595
*/
96-
private class VerifyMetaCommand extends DebugCommand {
96+
private static class VerifyMetaCommand extends DebugCommand {
9797
VerifyMetaCommand() {
9898
super("verifyMeta",
99-
"verifyMeta -meta <metadata-file> [-block <block-file>]",
100-
" Verify HDFS metadata and block files. If a block file is specified, we" +
101-
System.lineSeparator() +
102-
" will verify that the checksums in the metadata file match the block" +
103-
System.lineSeparator() +
104-
" file.");
99+
"verifyMeta -meta <metadata-file> [-block <block-file>]",
100+
" Verify HDFS metadata and block files. If a block file is specified, we" +
101+
System.lineSeparator() +
102+
" will verify that the checksums in the metadata file match the block" +
103+
System.lineSeparator() +
104+
" file.");
105105
}
106106

107107
int run(List<String> args) throws IOException {
@@ -209,7 +209,7 @@ int run(List<String> args) throws IOException {
209209
/**
210210
* The command for verifying a block metadata file and possibly block file.
211211
*/
212-
private class ComputeMetaCommand extends DebugCommand {
212+
private static class ComputeMetaCommand extends DebugCommand {
213213
ComputeMetaCommand() {
214214
super("computeMeta",
215215
"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
@@ -562,7 +562,7 @@ protected MiniDFSCluster(Builder builder) throws IOException {
562562
builder.useConfiguredTopologyMappingClass);
563563
}
564564

565-
public class DataNodeProperties {
565+
public static class DataNodeProperties {
566566
final DataNode datanode;
567567
final Configuration conf;
568568
String[] dnArgs;

0 commit comments

Comments
 (0)