virajjasani commented on code in PR #5349:
URL: https://github.com/apache/hadoop/pull/5349#discussion_r1098087120
##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java:
##########
@@ -3825,14 +3829,37 @@ boolean isRestarting() {
* @return true - if the data node is fully started
*/
public boolean isDatanodeFullyStarted() {
+ return isDatanodeFullyStarted(false);
+ }
+
+ /**
+ * A datanode is considered to be fully started if all the BP threads are
+ * alive and all the block pools are initialized. If
checkConnectionToActiveNamenode is true,
+ * the datanode is considered to be fully started if it is also heartbeating
to
+ * active namenode in addition to the above-mentioned conditions.
+ *
+ * @param checkConnectionToActiveNamenode if true, performs additional check
of whether datanode
+ * is heartbeating to active namenode.
+ * @return true if the datanode is fully started and also conditionally
connected to active
+ * namenode, false otherwise.
+ */
+ public boolean isDatanodeFullyStarted(boolean
checkConnectionToActiveNamenode) {
+ if (checkConnectionToActiveNamenode) {
Review Comment:
We will loop only once. To make it more readable, I made it like this:
```
if (true) {
for(loop) {
return false; <=== for true case only, this gets executed
}
return true; <=== for true case, we will not have to go to next for loop
}
for(loop) {
return false; <=== for false case only, this gets executed
}
return true; <=== for false case, we will directly come to this for loop
only, not the one inside if condition
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]