Skip to content

Commit 06ffd03

Browse files
chtituxpicandocodigo
authored andcommitted
Transport/Connection: consider attributes values for equality
Two hosts must be considered as different if their attributes differ. If we don't, on hosts list refreshing, if hosts have the same IP and port, but have updated attributes, we will always consider hosts are the same and won't take the new attributes into account. On startup, hosts do not have any attributes. On the first call of client.transport.reload_connections!, we fetch the nodes list with their attributes, remove hosts that have been disappeared and add new hosts. However, we use this equality to detect if the hosts were already in the current list of nodes or node. If the client was configured with a nodes list that have the same name as the published hostname and port, the nodes with attributes will be considered equals as nodes without and we will never save the attributes in the list. And the Selector can't use attributes.
1 parent 8437f50 commit 06ffd03

File tree

1 file changed

+3
-2
lines changed
  • elasticsearch-transport/lib/elasticsearch/transport/transport/connections

1 file changed

+3
-2
lines changed

elasticsearch-transport/lib/elasticsearch/transport/transport/connections/connection.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,15 @@ def resurrectable?
135135
}
136136
end
137137

138-
# Equality operator based on connection protocol, host and port
138+
# Equality operator based on connection protocol, host, port and attributes
139139
#
140140
# @return [Boolean]
141141
#
142142
def ==(other)
143143
self.host[:protocol] == other.host[:protocol] && \
144144
self.host[:host] == other.host[:host] && \
145-
self.host[:port].to_i == other.host[:port].to_i
145+
self.host[:port].to_i == other.host[:port].to_i && \
146+
self.host[:attributes] == other.host[:attributes]
146147
end
147148

148149
# @return [String]

0 commit comments

Comments
 (0)