Permalink
Browse files

add stats for wal

  • Loading branch information...
1 parent f174dff commit bd1484dea20cd9a3ab53355351a26d5c4adbd9be @sunng87 committed Sep 21, 2011
Showing with 13 additions and 3 deletions.
  1. +1 −1 scripts/put.clj
  2. +9 −2 src/clojalk/jmx.clj
  3. +3 −0 src/clojalk/wal.clj
View
@@ -15,7 +15,7 @@
(def job-body "<UserRequest><email>sunng@about.me</email><name>Sun Ning</name></UserRequest>")
(defn byte-length [s]
- (alength (.getBytes s "utf8")))
+ (alength ^bytes (.getBytes ^String s "utf8")))
(time (let [args (rest *command-line-args*)
tube-name (first args)
View
@@ -1,6 +1,6 @@
(ns clojalk.jmx
(:refer-clojure :exclude [use peek])
- (:use [clojalk data utils])
+ (:use [clojalk data utils wal])
(:require [clojure.contrib.jmx :as jmx])
(:import [clojure.contrib.jmx Bean]))
@@ -35,8 +35,15 @@
(ref
{:tubes (fn [] (into-string-array (map #(name (:name @%)) (vals @tubes))))
})))
+
+(def jmx-wal-bean
+ (new-mbean
+ (ref
+ {:total-files #(count @log-files)
+ :total-file-size (fn [] @log-total-size)})))
(defn start-jmx-server []
(jmx/register-mbean jmx-session-bean "clojalk.management:type=Sessions")
(jmx/register-mbean jmx-job-bean "clojalk.management:type=Jobs")
- (jmx/register-mbean jmx-tube-bean "clojalk.management:type=Tubes"))
+ (jmx/register-mbean jmx-tube-bean "clojalk.management:type=Tubes")
+ (jmx/register-mbean jmx-wal-bean "clojalk.management:type=Wal"))
View
@@ -225,6 +225,8 @@
;; log file streams
(def log-files (ref []))
+;; A statistical field for total bytes written to file system
+(def log-total-size (atom (long 0)))
;; Create empty log files into `log-files`. This is invoked after legacy logs replayed.
(defn init-log-files []
@@ -263,6 +265,7 @@
log-file-index (mod id log-files-count)
log-stream (nth @log-files log-file-index)
job-bytes (.array ^java.nio.ByteBuffer (job-to-bin j full?))]
+ (swap! log-total-size + (alength ^bytes job-bytes))
(send log-stream stream-write job-bytes))))
;; Write all jobs into log streams as full record

0 comments on commit bd1484d

Please sign in to comment.