Github user revans2 commented on a diff in the pull request:

    https://github.com/apache/storm/pull/2752#discussion_r200437014
  
    --- Diff: storm-core/src/jvm/org/apache/storm/ui/UIHelpers.java ---
    @@ -295,9 +391,1104 @@ public static String getJsonResponseBody(Object 
data, String callback, boolean n
             return callback != null ? wrapJsonInCallback(callback, 
serializedData) : serializedData;
         }
     
    +    /**
    +     * Converts exception into json map.
    +     * @param ex Exception to be converted.
    +     * @param statusCode Status code to be returned.
    +     * @return Map to be converted into json.
    +     */
         public static Map exceptionToJson(Exception ex, int statusCode) {
             StringWriter sw = new StringWriter();
             ex.printStackTrace(new PrintWriter(sw));
    -        return ImmutableMap.of("error", statusCode + " " + 
HttpStatus.getMessage(statusCode), "errorMessage", sw.toString());
    +        return ImmutableMap.of(
    +                "error", statusCode
    +                        + " "
    +                        + HttpStatus.getMessage(statusCode),
    +                "errorMessage", sw.toString());
    +    }
    +
    +    /**
    +     * Converts thrift call result into map fit for UI/api.
    +     * @param clusterSummary Obtained from Nimbus.
    +     * @param user User Making request
    +     * @param conf Storm Conf
    +     * @return Cluster Summary for display on UI/monitoring purposes via 
API
    +     */
    +    public static Map<String, Object> getClusterSummary(ClusterSummary 
clusterSummary, String user,
    +                                                        Map<String, 
Object> conf) {
    +        Map<String, Object> result = new HashMap();
    +        List<SupervisorSummary> supervisorSummaries = 
clusterSummary.get_supervisors();
    +        List<TopologySummary> topologySummaries = 
clusterSummary.get_topologies();
    +
    +        Integer usedSlots =
    +                supervisorSummaries.stream().mapToInt(
    +                SupervisorSummary::get_num_used_workers).sum();
    +        Integer totalSlots =
    +                supervisorSummaries.stream().mapToInt(
    +                        SupervisorSummary::get_num_workers).sum();
    +
    +        Integer totalTasks =
    +                topologySummaries.stream().mapToInt(
    +                        TopologySummary::get_num_tasks).sum();
    +        Integer totalExecutors =
    +                topologySummaries.stream().mapToInt(
    +                        TopologySummary::get_num_executors).sum();
    +
    +        Double supervisorTotalMemory =
    --- End diff --
    
    nit: same for `double` vs `Double` here.


---

Reply via email to