Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions source/code/plugin/health/cluster_health_state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ def initialize(token_file_path, cert_file_path)
@token = get_token
end

def update_state(state)
def update_state(state) #state = hash of monitor_instance_id to HealthMonitorInstanceState struct
get_request = Net::HTTP::Get.new(@uri.request_uri)
monitor_states_hash = {}
state.each {|monitor_instance_id, health_monitor_instance_state|
monitor_states_hash[monitor_instance_id] = health_monitor_instance_state.to_h
}

get_request["Authorization"] = "Bearer #{@token}"
@log.info "Making GET request to #{@uri.request_uri} @ #{Time.now.utc.iso8601}"
Expand All @@ -37,7 +41,7 @@ def update_state(state)
update_request["Authorization"] = "Bearer #{@token}"

update_request_body = get_update_request_body
update_request_body["state"] = state.to_json
update_request_body["state"] = monitor_states_hash.to_json
update_request.body = update_request_body.to_json

update_response = @http_client.request(update_request)
Expand Down
2 changes: 1 addition & 1 deletion source/code/plugin/health/health_monitor_state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def to_h
def initialize_state(deserialized_state)
@@monitor_states = {}
deserialized_state.each{|k,v|
health_monitor_instance_state_hash = JSON.parse(v)
health_monitor_instance_state_hash = v
state = HealthMonitorInstanceState.new(*health_monitor_instance_state_hash.values_at(*HealthMonitorInstanceState.members))
state.prev_sent_record_time = health_monitor_instance_state_hash["prev_sent_record_time"]
state.old_state = health_monitor_instance_state_hash["old_state"]
Expand Down