Skip to content

Commit

Permalink
HDFS-9223. Code cleanup for DatanodeDescriptor and HeartbeatManager. …
Browse files Browse the repository at this point in the history
…Contributed by Jing Zhao.
  • Loading branch information
Jing9 committed Oct 14, 2015
1 parent a807025 commit be7a0ad
Show file tree
Hide file tree
Showing 14 changed files with 349 additions and 323 deletions.
2 changes: 2 additions & 0 deletions hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
Expand Up @@ -1527,6 +1527,8 @@ Release 2.8.0 - UNRELEASED
HDFS-9238. Update TestFileCreation.testLeaseExpireHardLimit() to avoid using
DataNodeTestUtils.getFile(). (Tony Wu via lei)

HDFS-9223. Code cleanup for DatanodeDescriptor and HeartbeatManager. (jing9)

OPTIMIZATIONS

HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than
Expand Down
Expand Up @@ -1022,9 +1022,9 @@ public void setBlockToken(final LocatedBlock b,
void addKeyUpdateCommand(final List<DatanodeCommand> cmds,
final DatanodeDescriptor nodeinfo) {
// check access key update
if (isBlockTokenEnabled() && nodeinfo.needKeyUpdate) {
if (isBlockTokenEnabled() && nodeinfo.needKeyUpdate()) {
cmds.add(new KeyUpdateCommand(blockTokenSecretManager.exportKeys()));
nodeinfo.needKeyUpdate = false;
nodeinfo.setNeedKeyUpdate(false);
}
}

Expand Down Expand Up @@ -1966,7 +1966,7 @@ public boolean processReport(final DatanodeID nodeID,

try {
node = datanodeManager.getDatanode(nodeID);
if (node == null || !node.isAlive) {
if (node == null || !node.isAlive()) {
throw new IOException(
"ProcessReport from dead or unregistered node: " + nodeID);
}
Expand Down Expand Up @@ -3528,7 +3528,7 @@ public void processIncrementalBlockReport(final DatanodeID nodeID,
int deleted = 0;
int receiving = 0;
final DatanodeDescriptor node = datanodeManager.getDatanode(nodeID);
if (node == null || !node.isAlive) {
if (node == null || !node.isAlive()) {
blockLog.warn("BLOCK* processIncrementalBlockReport"
+ " is received from dead or unregistered node {}", nodeID);
throw new IOException(
Expand Down Expand Up @@ -3678,7 +3678,7 @@ boolean isNodeHealthyForDecommission(DatanodeDescriptor node) {
return false;
}

if (node.isAlive) {
if (node.isAlive()) {
return true;
}

Expand Down
Expand Up @@ -131,7 +131,7 @@ void removeBlock(Block block) {
for(int idx = size - 1; idx >= 0; idx--) {
DatanodeDescriptor dn = blockInfo.getDatanode(idx);
if (dn != null) {
dn.removeBlock(blockInfo); // remove from the list and wipe the location
removeBlock(dn, blockInfo); // remove from the list and wipe the location
}
}
}
Expand Down Expand Up @@ -195,7 +195,7 @@ boolean removeNode(Block b, DatanodeDescriptor node) {
return false;

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

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

/**
* Remove block from the list of blocks belonging to the data-node. Remove
* data-node from the block.
*/
static boolean removeBlock(DatanodeDescriptor dn, BlockInfo b) {
final DatanodeStorageInfo s = b.findStorageInfo(dn);
// if block exists on this datanode
return s != null && s.removeBlock(b);
}

int size() {
if (blocks != null) {
return blocks.size();
Expand Down

0 comments on commit be7a0ad

Please sign in to comment.