Skip to content

Commit

Permalink
added some stats functions
Browse files Browse the repository at this point in the history
  • Loading branch information
amitrathore committed Mar 22, 2011
1 parent f799a79 commit 98eb79c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/org/rathore/amit/medusa/core.clj
Expand Up @@ -73,8 +73,14 @@
(defn current-pool-size [] (defn current-pool-size []
(.getPoolSize THREADPOOL)) (.getPoolSize THREADPOOL))


(defn max-pool-size []
(.getMaximumPoolSize THREADPOOL))

(defn completed-task-count [] (defn completed-task-count []
(.getCompletedTaskCount THREADPOOL)) (.getCompletedTaskCount THREADPOOL))


(defn futures-count [] (defn futures-count []
(count @running-futures)) (count @running-futures))

(defn medusa-stats []
{:queued (number-of-queued-tasks) :current-threads (current-pool-size) :max-threads (max-pool-size) :completed (completed-task-count)})
7 changes: 7 additions & 0 deletions src/org/rathore/amit/medusa/utils.clj
Expand Up @@ -2,3 +2,10 @@


(defn random-uuid [] (defn random-uuid []
(str (java.util.UUID/randomUUID))) (str (java.util.UUID/randomUUID)))

(defn threadpool-factory [thread-name-prefix]
(proxy [java.util.concurrent.ThreadFactory] []
(newThread [r]
(let [t (Thread. r)]
(.setName t (str thread-name-prefix (random-uuid)))
t))))

0 comments on commit 98eb79c

Please sign in to comment.