Permalink
Browse files

move time consuming calls out of initilization of mysql and postgres …

…nodes

prevent time consuming calls block NATs connection

Change-Id: I23367aa1bb79749c2eb34dda88e638e858008068
  • Loading branch information...
1 parent cb2b75e commit ec3729f8ba93a9ccb96a77fd74b44668ec29ce2b @andl andl committed with figo Nov 8, 2011
Showing with 14 additions and 10 deletions.
  1. +7 −5 mysql/lib/mysql_service/node.rb
  2. +7 −5 postgresql/lib/postgresql_service/node.rb
@@ -78,14 +78,9 @@ def initialize(options)
DataMapper.setup(:default, options[:local_db])
DataMapper::auto_upgrade!
- check_db_consistency()
-
@available_storage = options[:available_storage] * 1024 * 1024
@available_storage_lock = Mutex.new
@node_capacity = @available_storage
- ProvisionedService.all.each do |provisioned_service|
- @available_storage -= storage_for_service(provisioned_service)
- end
@queries_served = 0
@qps_last_updated = 0
@@ -98,6 +93,13 @@ def initialize(options)
@binding_served = 0
end
+ def pre_send_announcement
+ ProvisionedService.all.each do |provisioned_service|
+ @available_storage -= storage_for_service(provisioned_service)
+ end
+ check_db_consistency
+ end
+
def all_instances_list
ProvisionedService.all.map{|s| s.name}
end
@@ -76,13 +76,8 @@ def initialize(options)
DataMapper.setup(:default, options[:local_db])
DataMapper::auto_upgrade!
- check_db_consistency()
-
@available_storage = options[:available_storage] * 1024 * 1024
@node_capacity = @available_storage
- Provisionedservice.all.each do |provisionedservice|
- @available_storage -= storage_for_service(provisionedservice)
- end
@long_queries_killed = 0
@long_tx_killed = 0
@@ -92,6 +87,13 @@ def initialize(options)
@mutex_available_storage = Mutex.new
end
+ def pre_send_announcement
+ Provisionedservice.all.each do |provisionedservice|
+ @available_storage -= storage_for_service(provisionedservice)
+ end
+ check_db_consistency()
+ end
+
def get_available_storage
@mutex_available_storage.synchronize do
return @available_storage

0 comments on commit ec3729f

Please sign in to comment.