You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by ka...@apache.org on 2014/01/28 23:51:03 UTC

git commit: Create and join the cluster directly from the config

Updated Branches:
  refs/heads/helix-monitoring b1df294ba -> a99284237


Create and join the cluster directly from the config


Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/a9928423
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/a9928423
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/a9928423

Branch: refs/heads/helix-monitoring
Commit: a99284237eb69104a967d7ffa90ef205e51953b6
Parents: b1df294
Author: Kanak Biscuitwala <ka...@apache.org>
Authored: Tue Jan 28 14:50:34 2014 -0800
Committer: Kanak Biscuitwala <ka...@apache.org>
Committed: Tue Jan 28 14:50:34 2014 -0800

----------------------------------------------------------------------
 helix-monitor-server/pom.xml                    |  5 +++
 .../src/main/resources/riemann.config           | 39 ++++++++++++++++++++
 2 files changed, 44 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/a9928423/helix-monitor-server/pom.xml
----------------------------------------------------------------------
diff --git a/helix-monitor-server/pom.xml b/helix-monitor-server/pom.xml
index d6fdf52..041a390 100644
--- a/helix-monitor-server/pom.xml
+++ b/helix-monitor-server/pom.xml
@@ -54,6 +54,11 @@ under the License.
       <version>0.2.4</version>
     </dependency>
     <dependency>
+      <groupId>factual</groupId>
+      <artifactId>clj-helix</artifactId>
+      <version>0.1.0</version>
+    </dependency>
+    <dependency>
       <groupId>org.testng</groupId>
       <artifactId>testng</artifactId>
       <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/helix/blob/a9928423/helix-monitor-server/src/main/resources/riemann.config
----------------------------------------------------------------------
diff --git a/helix-monitor-server/src/main/resources/riemann.config b/helix-monitor-server/src/main/resources/riemann.config
index 0f06dd0..bdb785e 100644
--- a/helix-monitor-server/src/main/resources/riemann.config
+++ b/helix-monitor-server/src/main/resources/riemann.config
@@ -27,6 +27,45 @@
 (udp-server :host "0.0.0.0")
 (ws-server :host "0.0.0.0")
 (repl-server :host "0.0.0.0")
+(use 'clj-helix.admin)
+
+(def admin (helix-admin "localhost:2185"))
+
+(add-cluster admin :my-app)
+
+(def fsm-def
+ (clj-helix.fsm/fsm-definition
+  {:name :OnlineOffline
+   :states
+    {:DROPPED {:transitions :OFFLINE}
+     :ONLINE {:priority 1 :upper-bound :R :transitions :OFFLINE}
+     :OFFLINE {:initial? true :transitions [:ONLINE :DROPPED]}}}))
+
+(add-fsm-definition admin :my-app fsm-def)
+
+(add-resource admin :my-app {:resource   :some-resouce
+                             :partitions 128
+                             :replicas   5
+                             :state-model (:name fsm-def)})
+
+(add-instance admin :my-app {:host "localhost"
+                                         :port 5555})
+(use 'clj-helix.manager)
+
+(def f (clj-helix.fsm/fsm fsm-def
+     (:OFFLINE :ONLINE [part message context]
+       (prn part :coming-online))
+
+     (:OFFLINE :DROPPED [part m c]
+       (prn part "dropped!"))
+
+     (:ONLINE :OFFLINE [part m c]
+       (prn part "Going offline."))))
+
+(def p (participant {:zookeeper "localhost:2185"
+                     :cluster   :my-app
+                     :instance {:host "localhost" :port 5555}
+                     :fsm       f}))
 
 (periodically-expire 1)