class Cassandra::Host

Attributes

broadcast_address[R]

@note This is the public IP address of the host if the cluster is deployed across multiple Amazon EC2 regions

(or equivalently multiple networks). Cassandra nodes in other EC2 regions use this address to connect to this
host.

@return [IPAddr, String] broadcast address, if available.

datacenter[R]

@note Host datacenter can be `nil` before cluster has connected. @return [String, nil] host datacenter

id[R]

@note Host id can be `nil` before cluster has connected. @return [Cassandra::Uuid, nil] host id.

ip[R]

@return [IPAddr] host ip that clients use to connect to this host.

listen_address[R]

@note This is the address that other Cassandra nodes use to connect to this host. @return [IPAddr, String] listen address, if available.

rack[R]

@note Host rack can be `nil` before cluster has connected. @return [String, nil] host rack

release_version[R]

@note Host's cassandra version can be `nil` before cluster has connected. @return [String, nil] version of cassandra that a host is running

status[R]

@return [Symbol] host status. Must be `:up` or `:down`

tokens[R]

@note Host tokens will be empty before cluster has connected. @return [Array<String>] a list of tokens owned by this host

Public Class Methods

new(ip, id = nil, rack = nil, datacenter = nil, release_version = nil, tokens = EMPTY_LIST, status = :up, broadcast_address = nil, listen_address = nil) click to toggle source

@private

   # File lib/cassandra/host.rb
50 def initialize(ip,
51                id = nil,
52                rack = nil,
53                datacenter = nil,
54                release_version = nil,
55                tokens = EMPTY_LIST,
56                status = :up,
57                broadcast_address = nil,
58                listen_address = nil)
59   @ip              = ip
60   @id              = id
61   @rack            = rack
62   @datacenter      = datacenter
63   @release_version = release_version
64   @tokens          = tokens
65   @status          = status
66   @broadcast_address = broadcast_address.is_a?(String) ?
67       ::IPAddr.new(broadcast_address) : broadcast_address
68   @listen_address = listen_address.is_a?(String) ?
69       ::IPAddr.new(listen_address) : listen_address
70 end

Public Instance Methods

==(other)
Alias for: eql?
down?() click to toggle source

@return [Boolean] whether this host's status is `:down`

   # File lib/cassandra/host.rb
78 def down?
79   @status == :down
80 end
eql?(other) click to toggle source

@private

   # File lib/cassandra/host.rb
92 def eql?(other)
93   other.eql?(@ip)
94 end
Also aliased as: ==
hash() click to toggle source

@private

   # File lib/cassandra/host.rb
83 def hash
84   @hash ||= begin
85     h = 17
86     h = 31 * h + @ip.hash
87     h
88   end
89 end
inspect() click to toggle source

@private

    # File lib/cassandra/host.rb
 98 def inspect
 99   "#<#{self.class.name}:0x#{object_id.to_s(16)} @ip=#{@ip}>"
100 end
up?() click to toggle source

@return [Boolean] whether this host's status is `:up`

   # File lib/cassandra/host.rb
73 def up?
74   @status == :up
75 end