Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added monitoring for sevaks

  • Loading branch information...
commit 540fce9126e25525535d8f82ebad2e1897609a2c 1 parent afbce7e
@amitrathore authored
View
1  .gitignore
@@ -4,3 +4,4 @@
.project
config/config.clj
scripts/furtive
+logs/*
View
23 src/org/runa/swarmiji/client/client_core.clj
@@ -8,6 +8,8 @@
(require '(org.danlarkin [json :as json]))
(import '(java.io StringWriter))
+(def WORK-REPORT "WORK_REPORT")
+
(declare send-work-report)
(def swarmiji-sevak-init-value :__swarmiji-sevak-init__)
@@ -28,6 +30,9 @@
(defn return-q [sevak-data]
(attribute-from-response sevak-data :return-q-name))
+(defn sevak-server-pid [sevak-data]
+ (attribute-from-response sevak-data :sevak-server-pid))
+
(defn sevak-name-from [sevak-data]
(attribute-from-response sevak-data :sevak-name))
@@ -44,7 +49,8 @@
(if (complete?)
(do
(dosync (ref-set total-sevak-time (- (System/currentTimeMillis) @sevak-start)))
- (if (swarmiji-diagnostics-mode?) (send-work-report (sevak-name) args (sevak-time) (messaging-time) (return-q @sevak-data))))))
+ (if (swarmiji-diagnostics-mode?)
+ (send-work-report (sevak-name) args (sevak-time) (messaging-time) (return-q @sevak-data) (sevak-server-pid @sevak-data))))))
on-swarm-proxy-client (new-proxy (name sevak-service) args on-swarm-response)]
(fn [accessor]
(cond
@@ -95,12 +101,13 @@
(@response-with-time :response))
:default (throw (Exception. (str "On-local proxy error - unknown message:" accessor)))))))
-(defn send-work-report [sevak-name args sevak-time messaging-time return-q]
- (let [report {:sevak-name sevak-name
- :sevak-args args
- :sevak-time sevak-time
- :messaging-time messaging-time
- :return-q-name return-q
- :sevak-server-pid (process-pid)}]
+(defn send-work-report [sevak-name args sevak-time messaging-time return-q sevak-server-pid]
+ (let [report {:message_type WORK-REPORT
+ :sevak_name sevak-name
+ :sevak_args (str args)
+ :sevak_time sevak-time
+ :messaging_time messaging-time
+ :return_q_name return-q
+ :sevak_server_pid sevak-server-pid}]
(log-message "Work report for diagnostics:" report)
(send-on-transport (queue-diagnostics-q-name) report)))
View
35 src/org/runa/swarmiji/config/system_config.clj
@@ -48,11 +48,42 @@
}
)
-(defn operation-config []
+(def swarmiji-mysql-configs {
+ "development" {
+ :classname "com.mysql.jdbc.Driver"
+ :subprotocol "mysql"
+ :user "root"
+ :password "password"
+ :subname (str "//localhost/swarmiji_development")
+ }
+ "test" {
+ :classname "com.mysql.jdbc.Driver"
+ :subprotocol "mysql"
+ :user "root"
+ :password "password"
+ :subname (str "//localhost/swarmiji_development")
+ }
+ "staging" {
+ :classname "com.mysql.jdbc.Driver"
+ :subprotocol "mysql"
+ :user "root"
+ :password "password"
+ :subname (str "//localhost/swarmiji_development")
+ }
+ }
+)
+
+(defn environment-specific-config-from [configs]
(if *swarmiji-env*
- (operation-configs *swarmiji-env*)
+ (configs *swarmiji-env*)
(throw (Exception. "SWARMIJI_ENV is not set"))))
+(defn operation-config []
+ (environment-specific-config-from operation-configs))
+
+(defn swarmiji-mysql-config []
+ (environment-specific-config-from swarmiji-mysql-configs))
+
(def logfile (str ((operation-config) :logsdir) "/" *swarmiji-env* "_" (random-number-string) ".log"))
(defn swarmiji-user []
View
13 src/org/runa/swarmiji/mpi/transport.clj
@@ -3,6 +3,8 @@
(use 'org.runa.swarmiji.config.system-config)
(require '(org.danlarkin [json :as json]))
(import '(net.ser1.stomp Client Listener))
+(use 'org.runa.swarmiji.utils.exception-utils)
+(use 'org.runa.swarmiji.utils.logger)
(defn new-queue-client []
(Client. (queue-host) (queue-port), (queue-username) (queue-password)))
@@ -11,4 +13,13 @@
(let [client (new-queue-client)
q-message-string (json/encode-to-str q-message-object)]
(.send client q-name q-message-string)
- client))
+ client))
+
+(defn queue-message-handler-for-function [the-function]
+ (proxy [Listener] []
+ (message [header-map message-body]
+ (try
+ (the-function (json/decode-from-str message-body))
+ (catch Exception e
+ (log-exception e))))))
+
View
2  src/org/runa/swarmiji/sevak/sevak_core.clj
@@ -45,7 +45,7 @@
(defn async-sevak-handler [service-handler sevak-name service-args return-q]
(let [response (merge
- {:return-q-name return-q :sevak-name sevak-name}
+ {:return-q-name return-q :sevak-name sevak-name :sevak-server-pid (process-pid)}
(handle-sevak-request service-handler service-args))]
(send-on-transport return-q response)))
View
2  src/org/runa/swarmiji/utils/general_utils.clj
@@ -28,4 +28,4 @@
`(let [start-time# (System/currentTimeMillis)
response# ~expr
end-time# (System/currentTimeMillis)]
- {:time-taken (- end-time# start-time#) :response response# :start-time start-time# :end-time end-time#}))
+ {:time-taken (- end-time# start-time#) :response response# :start-time start-time# :end-time end-time#}))
Please sign in to comment.
Something went wrong with that request. Please try again.