Skip to content

Commit

Permalink
[CASSANDRA-7825] skip ghost nodes in system.peers table
Browse files Browse the repository at this point in the history
  • Loading branch information
Bulat Shakirzyanov committed Oct 4, 2014
1 parent d472834 commit 220942f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/cassandra/cluster/control_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,9 @@ def refresh_hosts_async
ips = ::Set.new

peers.each do |data|
ips << ip = peer_ip(data)
ip = peer_ip(data)
next unless ip
ips << ip
@registry.host_found(ip, data)
end

Expand Down
40 changes: 40 additions & 0 deletions spec/cassandra/cluster/control_connection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,46 @@ def handle_request(&handler)
end
end

context 'with empty peers' do
it 'skips empty peers' do
additional_rpc_addresses = additional_nodes.dup

handle_request do |request|
case request
when Protocol::QueryRequest
case request.cql
when /FROM system\.peers/
rows = min_peers[0].times.map do |host_id|
ip = additional_rpc_addresses.shift
{
'peer' => ip,
'rack' => racks[ip],
'data_center' => data_centers[ip],
'host_id' => host_ids[ip],
'rpc_address' => bind_all_rpc_addresses ? IPAddr.new('0.0.0.0') : ip,
'release_version' => release_versions[ip]
}
end

rows << {
'peer' => nil,
'rack' => nil,
'data_center' => nil,
'host_id' => nil,
'rpc_address' => nil,
'release_version' => nil
}
Protocol::RowsResultResponse.new(rows, peer_metadata, nil, nil)
end
end
end

control_connection.connect_async.value

expect(cluster_registry).to have(3).hosts
end
end

context 'with logging' do
it 'logs when fetching cluster state' do
logger.stub(:debug)
Expand Down

0 comments on commit 220942f

Please sign in to comment.