apex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davidyan74 <...@git.apache.org>
Subject [GitHub] incubator-apex-core pull request: APEXCORE-330 : Stacktrace of the...
Date Mon, 02 May 2016 23:52:12 GMT
Github user davidyan74 commented on a diff in the pull request:

    https://github.com/apache/incubator-apex-core/pull/321#discussion_r61823831
  
    --- Diff: engine/src/main/java/com/datatorrent/stram/StramUtils.java ---
    @@ -81,4 +89,48 @@
         }
       }
     
    +  public static JSONObject getJsonFormat()
    +  {
    +    Map<Thread, StackTraceElement[]> stackTraces = Thread.getAllStackTraces();
    +
    +    JSONObject jsonObject = new JSONObject();
    +    JSONArray jsonArray = new JSONArray();
    +
    +    for (Map.Entry<Thread,StackTraceElement[]> elements : stackTraces.entrySet())
{
    +
    +      JSONObject jsonThreads = new JSONObject();
    +
    +      Thread thread = elements.getKey();
    +
    +      try {
    +
    +        jsonThreads.put("name", thread.getName());
    +        jsonThreads.put("state", thread.getState());
    +        jsonThreads.put("id", thread.getId());
    +
    +        JSONArray stacks = new JSONArray();
    +
    +        for ( StackTraceElement stackTraceElement: elements.getValue()) {
    +
    +          stacks.put(stackTraceElement.toString());
    +        }
    +
    +        jsonThreads.put("stackTraceElement", stacks);
    +
    +        jsonArray.put(jsonThreads);
    +      } catch (Exception ex) {
    +        LOG.warn("Getting stack trace for the thread " + thread.getName() + " failed.");
    +        continue;
    +      }
    +    }
    +
    +    try {
    +      jsonObject.put("threads", jsonArray);
    +    } catch (JSONException e) {
    +      throw new RuntimeException(e.toString());
    --- End diff --
    
    new RuntimeException(e)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message