Permalink
Browse files

the RCC should only write the to the master_file if it has differing …

…content
  • Loading branch information...
1 parent a449cfb commit 93176e8a133caf728c32720c86aad6917e24f1cf @skaes skaes committed Jul 1, 2010
Showing with 9 additions and 2 deletions.
  1. +9 −2 lib/beetle/redis_configuration_client.rb
@@ -68,8 +68,11 @@ def reconfigure(payload)
host = payload["host"]
port = payload["port"]
logger.warn "Received reconfigure message with host '#{host}' port '#{port}'"
- write_redis_master_file("#{host}:#{port}")
- @redis_master = Redis.new(:host => host, :port => port)
+ server = "#{host}:#{port}"
+ unless server == read_redis_master_file
+ write_redis_master_file(server)
+ @redis_master = Redis.new(:host => host, :port => port)
+ end
end
private
@@ -123,6 +126,10 @@ def clear_redis_master_file
write_redis_master_file("")
end
+ def read_redis_master_file
+ File.read(master_file).chomp
+ end
+
def write_redis_master_file(redis_server_string)
logger.warn "Writing '#{redis_server_string}' to redis master file '#{master_file}'"
File.open(master_file, "w"){|f| f.puts redis_server_string}

0 comments on commit 93176e8

Please sign in to comment.