[ 
https://issues.apache.org/jira/browse/YARN-11823?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17966296#comment-17966296
 ] 

ASF GitHub Bot commented on YARN-11823:
---------------------------------------

Hean-Chhinling commented on code in PR #7726:
URL: https://github.com/apache/hadoop/pull/7726#discussion_r2143456063


##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/DiagnosticJStackService.java:
##########
@@ -0,0 +1,134 @@
+/** * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.yarn.server.nodemanager;
+
+import org.apache.hadoop.util.Shell;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.*;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class DiagnosticJStackService {
+
+    private static final Logger LOG = LoggerFactory
+            .getLogger(DiagnosticJStackService.class);
+    private static final String PYTHON_COMMAND = "python3";
+    private static String scriptLocation = null;
+
+    static {
+        try {
+            // Extract script from JAR to a temp file
+            InputStream in = DiagnosticJStackService.class.getClassLoader()
+                    .getResourceAsStream("diagnostics/jstack_collector.py");
+            File tempScript = File.createTempFile("jstack_collector", ".py");
+            Files.copy(in, tempScript.toPath(), 
StandardCopyOption.REPLACE_EXISTING);
+            tempScript.setExecutable(true); // Set execute permission
+            scriptLocation = tempScript.getAbsolutePath();
+        } catch (IOException e) {
+            LOG.error("Failed to extract Python script from JAR", e);
+        }
+    }
+
+    public static String collectNodeJStack()

Review Comment:
   Sure, I am thinking of changing to `collectNodeThreadDump()`





> New JStack endpoint for running containers and nodes
> ----------------------------------------------------
>
>                 Key: YARN-11823
>                 URL: https://issues.apache.org/jira/browse/YARN-11823
>             Project: Hadoop YARN
>          Issue Type: New Feature
>          Components: yarn
>            Reporter: chhinlinghean
>            Assignee: chhinlinghean
>            Priority: Major
>              Labels: pull-request-available
>
> Getting jstack for container is not trivial to most people. This new endpoint 
> aims to streamline the process of getting jstack of running containers and 
> nodes. It mainly use in the DiagnosticCollector script.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: yarn-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: yarn-issues-h...@hadoop.apache.org

Reply via email to