class Cassandra::LoadBalancing::Policies::TokenAware::Plan
@private
Public Class Methods
new(hosts, policy, keyspace, statement, options)
click to toggle source
# File lib/cassandra/load_balancing/policies/token_aware.rb 25 def initialize(hosts, policy, keyspace, statement, options) 26 @hosts = hosts 27 @policy = policy 28 @keyspace = keyspace 29 @statement = statement 30 @options = options 31 @seen = ::Hash.new 32 end
Public Instance Methods
has_next?()
click to toggle source
# File lib/cassandra/load_balancing/policies/token_aware.rb 34 def has_next? 35 until @hosts.empty? 36 host = @hosts.shift 37 38 next unless @policy.distance(host) == :local 39 @seen[host] = true 40 @next = host 41 break 42 end 43 44 return true if @next 45 46 @plan ||= @policy.plan(@keyspace, @statement, @options) 47 48 while @plan.has_next? 49 host = @plan.next 50 51 unless @seen[host] 52 @next = host 53 return true 54 end 55 end 56 57 false 58 end
next()
click to toggle source
# File lib/cassandra/load_balancing/policies/token_aware.rb 60 def next 61 host = @next 62 @next = nil 63 host 64 end