Skip to content

Commit be7a0ad

Browse files
committed
HDFS-9223. Code cleanup for DatanodeDescriptor and HeartbeatManager. Contributed by Jing Zhao.
1 parent a807025 commit be7a0ad

File tree

14 files changed

+349
-323
lines changed

14 files changed

+349
-323
lines changed

hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,8 @@ Release 2.8.0 - UNRELEASED
15271527
HDFS-9238. Update TestFileCreation.testLeaseExpireHardLimit() to avoid using
15281528
DataNodeTestUtils.getFile(). (Tony Wu via lei)
15291529

1530+
HDFS-9223. Code cleanup for DatanodeDescriptor and HeartbeatManager. (jing9)
1531+
15301532
OPTIMIZATIONS
15311533

15321534
HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,9 +1022,9 @@ public void setBlockToken(final LocatedBlock b,
10221022
void addKeyUpdateCommand(final List<DatanodeCommand> cmds,
10231023
final DatanodeDescriptor nodeinfo) {
10241024
// check access key update
1025-
if (isBlockTokenEnabled() && nodeinfo.needKeyUpdate) {
1025+
if (isBlockTokenEnabled() && nodeinfo.needKeyUpdate()) {
10261026
cmds.add(new KeyUpdateCommand(blockTokenSecretManager.exportKeys()));
1027-
nodeinfo.needKeyUpdate = false;
1027+
nodeinfo.setNeedKeyUpdate(false);
10281028
}
10291029
}
10301030

@@ -1966,7 +1966,7 @@ public boolean processReport(final DatanodeID nodeID,
19661966

19671967
try {
19681968
node = datanodeManager.getDatanode(nodeID);
1969-
if (node == null || !node.isAlive) {
1969+
if (node == null || !node.isAlive()) {
19701970
throw new IOException(
19711971
"ProcessReport from dead or unregistered node: " + nodeID);
19721972
}
@@ -3528,7 +3528,7 @@ public void processIncrementalBlockReport(final DatanodeID nodeID,
35283528
int deleted = 0;
35293529
int receiving = 0;
35303530
final DatanodeDescriptor node = datanodeManager.getDatanode(nodeID);
3531-
if (node == null || !node.isAlive) {
3531+
if (node == null || !node.isAlive()) {
35323532
blockLog.warn("BLOCK* processIncrementalBlockReport"
35333533
+ " is received from dead or unregistered node {}", nodeID);
35343534
throw new IOException(
@@ -3678,7 +3678,7 @@ boolean isNodeHealthyForDecommission(DatanodeDescriptor node) {
36783678
return false;
36793679
}
36803680

3681-
if (node.isAlive) {
3681+
if (node.isAlive()) {
36823682
return true;
36833683
}
36843684

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlocksMap.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ void removeBlock(Block block) {
131131
for(int idx = size - 1; idx >= 0; idx--) {
132132
DatanodeDescriptor dn = blockInfo.getDatanode(idx);
133133
if (dn != null) {
134-
dn.removeBlock(blockInfo); // remove from the list and wipe the location
134+
removeBlock(dn, blockInfo); // remove from the list and wipe the location
135135
}
136136
}
137137
}
@@ -195,7 +195,7 @@ boolean removeNode(Block b, DatanodeDescriptor node) {
195195
return false;
196196

197197
// remove block from the data-node list and the node from the block info
198-
boolean removed = node.removeBlock(info);
198+
boolean removed = removeBlock(node, info);
199199

200200
if (info.hasNoStorage() // no datanodes left
201201
&& info.isDeleted()) { // does not belong to a file
@@ -204,6 +204,16 @@ boolean removeNode(Block b, DatanodeDescriptor node) {
204204
return removed;
205205
}
206206

207+
/**
208+
* Remove block from the list of blocks belonging to the data-node. Remove
209+
* data-node from the block.
210+
*/
211+
static boolean removeBlock(DatanodeDescriptor dn, BlockInfo b) {
212+
final DatanodeStorageInfo s = b.findStorageInfo(dn);
213+
// if block exists on this datanode
214+
return s != null && s.removeBlock(b);
215+
}
216+
207217
int size() {
208218
if (blocks != null) {
209219
return blocks.size();

0 commit comments

Comments
 (0)