class Cassandra::LoadBalancing::Policies::DCAwareRoundRobin::Plan
@private
Public Class Methods
new(local, remote, index)
click to toggle source
# File lib/cassandra/load_balancing/policies/dc_aware_round_robin.rb 30 def initialize(local, remote, index) 31 @local = local 32 @remote = remote 33 @index = index 34 35 @local_remaining = @local_total = local.size 36 @remote_remaining = @remote_total = remote.size 37 end
Public Instance Methods
has_next?()
click to toggle source
# File lib/cassandra/load_balancing/policies/dc_aware_round_robin.rb 39 def has_next? 40 @local_remaining > 0 || @remote_remaining > 0 41 end
next()
click to toggle source
# File lib/cassandra/load_balancing/policies/dc_aware_round_robin.rb 43 def next 44 if @local_remaining > 0 45 @local_remaining -= 1 46 i = (@index % @local_total) 47 @index += 1 48 49 return @local[i] 50 end 51 52 if @remote_remaining > 0 53 @remote_remaining -= 1 54 i = (@index % @remote_total) 55 @index += 1 56 57 return @remote[i] 58 end 59 end