horde 0.0.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +3 -0
- data/Rakefile +1 -0
- data/horde.gemspec +28 -0
- data/lib/horde.rb +5 -0
- data/lib/horde/client.rb +52 -0
- data/lib/horde/server.rb +50 -0
- data/lib/horde/test.rb +32 -0
- data/lib/horde/ventilator.rb +34 -0
- data/lib/horde/version.rb +3 -0
- metadata +100 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/horde.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "horde/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "horde"
|
7
|
+
s.version = Horde::VERSION
|
8
|
+
s.authors = ["Dan Ryan"]
|
9
|
+
s.email = ["dan@appliedawesome.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Real-time infrastructure data aggregation}
|
12
|
+
s.description = %q{}
|
13
|
+
|
14
|
+
s.rubyforge_project = "horde"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
# s.add_runtime_dependency "rest-client"
|
24
|
+
s.add_dependency "ffi-rzmq", ">= 0.9.3"
|
25
|
+
s.add_dependency "msgpack", ">= 0.4.6"
|
26
|
+
s.add_dependency "eventmachine", ">= 1.0.0.beta.4"
|
27
|
+
s.add_dependency "yajl-ruby", ">= 1.1.0"
|
28
|
+
end
|
data/lib/horde.rb
ADDED
data/lib/horde/client.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# module Horde
|
2
|
+
# class Client
|
3
|
+
#
|
4
|
+
# end
|
5
|
+
# end
|
6
|
+
#
|
7
|
+
# sender = context.socket(ZMQ::PUSH)
|
8
|
+
# sender.connect("tcp://localhost:9001")
|
9
|
+
#
|
10
|
+
# client2 = context.socket(ZMQ::PUSH)
|
11
|
+
# client2.connect("tcp://localhost:9001")
|
12
|
+
#
|
13
|
+
# while true do
|
14
|
+
# client1.send_msg("hi from client1")
|
15
|
+
# client2.send_msg("hi from client2")
|
16
|
+
# end
|
17
|
+
|
18
|
+
#
|
19
|
+
# Task worker in Ruby
|
20
|
+
# Connects PULL socket to tcp://localhost:5557
|
21
|
+
# Collects workloads from ventilator via that socket
|
22
|
+
# Connects PUSH socket to tcp://localhost:5558
|
23
|
+
# Sends results to sink via that socket
|
24
|
+
#
|
25
|
+
|
26
|
+
require 'rubygems'
|
27
|
+
require 'ffi-rzmq'
|
28
|
+
|
29
|
+
context = ZMQ::Context.new(1)
|
30
|
+
|
31
|
+
# Socket to receive messages on
|
32
|
+
receiver = context.socket(ZMQ::PULL)
|
33
|
+
receiver.connect("tcp://localhost:5557")
|
34
|
+
|
35
|
+
# Socket to send messages to
|
36
|
+
sender = context.socket(ZMQ::PUSH)
|
37
|
+
sender.connect("tcp://localhost:5558")
|
38
|
+
|
39
|
+
# Process tasks forever
|
40
|
+
while true
|
41
|
+
|
42
|
+
receiver.recv_string(msec = '')
|
43
|
+
# Simple progress indicator for the viewer
|
44
|
+
$stdout << "#{msec}."
|
45
|
+
$stdout.flush
|
46
|
+
|
47
|
+
# Do the work
|
48
|
+
sleep(msec.to_f / 1000)
|
49
|
+
|
50
|
+
# Send results to sink
|
51
|
+
sender.send_string("")
|
52
|
+
end
|
data/lib/horde/server.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# module Horde
|
2
|
+
# class Server
|
3
|
+
#
|
4
|
+
# end
|
5
|
+
# end
|
6
|
+
#
|
7
|
+
# require 'ffi-rzmq'
|
8
|
+
#
|
9
|
+
# context = ZMQ::Context.new(1)
|
10
|
+
#
|
11
|
+
# server = context.socket(ZMQ::PULL)
|
12
|
+
# server.bind("tcp://localhost:9001")
|
13
|
+
#
|
14
|
+
# tstart = Time.now
|
15
|
+
#
|
16
|
+
# 100.times do |task|
|
17
|
+
# server.recv_string(msg = '')
|
18
|
+
# $stdout << task
|
19
|
+
# $stdout << "#{msg}"
|
20
|
+
# $stdout.flush
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# tend = Time.now
|
24
|
+
#
|
25
|
+
# total_msec = (tend - tstart) * 1000
|
26
|
+
# puts "Total elapsed time: #{total_msec} msec"
|
27
|
+
|
28
|
+
require 'rubygems'
|
29
|
+
require 'ffi-rzmq'
|
30
|
+
|
31
|
+
# Prepare our context and socket
|
32
|
+
context = ZMQ::Context.new(1)
|
33
|
+
receiver = context.socket(ZMQ::PULL)
|
34
|
+
receiver.bind("tcp://10.0.1.140:5557")
|
35
|
+
|
36
|
+
# Wait for start of batch
|
37
|
+
receiver.recv_string('')
|
38
|
+
tstart = Time.now
|
39
|
+
|
40
|
+
# Process 100 confirmations
|
41
|
+
100.times do |task_nbr|
|
42
|
+
receiver.recv_string(msg = '')
|
43
|
+
$stdout << "#{msg}"
|
44
|
+
$stdout.flush
|
45
|
+
end
|
46
|
+
|
47
|
+
# Calculate and report duration of batch
|
48
|
+
tend = Time.now
|
49
|
+
total_msec = (tend-tstart) * 1000
|
50
|
+
puts "Total elapsed time: #{total_msec} msec"
|
data/lib/horde/test.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'ffi-rzmq'
|
2
|
+
|
3
|
+
context = ZMQ::Context.new(1)
|
4
|
+
|
5
|
+
server = context.socket(ZMQ::PULL)
|
6
|
+
server.bind("tcp://localhost:9001")
|
7
|
+
|
8
|
+
tstart = Time.now
|
9
|
+
|
10
|
+
100.times do |task|
|
11
|
+
server.recv_string(msg = '')
|
12
|
+
$stdout << task
|
13
|
+
$stdout << "#{msg}"
|
14
|
+
$stdout.flush
|
15
|
+
end
|
16
|
+
|
17
|
+
tend = Time.now
|
18
|
+
|
19
|
+
total_msec = (tend - tstart) * 1000
|
20
|
+
puts "Total elapsed time: #{total_msec} msec"
|
21
|
+
|
22
|
+
|
23
|
+
sender = context.socket(ZMQ::PUSH)
|
24
|
+
sender.connect("tcp://localhost:9001")
|
25
|
+
|
26
|
+
client2 = context.socket(ZMQ::PUSH)
|
27
|
+
client2.connect("tcp://localhost:9001")
|
28
|
+
|
29
|
+
while true do
|
30
|
+
client1.send_msg("hi from client1")
|
31
|
+
client2.send_msg("hi from client2")
|
32
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#
|
2
|
+
# Task ventilator in Ruby
|
3
|
+
# Binds PUSH socket to tcp://localhost:5557
|
4
|
+
# Sends batch of tasks to workers via that socket
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'rubygems'
|
8
|
+
require 'ffi-rzmq'
|
9
|
+
|
10
|
+
context = ZMQ::Context.new(1)
|
11
|
+
|
12
|
+
# Socket to send messages on
|
13
|
+
sender = context.socket(ZMQ::PUSH)
|
14
|
+
sender.connect("tcp://10.0.1.140:5557")
|
15
|
+
|
16
|
+
puts "Press enter when the workers are ready..."
|
17
|
+
$stdin.read(1)
|
18
|
+
puts "Sending tasks to workers..."
|
19
|
+
|
20
|
+
# The first message is "0" and signals start of batch
|
21
|
+
sender.send_string('0')
|
22
|
+
|
23
|
+
# Send 100 tasks
|
24
|
+
total_msec = 0 # Total expected cost in msecs
|
25
|
+
10.times do
|
26
|
+
workload = %x[ ohai ]
|
27
|
+
total_msec = rand(100) + 1
|
28
|
+
$stdout << "#{workload}."
|
29
|
+
sender.send_string(workload.to_s)
|
30
|
+
sleep 1
|
31
|
+
end
|
32
|
+
|
33
|
+
puts "Total expected cost: #{total_msec} msec"
|
34
|
+
Kernel.sleep(1) # Give 0MQ time to deliver
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: horde
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.pre
|
5
|
+
prerelease: 6
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dan Ryan
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-15 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: ffi-rzmq
|
16
|
+
requirement: &70150749657080 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.9.3
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70150749657080
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: msgpack
|
27
|
+
requirement: &70150749656320 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.4.6
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70150749656320
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: eventmachine
|
38
|
+
requirement: &70150749655580 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.0.0.beta.4
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70150749655580
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: yajl-ruby
|
49
|
+
requirement: &70150749654700 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.1.0
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70150749654700
|
58
|
+
description: ''
|
59
|
+
email:
|
60
|
+
- dan@appliedawesome.com
|
61
|
+
executables: []
|
62
|
+
extensions: []
|
63
|
+
extra_rdoc_files: []
|
64
|
+
files:
|
65
|
+
- .gitignore
|
66
|
+
- Gemfile
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- horde.gemspec
|
70
|
+
- lib/horde.rb
|
71
|
+
- lib/horde/client.rb
|
72
|
+
- lib/horde/server.rb
|
73
|
+
- lib/horde/test.rb
|
74
|
+
- lib/horde/ventilator.rb
|
75
|
+
- lib/horde/version.rb
|
76
|
+
homepage: ''
|
77
|
+
licenses: []
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>'
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.3.1
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project: horde
|
96
|
+
rubygems_version: 1.8.15
|
97
|
+
signing_key:
|
98
|
+
specification_version: 3
|
99
|
+
summary: Real-time infrastructure data aggregation
|
100
|
+
test_files: []
|