K0K0V0K commented on code in PR #8123:
URL: https://github.com/apache/hadoop/pull/8123#discussion_r2896666362


##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/NMWebServices.java:
##########
@@ -628,6 +634,63 @@ public Response syncYarnSysFS(@javax.ws.rs.core.Context
     return Response.ok().build();
   }
 
+
+  @GET
+  @Path("/jstack/{numberOfJStack}")
+  public Response getNodeThreadDump(@PathParam("numberOfJStack") int 
numberOfJStack)
+  {
+    if (isJStackEndpointsEnable) {
+      try {
+        DiagnosticJStackService diagnosticJStackService = new 
DiagnosticJStackService(this.nmContext);
+        return Response.status(Status.OK)
+                
.entity(diagnosticJStackService.collectNodeThreadDump(numberOfJStack))
+                .build();
+      } catch (IOException e){
+        throw new WebAppException("Shell command has failed: " + 
e.getMessage() + ". " +
+                "For more information please check the NodeManager logs.");
+      } catch (Exception e) {
+        throw new WebAppException(
+                "Unexpected error collection NodeManager JStack: " + 
e.getMessage() + ". " +
+                "For more information please check the NodeManager logs.");
+      }
+    } else {
+      return Response.status(Status.METHOD_NOT_ALLOWED)

Review Comment:
   I think an early return can reduce the method complexity here



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