public class Host extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
Host.LifecycleAwareStateListener
A
StateListener that tracks when it gets registered or unregistered with a cluster. |
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 node address.
|
VersionNumber |
getCassandraVersion()
The Cassandra version the host is running.
|
String |
getDatacenter()
Returns the name of the datacenter this host is part of.
|
ListenableFuture<?> |
getInitialReconnectionAttemptFuture()
Deprecated.
the suspicion mechanism has been disabled. This will always return
a completed future.
|
String |
getRack()
Returns the name of the rack this host is part of.
|
ListenableFuture<?> |
getReconnectionAttemptFuture()
Returns a
ListenableFuture representing the completion of the reconnection
attempts scheduled after a host is marked DOWN . |
InetSocketAddress |
getSocketAddress()
Returns the node socket address.
|
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 |
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()
.InetAddress
.public InetSocketAddress getSocketAddress()
InetSocketAddress
.public String getDatacenter()
null
, and the caller should always be aware
of this possibility.public String getRack()
null
, and the caller should always aware of this
possibility.public VersionNumber getCassandraVersion()
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()
@Deprecated public ListenableFuture<?> getInitialReconnectionAttemptFuture()
ListenableFuture
representing the completion of the first
reconnection attempt after a node has been suspected.
This is useful in load balancing policies when there are no more live nodes and
we are trying suspected nodes.public 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.