Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Change use of Nats::Message with Schemata msgs

Change-Id: I6209220de17bfd802d6d8c334394d270dcf1bdf0
  • Loading branch information...
commit 3c514140eef66caea7e7d11008b9807359f5f24f 1 parent b38cc70
David Sabeti dsabeti authored

Showing 1 changed file with 14 additions and 20 deletions. Show diff stats Hide diff stats

  1. +14 20 lib/dea/bootstrap.rb
34 lib/dea/bootstrap.rb
@@ -530,7 +530,7 @@ def handle_dea_status(message)
530 530 def handle_dea_directed_start(message)
531 531 msg_obj = Schemata::DEA::StartRequest.decode(message.data)
532 532
533   - instance = create_instance(Yajl::Parser.parse(message.data))
  533 + instance = create_instance(msg_obj.contents)
534 534
535 535 if config.only_production_apps? && !instance.production_app?
536 536 logger.info("Ignoring instance for non-production app: #{instance}")
@@ -554,7 +554,7 @@ def handle_dea_locate(message)
554 554 def handle_dea_stop(message)
555 555 msg_obj = Schemata::DEA::StopRequest.decode(message.data)
556 556
557   - instances_filtered_by_message(message) do |instance|
  557 + instances_filtered_by_message(msg_obj) do |instance|
558 558 next if !instance.running?
559 559
560 560 instance.stop do |error|
@@ -566,10 +566,8 @@ def handle_dea_stop(message)
566 566 def handle_dea_discover(message)
567 567 msg_obj = Schemata::DEA::DiscoverRequest.decode(message.data)
568 568
569   - data = Yajl::Parser.parse(message.data)
570   -
571   - runtime = data["runtime"]
572   - rs = data["limits"]
  569 + runtime = msg_obj.runtime
  570 + rs = msg_obj.limits
573 571
574 572 if !runtimes.has_key?(runtime)
575 573 logger.info("Unsupported runtime '#{runtime}'")
@@ -579,7 +577,7 @@ def handle_dea_discover(message)
579 577 return
580 578 end
581 579
582   - delay = calculate_discover_delay(data["droplet"].to_s)
  580 + delay = calculate_discover_delay(msg_obj.droplet.to_s)
583 581
584 582 logger.debug("Delaying discover response for #{delay} secs.")
585 583
@@ -604,10 +602,8 @@ def calculate_discover_delay(app_id)
604 602 def handle_dea_update(message)
605 603 msg_obj = Schemata::DEA::UpdateRequest.decode(message.data)
606 604
607   - data = Yajl::Parser.parse(message.data)
608   -
609   - app_id = data["droplet"].to_s
610   - uris = data["uris"]
  605 + app_id = msg_obj.droplet.to_s
  606 + uris = msg_obj.uris
611 607
612 608 instance_registry.instances_for_application(app_id).each do |_, instance|
613 609 current_uris = instance.application_uris
@@ -632,10 +628,10 @@ def handle_dea_update(message)
632 628 def handle_dea_find_droplet(message)
633 629 msg_obj = Schemata::DEA::FindDropletRequest.decode(message.data)
634 630
635   - instances_filtered_by_message(message) do |instance|
  631 + instances_filtered_by_message(msg_obj) do |instance|
636 632 response = Dea::Protocol::V1::FindDropletResponse.generate(self,
637 633 instance,
638   - Yajl::Parser.parse(message.data))
  634 + msg_obj.contents)
639 635 message.respond(response)
640 636 end
641 637
@@ -759,8 +755,7 @@ def send_advertise
759 755 end
760 756
761 757 def instances_filtered_by_message(message)
762   - data = Yajl::Parser.parse(message.data)
763   - app_id = data["droplet"].to_s
  758 + app_id = message.droplet.to_s
764 759
765 760 if app_id
766 761 logger.debug2("Filter message for app_id: %s" % app_id, :app_id => app_id)
@@ -778,11 +773,10 @@ def instances_filtered_by_message(message)
778 773 set_or_nil = lambda { |h, k| h.has_key?(k) ? Set.new(h[k]) : nil }
779 774
780 775 # Optional search filters
781   - version = data["version"]
782   - instance_ids = set_or_nil.call(data, "instances")
783   - instance_ids ||= set_or_nil.call(data, "instance_ids")
784   - indices = set_or_nil.call(data, "indices")
785   - states = set_or_nil.call(data, "states")
  776 + version = message.version
  777 + instance_ids ||= message.instance_ids
  778 + indices = message.indices
  779 + states = message.states
786 780 states = states.map { |e| Dea::Instance::State.from_external(e) } unless states.nil?
787 781
788 782 instances.each do |_, instance|

Git Notes

review

Verified+1: CI Master <cf-ci@rbcon.com>
Code-Review+2: Kowshik Prakasam <kprakasam@rbcon.com>
Submitted-by: David Sabeti <dsabeti@rbcon.com>
Submitted-at: Fri, 11 Jan 2013 21:57:06 +0000
Reviewed-on: http://reviews.cloudfoundry.org/13221
Project: dea_ng
Branch: refs/heads/schemata

0 comments on commit 3c51414

Please sign in to comment.
Something went wrong with that request. Please try again.