Skip to content

Commit

Permalink
skip dcs with missing replication factor
Browse files Browse the repository at this point in the history
  • Loading branch information
Bulat Shakirzyanov committed Oct 1, 2014
1 parent fc6e4ef commit 1a703a0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ def replication_map(token_hosts, token_ring, replication_options)
datacenter = host.datacenter
next if datacenter.nil?

factor = Integer(replication_options[datacenter])
factor = replication_options[datacenter]
next unless factor

factor = Integer(factor) rescue next

replicas_in_datacenter = all_replicas[datacenter] ||= ::Set.new
next if replicas_in_datacenter.size >= factor

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,27 @@ module ReplicationStrategies
])
end
end

context('with datacenters missing replication factor') do
let(:replication_options) {
{
'dc1' => '2',
'dc2' => '2'
}
}

it 'skips those datacenters in replication map' do
replication_map = subject.replication_map(token_hosts, token_ring, replication_options)
expect(replication_map[token_ring[0]].map do |host|
[host.datacenter, host.rack]
end).to eq([
['dc1', 'rack1'],
['dc2', 'rack1'],
['dc1', 'rack2'],
['dc2', 'rack2'],
])
end
end
end
end
end
Expand Down

0 comments on commit 1a703a0

Please sign in to comment.