com.datastax.driver.core

## Interface Session.State

• Enclosing interface:
Session

public static interface Session.State
The state of a Session.

This mostly exposes information on the connections maintained by a Session: which host it is connected to, how many connections it has for each host, etc...

• ### Method Summary

All Methods
Modifier and Type Method and Description
Collection<Host> getConnectedHosts()
The hosts to which the session is currently connected (more precisely, at the time this State has been grabbed).
int getInFlightQueries(Host host)
The number of queries that are currently being executed through a given host.
int getOpenConnections(Host host)
The number of open connections to a given host.
Session getSession()
The Session to which this State corresponds to.
int getTrashedConnections(Host host)
The number of "trashed" connections to a given host.
• ### Method Detail

• #### getSession

Session getSession()
The Session to which this State corresponds to.
Returns:
the Session to which this State corresponds to.
• #### getConnectedHosts

Collection<Host> getConnectedHosts()
The hosts to which the session is currently connected (more precisely, at the time this State has been grabbed).

Please note that this method really returns the hosts for which the session currently holds a connection pool. As such, it's unlikely but not impossible for a host to be listed in the output of this method but to have getOpenConnections return 0, if the pool itself is created but no connections have been successfully opened yet.

Returns:
an immutable collection of the hosts to which the session is connected.
• #### getOpenConnections

int getOpenConnections(Host host)
The number of open connections to a given host.

Note that this refers to active connections. The actual number of connections also includes getTrashedConnections(Host).

Parameters:
host - the host to get open connections for.
Returns:
The number of open connections to host. If the session is not connected to that host, 0 is returned.
• #### getTrashedConnections

int getTrashedConnections(Host host)
The number of "trashed" connections to a given host.

When the load to a host decreases, the driver will reclaim some connections in order to save resources. No requests are sent to these connections anymore, but they are kept open for an additional amount of time (PoolingOptions.getIdleTimeoutSeconds()), in case the load goes up again. This method counts connections in that state.

Parameters:
host - the host to get trashed connections for.
Returns:
The number of trashed connections to host. If the session is not connected to that host, 0 is returned.
• #### getInFlightQueries

int getInFlightQueries(Host host)
The number of queries that are currently being executed through a given host.

This corresponds to the number of queries that have been sent (by the session this is a State of) to the Cassandra Host on one of its connections but haven't yet returned. In that sense this provides a sort of measure of how busy the connections to that node are (at the time the State was grabbed at least).

Parameters:
host - the host to get in-flight queries for.
Returns:
the number of currently (as in 'at the time the state was grabbed') executing queries to host.