class Cassandra::Execution::ProfileManager
@private
Attributes
load_balancing_policies[R]
profiles[R]
Public Class Methods
new(default_profile, profiles)
click to toggle source
# File lib/cassandra/execution/profile_manager.rb 26 def initialize(default_profile, profiles) 27 # default_profile is the default profile that we constructed internally. However, the user can override it 28 # with their own :default profile. If that happens, ignore the internally generated default profile. 29 30 profiles[:default] = default_profile unless profiles.key?(:default) 31 32 # Save off all of the load-balancing policies for easy access. 33 @load_balancing_policies = Set.new 34 profiles.each do |name, profile| 35 @load_balancing_policies << profile.load_balancing_policy 36 end 37 @profiles = profiles 38 end
Public Instance Methods
add_profile(name, profile)
click to toggle source
NOTE: It's only safe to call add_profile
when setting up the cluster object. In particular, this is only ok before calling Driver#connect
.
# File lib/cassandra/execution/profile_manager.rb 59 def add_profile(name, profile) 60 @profiles[name] = profile 61 @load_balancing_policies << profile.load_balancing_policy 62 end
default_profile()
click to toggle source
# File lib/cassandra/execution/profile_manager.rb 40 def default_profile 41 @profiles[:default] 42 end
distance(host)
click to toggle source
# File lib/cassandra/execution/profile_manager.rb 44 def distance(host) 45 # Return the min distance to the host, as per each lbp. 46 distances = Set.new 47 @load_balancing_policies.each do |lbp| 48 distances.add(lbp.distance(host)) 49 end 50 return :local if distances.include?(:local) 51 return :remote if distances.include?(:remote) 52 53 # Fall back to ignore the host. 54 :ignore 55 end
inspect()
click to toggle source
@private
# File lib/cassandra/execution/profile_manager.rb 65 def inspect 66 "#<#{self.class.name}:0x#{object_id.to_s(16)} " \ 67 "profiles=#{@profiles.inspect}>" 68 end