Skip to content

Commit

Permalink
Merge pull request #211 from banjiewen/master
Browse files Browse the repository at this point in the history
Add some type hints
  • Loading branch information
aphyr committed Apr 30, 2013
2 parents 0f97795 + ae6b8df commit 4709546
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/riemann/common.clj
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
events)))

(defn count-string-bytes [s]
(count (.getBytes s "UTF8")))
(count (.getBytes ^String s "UTF8")))

(defn count-character-bytes [c]
(count-string-bytes (.toString c)))
Expand Down
10 changes: 5 additions & 5 deletions src/riemann/graphite.clj
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
:out (OutputStreamWriter. (.getOutputStream sock)))))
(send-line [this line]
(let [out (:out this)]
(.write ^OutputStreamWriter out line)
(.write ^OutputStreamWriter out ^String line)
(.flush ^OutputStreamWriter out)))
(close [this]
(.close (:out this))
(.close (:socket this))))
(.close ^OutputStreamWriter (:out this))
(.close ^Socket (:socket this))))

(defrecord GraphiteUDPClient [host port]
GraphiteClient
Expand All @@ -50,13 +50,13 @@
:host host
:port port))
(send-line [this line]
(let [bytes (.getBytes line)
(let [bytes (.getBytes ^String line)
length (count line)
addr (InetAddress/getByName (:host this))
datagram (DatagramPacket. bytes length addr (:port this))]
(.send ^DatagramSocket (:socket this) datagram)))
(close [this]
(.close (:socket this))))
(.close ^DatagramSocket (:socket this))))

(defn graphite-path-basic
"Constructs a path for an event. Takes the hostname fqdn, reversed,
Expand Down
6 changes: 3 additions & 3 deletions src/riemann/pool.clj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
(grow [this]
(loop []
(if-let [thingy (try (open) (catch Throwable t nil))]
(.put queue thingy)
(.put ^LinkedBlockingQueue queue thingy)
(do
(Thread/sleep (* 1000 regenerate-interval))
(recur)))))
Expand All @@ -34,7 +34,7 @@
(let [timeout (* 1000 (or timeout 0))]
(or
(try
(.poll queue timeout TimeUnit/MILLISECONDS)
(.poll ^LinkedBlockingQueue queue timeout TimeUnit/MILLISECONDS)
(catch java.lang.InterruptedException e
nil))
(throw+
Expand All @@ -44,7 +44,7 @@

(release [this thingy]
(when thingy
(.put queue thingy)))
(.put ^LinkedBlockingQueue queue thingy)))

(invalidate [this thingy]
(when thingy
Expand Down

0 comments on commit 4709546

Please sign in to comment.