LuciferYang commented on code in PR #36890:
URL: https://github.com/apache/spark/pull/36890#discussion_r900920200


##########
resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/YarnAllocator.scala:
##########
@@ -1004,3 +1020,35 @@ private object YarnAllocator {
     ContainerExitStatus.DISKS_FAILED
   )
 }
+
+/**
+ * State of the node.
+ * Add the node state depending upon the cluster manager for Yarn
+ */
+private[spark] object NodeState extends Enumeration {
+  val RUNNING, DECOMMISSIONED, DECOMMISSIONING, LOST, OTHER = Value
+  type NodeState = Value
+
+  // Helper method to get NodeState of the Yarn.
+  def getYarnNodeState(state: YarnNodeState): NodeState.Value = {
+    // In hadoop-2.7 there is no support for node state DECOMMISSIONING
+    // In Hadoop-2.8, hadoop3.1 and later version of spark there is a support
+    // to node state DECOMMISSIONING.
+    // Inorder to build the spark using hadoop2 and hadoop3,
+    // using string comparison for the YARN node state DECOMMISSIONING here and
+    // for other states we are matching the YarnNodeState and assigning
+    // the node state at spark end
+    if (state.toString.equals(NodeState.DECOMMISSIONING.toString)) {

Review Comment:
   should we change to
   ```scala
   state match {
         case YarnNodeState.RUNNING => NodeState.RUNNING
         case YarnNodeState.DECOMMISSIONED => NodeState.DECOMMISSIONED
         case YarnNodeState.LOST => NodeState.LOST
         case YarnNodeState.UNHEALTHY => NodeState.LOST
         case other if 
other.toString.equals(NodeState.DECOMMISSIONING.toString) =>
           NodeState.DECOMMISSIONING
         case _ => NodeState.OTHER
       }
   ```



-- 
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]

Reply via email to