PageRenderTime 394ms CodeModel.GetById 191ms app.highlight 9ms RepoModel.GetById 193ms app.codeStats 0ms

/src/clj/backtype/storm/crate/zeromq.clj

http://github.com/nathanmarz/storm-deploy
Clojure | 90 lines | 70 code | 13 blank | 7 comment | 1 complexity | fbfdf3484d85e2f6411b0ddbf6486cb0 MD5 | raw file
 1(ns backtype.storm.crate.zeromq
 2  (:require
 3   [pallet.action.exec-script :as exec-script]
 4   [pallet.resource.package :as package]
 5   [pallet.resource.remote-directory :as remote-directory]
 6   [pallet.resource.directory :as directory]
 7   [pallet.crate.maven :as maven]
 8   [pallet.crate.git :as git]
 9   [pallet.parameter :as parameter]
10   [pallet.crate.iptables :as iptables]
11   ))
12
13(def src-path "/opt/local/zeromq")
14(def md5s {})
15
16(defn download-url
17  "The url for downloading zeromq"
18  [version]
19  (format
20   "http://download.zeromq.org/zeromq-%s.tar.gz"
21   version))
22
23(defn install
24  "Install zeromq from source."
25  [request & {:keys [version] :or {version "2.0.10"}}]
26  (->
27   request
28   (package/packages
29    :yum ["gcc" "gcc-c++" "glib" "glibc-common" "libuuid-devel"]
30    :aptitude ["build-essential" "uuid-dev"])
31   (remote-directory/remote-directory
32    src-path
33    :url (download-url version) :md5 (md5s version) :unpack :tar)
34   (exec-script/exec-checked-script
35    "Build zeromq"
36    (cd ~src-path)
37    ("./configure")
38    (make)
39    (make install)
40    ("/sbin/ldconfig"))
41   ;;(parameter/assoc-for-target [:zeromq :version] version)
42   ))
43
44(defn install-jzmq
45  "Install jzmq from source. You must install zeromq first."
46  [request & {:keys [version]}]
47  (->
48   request
49   (maven/package)
50   (git/git)
51   (package/packages
52    :yum ["libtool" "pkg-config" "autoconf"]
53    :aptitude ["libtool" "pkg-config" "autoconf"])
54
55   (exec-script/exec-checked-script
56    "Build jzmq"
57
58    (var tmpdir (~directory/make-temp-dir "rf"))
59    (cd (quoted @tmpdir))
60    ;; use frozen version of jzmq
61    (git clone "git://github.com/nathanmarz/jzmq.git")
62
63    (cd "jzmq")
64
65    (export (str "JAVA_HOME="
66                 @(dirname @(dirname @(dirname @(update-alternatives "--list" java))))))
67
68    ("touch src/classdist_noinst.stamp")
69    (cd "src")
70    ("CLASSPATH=.:./.:$CLASSPATH javac -d . org/zeromq/ZMQ.java org/zeromq/App.java org/zeromq/ZMQForwarder.java org/zeromq/EmbeddedLibraryTools.java org/zeromq/ZMQQueue.java org/zeromq/ZMQStreamer.java org/zeromq/ZMQException.java")
71    (cd "..")
72    
73    ("./autogen.sh")
74    ("./configure")
75    (make)
76
77    (make install)
78;;    (mvn ~(print-str "install:install-file -Dfile=/usr/local/share/java/zmq.jar"
79;;                     "-DgroupId=org.zeromq"
80;;                     "-DartifactId=zmq"
81;;                     (format "-Dversion=%s" version)
82;;                     "-Dpackaging=jar"))
83                     )))
84
85(defn iptables-accept
86  "Accept zeromq connections, by default on port 5672"
87  ([request] (iptables-accept request 5672))
88  ([request port]
89     (iptables/iptables-accept-port request port)))
90