Permalink
Browse files

health manager uses cf-message-bus gem [#49434789]

  • Loading branch information...
1 parent 0cb20d2 commit 9058a98dd63d0c0f0df7c80c3bf0ae71e302a89f Alan Moran and Gregg Van Hove committed Jul 17, 2013
View
@@ -9,6 +9,7 @@ gem "eventmachine", "~> 1.0.0"
gem "yajl-ruby"
gem "rest-client"
gem "em-http-request"
+gem "cf-message-bus"
group :test do
gem "sinatra"
View
@@ -33,6 +33,11 @@ GEM
addressable (2.3.4)
backports (3.3.1)
builder (3.2.2)
+ cf-message-bus (0.0.3)
+ eventmachine (~> 1.0.0)
+ nats (= 0.4.26)
+ vcap-concurrency
+ yajl-ruby
cookiejar (0.3.0)
daemons (1.1.9)
descendants_tracker (0.0.1)
@@ -107,6 +112,7 @@ GEM
rack (>= 1.0.0)
tilt (1.3.7)
timecop (0.6.1)
+ vcap-concurrency (0.1.0)
virtus (0.5.5)
backports (~> 3.3)
descendants_tracker (~> 0.0.1)
@@ -117,6 +123,7 @@ PLATFORMS
ruby
DEPENDENCIES
+ cf-message-bus
em-http-request
eventmachine (~> 1.0.0)
httparty
View
@@ -1,26 +0,0 @@
-#!/usr/bin/env ruby
-home = File.join(File.dirname(__FILE__), '..')
-ENV['BUNDLE_GEMFILE'] = "#{home}/Gemfile"
-
-require 'rubygems'
-require 'bundler/setup'
-require File.join(home, 'lib', 'health_manager')
-
-trap('INT') { NATS.stop { EM.stop }}
-trap('SIGTERM') { NATS.stop { EM.stop }}
-
-EM::run do
- NATS.start :uri => ENV['NATS_URI'] || 'nats://nats:nats@192.168.24.128:4222' do
- config = {
- 'bulk' => {'host' => ENV['BULK_URL'] || 'api.vcap.me', 'batch_size' => '2'},
- }
- VCAP::Logging.setup_from_config({'level' => ENV['LOG_LEVEL'] || 'debug'})
-
- prov = HealthManager::DesiredState.new(config, nil)
- prov.each_droplet do |id, droplet|
- puts "Droplet #{id}:"
- puts droplet.inspect
- end
- EM.add_timer(5) { EM.stop { NATS.stop } }
- end
-end
View
@@ -1,59 +0,0 @@
-require File.join(File.dirname(__FILE__),'..','lib','health_manager')
-
-require 'pp'
-
-@tiers = {}
-
-compact = false
-
-def showem
- puts "DEA Tenancy. Tier count: #{@tiers.size} #{Time.now}"
- @tiers.keys.sort.each do |tier|
- deas = @tiers[tier]
- puts "Tier: #{tier}, Size: #{deas.size} deas"
- deas.keys.sort.each { |dea|
- droplets = deas[dea]
- puts " #{dea}"
- puts " #{droplets.inspect}"
- }
- end
-end
-
-def showem_and_stop
- showem
- NATS.stop
-end
-
-['INT','SIGTERM'].each {|sig| trap(sig) { NATS.stop }}
-
-NATS.start :uri => ENV['NATS_URI'] do
-
- NATS.subscribe('dea.heartbeat') do |json|
-
- msg = Yajl::Parser.parse(json)
-
- dea = msg['dea']
- tier = msg['tier'] || "DEFAULT"
- deas = @tiers[tier] ||= {}
- enough = deas.has_key? dea
-
- if compact
- deas[dea] = msg['droplets'].inject(Hash.new(0)) do |h,d|
- h[d['state']] += 1
- h
- end
- else
- deas[dea] = msg['droplets'].map { |d|
- #puts d
- klass_letter = d['droplet'].class.to_s[0].downcase
- "#{d['state'][0]}:#{d['droplet']}#{klass_letter}:#{d['index']}@#{d['cc_partition']}"
- }
- end
-
-
- showem_and_stop if enough
- end
-end
-
-
-
Oops, something went wrong.

0 comments on commit 9058a98

Please sign in to comment.