public class Host extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
Host.StateListener
Interface for listeners that are interested in hosts added, up, down and
removed events.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other) |
InetAddress |
getAddress()
Returns the address that the driver will use to connect to the node.
|
InetAddress |
getBroadcastAddress()
Returns the node broadcast address (that is, the IP by which it should be contacted by other peers in the
cluster), if known.
|
VersionNumber |
getCassandraVersion()
The Cassandra version the host is running.
|
String |
getDatacenter()
Returns the name of the datacenter this host is part of.
|
VersionNumber |
getDseVersion()
The DSE version the host is running.
|
String |
getDseWorkload()
The DSE Workload the host is running.
|
InetAddress |
getListenAddress()
Returns the node listen address (that is, the IP the node uses to contact other peers in the cluster), if known.
|
String |
getRack()
Returns the name of the rack this host is part of.
|
com.google.common.util.concurrent.ListenableFuture<?> |
getReconnectionAttemptFuture()
Returns a
ListenableFuture representing the completion of the reconnection
attempts scheduled after a host is marked DOWN . |
InetSocketAddress |
getSocketAddress()
Returns the address and port that the driver will use to connect to the node.
|
String |
getState()
Returns a description of the host's state, as seen by the driver.
|
Set<Token> |
getTokens()
Returns the tokens that this host owns.
|
int |
hashCode() |
boolean |
isDseGraphEnabled()
Returns whether the host is running DSE Graph.
|
boolean |
isUp()
Returns whether the host is considered up by the driver.
|
String |
toString() |
void |
tryReconnectOnce()
Triggers an asynchronous reconnection attempt to this host.
|
public InetAddress getAddress()
getSocketAddress().getAddress()
.getSocketAddress()
public InetSocketAddress getSocketAddress()
AddressTranslator
has been configured
for this cluster.
The broadcast RPC address is inferred from the following cassandra.yaml file settings:
rpc_address
, rpc_interface
or broadcast_rpc_address
native_transport_port
public InetAddress getBroadcastAddress()
broadcast_address
cassandra.yaml file setting and
is by default the same as getListenAddress()
, unless specified
otherwise in cassandra.yaml.
This is NOT the address clients should use to contact this node.
This information is always available for peer hosts. For the control host, it's only available if CASSANDRA-9436
is fixed on the server side (Cassandra versions >= 2.0.16, 2.1.6, 2.2.0 rc1). For older versions, note that if
the driver loses the control connection and reconnects to a different control host, the old control host becomes
a peer, and therefore its broadcast address is updated.null
.public InetAddress getListenAddress()
listen_address
cassandra.yaml file setting.
This is NOT the address clients should use to contact this node.
This information is available for the control host if CASSANDRA-9603 is fixed on the server side (Cassandra
versions >= 2.0.17, 2.1.8, 2.2.0 rc2). It's currently not available for peer hosts. Note that the current driver
code already tries to read a listen_address
column in system.peers
; when a future Cassandra
version adds it, it will be picked by the driver without any further change needed.null
.public String getDatacenter()
null
, and the caller should always be aware
of this possibility.public String getRack()
null
, and the caller should always be aware of this
possibility.public VersionNumber getCassandraVersion()
null
, and the caller should always be aware of this
possibility.public VersionNumber getDseVersion()
null
, and the caller should always be aware of this
possibility.public String getDseWorkload()
null
, and the caller should always be aware of this
possibility.public boolean isDseGraphEnabled()
public Set<Token> getTokens()
public boolean isUp()
LoadBalancingPolicy.distance
method says so), this information
may be durably inaccurate). This information should thus only be
considered as best effort and should not be relied upon too strongly.public String getState()
public com.google.common.util.concurrent.ListenableFuture<?> getReconnectionAttemptFuture()
ListenableFuture
representing the completion of the reconnection
attempts scheduled after a host is marked DOWN
.
If the caller cancels this future, the driver will not try to reconnect to
this host until it receives an UP event for it. Note that this could mean never, if
the node was marked down because of a driver-side error (e.g. read timeout) but no
failure was detected by Cassandra. The caller might decide to trigger an explicit
reconnection attempt at a later point with tryReconnectOnce()
.null
if no reconnection attempt was in progress.public void tryReconnectOnce()
IGNORED
,
but still need a way to periodically check these hosts' states (UP / DOWN).
For a host that is at distance IGNORED
, this method will try to reconnect exactly once: if
reconnection succeeds, the host is marked UP
; otherwise, no further attempts will be scheduled.
It has no effect if the node is already UP
, or if a reconnection attempt is already in progress.
Note that if the host is not a distance IGNORED
, this method will trigger a periodic
reconnection attempt if the reconnection fails.