Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added monitoring for sevaks

  • Loading branch information...
commit afbce7e578e1a7afe175088c38d6dcbdbc8f4a58 1 parent 18737c8
Amit Rathore authored
3  .gitmodules
View
@@ -0,0 +1,3 @@
+[submodule "lib/clojure/clj-record"]
+ path = lib/clojure/clj-record
+ url = git://github.com/duelinmarkers/clj-record.git
11 db/init.sql
View
@@ -0,0 +1,11 @@
+drop database if exists swarmiji_development;
+drop database if exists swarmiji_test;
+drop database if exists swarmiji_staging;
+drop database if exists swarmiji_sandbox;
+drop database if exists swarmiji_production;
+
+create database swarmiji_development;
+create database swarmiji_test;
+create database swarmiji_staging;
+create database swarmiji_sandbox;
+create database swarmiji_production;
33 db/schema.rb
View
@@ -0,0 +1,33 @@
+#!/usr/bin/env ruby
+
+require "rubygems"
+require "activerecord"
+
+def usage
+ puts "Swarmiji DB creator."
+ puts "Usage: schema.rb db-host[localhost|remote.runa.com|etc] db-environment [development|test|production|staging|etc.]"
+end
+
+puts "ARGV.length: #{ARGV.length} ARGV: #{ARGV.inspect}"
+
+if ARGV.length != 2
+ usage
+ exit -1
+end
+
+ActiveRecord::Base.establish_connection(
+ :adapter => "mysql",
+ :host => ARGV[0],
+ :database => "swarmiji_#{ARGV[1]}",
+ :username => "root",
+ :password => "password"
+)
+
+ActiveRecord::Base.connection.instance_eval do
+ create_table "control_messages", :force => true do |t|
+ t.string "sevak_server_pid", "message_type", "sevak_name", "sevak_args", "sevak_time", "messaging_time", "return_q_name"
+ t.timestamps
+ end
+end
+
+puts "Created swarmiji_#{ARGV[1]} schema on #{ARGV[0]}."
47 fujure.sh
View
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+# Please make sure to configure ~/.clojure.conf or /etc/clojure.conf
+# sample configuration can be found at clojure.conf.sample
+#
+# Note, running this script will:
+# - Run ~/.clojurerc on boot up (if exists)
+# - Add all .jar files within clj_ext (~/.clojure on default)
+# to the classpath
+#
+#
+
+if [ ! -f /etc/clojure.conf -a ! -f /mnt/furtive/clojure.conf -a ! -f ~/.clojure.conf ]; then
+ echo "Error: No config not found at /etc/clojure.conf or ~/.clojure.conf."
+ echo " Please provide one before starting this script."
+ echo " A sample can be found in the emacs-clojure repository named "
+ echo " clojure.conf.sample"
+ exit
+fi
+
+
+# Whether to load the repl or script
+if [ -z "$1" ]; then
+ clj_class=clojure.lang.Repl
+else
+ clj_class=clojure.lang.Script
+fi
+
+echo "SWARMIJI_HOME is ${SWARMIJI_HOME}"
+echo "SWARMIJI_ENV is ${SWARMIJI_ENV}"
+
+swarmiji_jars="${SWARMIJI_HOME}/lib/java"
+swarmiji_clj="${SWARMIJI_HOME}/src/:${SWARMIJI_HOME}/lib/clojure/clj-record/src/"
+
+clj_cp="."
+[ -f /etc/clojure.conf ] && . /etc/clojure.conf
+[ -f /mnt/furtive/clojure.conf ] && . /mnt/furtive/clojure.conf
+[ -f ~/.clojure.conf ] && . ~/.clojure.conf
+[ -f ~/.clojurerc ] && clj_rc=~/.clojurerc
+clj_cp="${clj_cp}:${swarmiji_jars}/*:${swarmiji_clj}/:${clj_ext}/*"
+
+if [ -n "${clj_lib}" ]; then
+ export LD_LIBRARY_PATH=${clj_lib}:$LD_LIBRARY_PATH
+fi
+
+echo exec java -Xms256m -Xmx512m -server -Dpid=$$ ${clj_opts} -cp ${clj_cp}:${clj} ${clj_wrapper} ${clj_class} ${clj_rc} $*
+exec java -Xms256m -Xmx512m -server -Dpid=$$ ${clj_opts} -cp ${clj_cp}:${clj} ${clj_wrapper} ${clj_class} ${clj_rc} $1 -- $*
1  lib/clojure/clj-record
@@ -0,0 +1 @@
+Subproject commit c8d124847eb11f0b69b13eb1873dcfef3931ebd6
BIN  lib/java/mysql-connector-java-5.1.7-bin.jar
View
Binary file not shown
6 src/org/runa/swarmiji/monitor/control_message.clj
View
@@ -0,0 +1,6 @@
+(ns org.runa.swarmiji.monitor.control_message
+ (:require clj-record.boot)
+ (:use [org.runa.swarmiji.config.system-config]))
+
+(def db (swarmiji-mysql-config))
+(clj-record.core/init-model)
24 src/org/runa/swarmiji/monitor/recorder.clj
View
@@ -0,0 +1,24 @@
+(ns org.runa.swarmiji.monitor.recorder
+ (:use [org.runa.swarmiji.mpi.transport])
+ (:use [org.runa.swarmiji.config.system-config])
+ (:use [org.runa.swarmiji.utils.logger])
+ (:use [org.runa.swarmiji.monitor.control_message :as control-message])
+ (:import (java.sql Date Time)))
+
+(defn timestamp-for-sql [time-in-millis]
+ (str (.toString (Date. time-in-millis)) " " (.toString (Time. time-in-millis))))
+
+(defn persist-message [control-message]
+ (log-message "control-message:" control-message)
+ (let [now (timestamp-for-sql (System/currentTimeMillis))
+ with-timestamps (merge {:created_at now :updated_at now} control-message)]
+ (control-message/insert with-timestamps)))
+
+(defn start []
+ (let [client (new-queue-client)
+ q-name (queue-diagnostics-q-name)
+ handler (queue-message-handler-for-function persist-message)]
+ (log-message "Swarmiji: Starting Control-Message-Recorder...")
+ (log-message "Listening on:" q-name)
+ (.subscribe client q-name handler)))
+
3  utils/start_recorder.clj
View
@@ -0,0 +1,3 @@
+(use 'org.runa.swarmiji.monitor.recorder)
+
+(start)
Please sign in to comment.
Something went wrong with that request. Please try again.