 (defn component-link [storm-id id]
   (link-to (url-format "/topology/%s/component/%s" storm-id id) id))
 
+(defn render-capacity [capacity]
+  [:span (if (> capacity 0.9)
+               {:class "red"}
+               {})
+         (float-str capacity)])
+
+(defn compute-executor-capacity [^ExecutorSummary e]
+  (let [stats (.get_stats e)
+        stats (if stats
+                (-> stats
+                    (aggregate-bolt-stats true)
+                    (aggregate-bolt-streams)
+                    swap-map-order
+                    (get "600")))
+        uptime (nil-to-zero (.get_uptime_secs e))
+        window (if (< uptime 600) uptime 600)
+        executed (-> stats :executed nil-to-zero)
+        latency (-> stats :execute-latencies nil-to-zero)
+        ]
+   (if (> window 0)
+     (div (* executed latency) (* 1000 window))
+     )))
+
+(defn compute-bolt-capacity [executors]
+  (->> executors
+       (map compute-executor-capacity)
+       (apply max)))
+
 (defn spout-comp-table [top-id summ-map errors window include-sys?]
   (sorted-table
    ["Id" "Executors" "Tasks" "Emitted" "Transferred" "Complete latency (ms)"

      (sum-tasks summs)
      (get-in stats [:emitted window])
      (get-in stats [:transferred window])
      (float-str (get-in stats [:execute-latencies window]))
      (get-in stats [:executed window])
      (float-str (get-in stats [:process-latencies window]))


(defn bolt-comp-table [top-id summ-map errors window include-sys?]
  (sorted-table
   ["Id" "Executors" "Tasks" "Emitted" "Transferred" "Capacity (last 10m)" "Execute latency (ms)" "Executed" "Process latency (ms)"
    "Acked" "Failed" "Last error"]
   (for [[id summs] summ-map
         :let [stats-seq (get-filled-stats summs)
