Permalink
Browse files

report mysql pool size in varz

Change-Id: Ibe189d27db1ac3e24ee824ccfc57ff0bffe7d926
  • Loading branch information...
EagleChen committed Nov 27, 2012
1 parent e9e0965 commit 80cc4dea2dfa024ef1e3656a4705d16b56589268
@@ -40,7 +40,7 @@ warden:
service_log_dir: /var/vcap/services/mysql/log
image_dir: /var/vcap/services/mysql/image
service_start_timeout: 3
- filesystem_quota: true
+ filesystem_quota: false
# z_interval: 30
# max_nats_payload: 1048576
@@ -648,6 +648,9 @@ def varz_details()
rescue => e
@logger.error("Error get instance list: #{e}")
end
+ # connection pool information
+ varz[:pools] = {}
+ each_pool_with_key { |conn_pool, key| varz[:pools][key] = conn_pool.inspect }
varz
rescue => e
@logger.error("Error during generate varz: #{e}")
@@ -203,7 +203,7 @@ def initialize(options)
def inspect
{
- :size => @size,
+ :size => @connections.size,
:checked_out_size => @checked_out.size,
:checked_out_by => @checked_out.map{|conn| conn.checked_out_by },
:average_latency_ms => @latency_sum / @queries_served,
@@ -93,6 +93,16 @@ def each_pool
end
end
+ def each_pool_with_key
+ # we can't iterate using @pools.each because provision and unprovision
+ # will change @pools. Changing @pools during @pools.each will cause an error
+ mysqlProvisionedService.all.each do |instance|
+ conn_pool = fetch_pool(instance.name)
+ next if conn_pool.nil?
+ yield conn_pool, instance.name
+ end
+ end
+
def each_connection_with_port
mysqlProvisionedService.all.each do |instance|
conn_pool = fetch_pool(instance.name)
@@ -69,6 +69,12 @@ def each_pool
end
end
+ def each_pool_with_key
+ @supported_versions.each do |version|
+ yield @pools[version], version
+ end
+ end
+
def each_connection_with_port
@supported_versions.each do |version|
@pools[version].with_connection { |conn| yield conn, @mysql_configs[version]["port"] }
@@ -714,6 +714,7 @@ class << @node
varz[:long_transactions_killed].should >= 0
varz[:provision_served].should >= 0
varz[:binding_served].should >= 0
+ varz[:pools].should be_instance_of Hash
EM.stop
end
end
@@ -801,6 +802,18 @@ class << @node
end
end
+ it "should report pool size in varz" do
+ EM.run do
+ varz = @node.varz_details
+ if @node.use_warden
+ varz[:pools].should have_key(@db["name"])
+ else
+ @opts[:mysql].keys.each { |key| varz[:pools].should have_key(key) }
+ end
+ EM.stop
+ end
+ end
+
it "should be thread safe" do
EM.run do
provision_served = @node.provision_served
@@ -897,16 +910,19 @@ class << @node
end
after :each do
- @node.create_missing_pools if @node.use_warden
- @test_dbs.keys.each do |db|
- begin
- name = db["name"]
- @node.unprovision(name, @test_dbs[db])
- @node.logger.info("Clean up temp database: #{name}")
- rescue => e
- @node.logger.info("Error during cleanup #{e}")
- end
- end if @test_dbs
+ EM.run do
+ @node.create_missing_pools if @node.use_warden
+ @test_dbs.keys.each do |db|
+ begin
+ name = db["name"]
+ @node.unprovision(name, @test_dbs[db])
+ @node.logger.info("Clean up temp database: #{name}")
+ rescue => e
+ @node.logger.info("Error during cleanup #{e}")
+ end
+ end if @test_dbs
+ EM.stop
+ end
end
after :all do

0 comments on commit 80cc4de

Please sign in to comment.