Permalink
Browse files

Fill out message fields needing the resource manager

Change-Id: I11b74f604cb96ec37c93497383fcf7bcc3f5fdc8
  • Loading branch information...
1 parent 54b2f69 commit c65f4c7a3a67f1133cfd93698e02483f05ef0a9b mpage committed Aug 9, 2012
Showing with 12 additions and 7 deletions.
  1. +11 −7 lib/dea/protocol.rb
  2. +1 −0 spec/dea/messages/advertisements_spec.rb
View
@@ -88,8 +88,7 @@ class AdvertiseMessage
def self.generate(bootstrap)
{ "id" => bootstrap.uuid,
"runtimes" => bootstrap.runtimes.keys,
- # TODO: Fill in when available
- "available_memory" => 0,
+ "available_memory" => bootstrap.resource_manager.resources["memory"].remain,
}
end
end
@@ -108,12 +107,17 @@ class DeaStatusResponse
def self.generate(bootstrap)
hello = HelloMessage.generate(bootstrap)
+ used_memory = bootstrap.instance_registry.inject(0) do |a, i|
+ a + (i.used_memory_in_bytes / (1024 * 1024))
+ end
+
+ rm = bootstrap.resource_manager
+
extra = {
- # TODO: Fill these in when we have resource tracking working
- "max_memory" => nil,
- "reserved_memory" => nil,
- "used_memory" => nil,
- "num_clients" => nil,
+ "max_memory" => rm.resources["memory"].capacity,
+ "reserved_memory" => rm.resources["memory"].used,
+ "used_memory" => used_memory,
+ "num_clients" => rm.resources["num_instances"].used,
}
hello.merge(extra)
@@ -35,5 +35,6 @@ def verify_advertisement(advert)
advert.should_not be_nil
advert["id"].should == @bootstrap.uuid
advert["runtimes"].should == @bootstrap.runtimes.keys
+ advert["available_memory"].should == @bootstrap.resource_manager.resources["memory"].remain
end
end

0 comments on commit c65f4c7

Please sign in to comment.