Skip to content

Instantly share code, notes, and snippets.

@aengelberg
Created October 4, 2016 00:52
Show Gist options
  • Save aengelberg/5f73ca3352f2419e7f0baad060e4db6f to your computer and use it in GitHub Desktop.
Save aengelberg/5f73ca3352f2419e7f0baad060e4db6f to your computer and use it in GitHub Desktop.
Riemann issues
(ns onyx.metrics.riemann-playground)
(require '[riemann.client :as r])
(def c (r/tcp-client {:host "192.168.99.100" :port 35002}))
(defn intensive-computation []
(let [prom (r/send-events c (repeat 100000 {:status "ok"}))]
(println "Obtained promise")
(println (time (deref prom)))))
(def f (future
(try
(while (not (Thread/interrupted))
(println (Thread/interrupted))
(println "ready to go")
(intensive-computation))
(catch Exception e (println e))
(finally (println "finally")))))
(Thread/sleep 10000)
(future-cancel f)
;; =>
false
ready to go
Obtained promise
"Elapsed time: 5327.321034 msecs"
#riemann.codec.Msg{:ok true, :error nil, :events [], :query nil, :decode-time 360401242217448}
false
ready to go
Obtained promise
#error {
:cause
nil
:via
[{:type java.lang.NullPointerException
:message nil
:at [com.aphyr.riemann.client.MsgValidator call MsgValidator.java 10]}]
:trace
[[com.aphyr.riemann.client.MsgValidator call MsgValidator.java 10]
[com.aphyr.riemann.client.MsgValidator call MsgValidator.java 8]
[com.aphyr.riemann.client.MapPromise mapCapturingExceptions MapPromise.java 26]
[com.aphyr.riemann.client.MapPromise deref MapPromise.java 42]
[com.aphyr.riemann.client.MapPromise deref MapPromise.java 42]
[clojure.core$deref invoke core.clj 2206]
[onyx.metrics.riemann_playground$intensive_computation invoke riemann_playground.clj 10]
[onyx.metrics.riemann_playground$fn__21309 invoke riemann_playground.clj 17]
[clojure.core$binding_conveyor_fn$fn__4444 invoke core.clj 1916]
[clojure.lang.AFn call AFn.java 18]
[java.util.concurrent.FutureTask run FutureTask.java 266]
[java.util.concurrent.ThreadPoolExecutor runWorker ThreadPoolExecutor.java 1142]
[java.util.concurrent.ThreadPoolExecutor$Worker run ThreadPoolExecutor.java
617]
[java.lang.Thread run Thread.java 745]]}
finally
;; If I change `(deref prom)` to `(deref prom 5000 ::timeout)`:
;; =>
false
ready to go
Obtained promise
"Elapsed time: 5006.735547 msecs"
:onyx.metrics.riemann-playground/timeout
false
ready to go
Obtained promise
"Elapsed time: 2612.650749 msecs"
:onyx.metrics.riemann-playground/timeout
false
ready to go
Obtained promise
"Elapsed time: 5003.882697 msecs"
:onyx.metrics.riemann-playground/timeout
false
ready to go
Obtained promise
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment