Navigation Menu

Skip to content

Commit

Permalink
Don't trigger restarting by changes of non-critical informations in t…
Browse files Browse the repository at this point in the history
…he cluster-state.json
  • Loading branch information
piroor committed Apr 23, 2015
1 parent f2c8555 commit 1f9f1f8
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lib/droonga/command/droonga_engine.rb
Expand Up @@ -597,19 +597,25 @@ def run_catalog_observer
catalog_observer
end

RESTART_TRIGGER_KEYS = [
"role",
]

def run_cluster_state_observer
previous_state = nil
cluster_state_observer = FileObserver.new(@loop, Path.cluster_state)
cluster_state_observer.on_change = lambda do
my_name = @configuration.engine_name
new_state = Cluster.load_state_file
if new_state and previous_state
my_new_state = new_state[my_name].dup
my_new_state.delete("internal_name")
my_previous_state = previous_state[my_name].dup
my_previous_state.delete("internal_name")
my_new_state = new_state[my_name].select do |key, _value|
RESTART_TRIGGER_KEYS.include?(key)
end
my_previous_state = previous_state[my_name].select do |key, _value|
RESTART_TRIGGER_KEYS.include?(key)
end
if my_new_state != my_previous_state
logger.info("restart by updated cluster-state.json",
logger.info("restart by changes of myself in cluster-state.json",
:previous => my_previous_state,
:new => my_new_state,
:diff => Differ.diff(my_previous_state, my_new_state))
Expand Down

0 comments on commit 1f9f1f8

Please sign in to comment.