me.prettyprint.cassandra.connection.client
Interface HClient

All Known Implementing Classes:
HKerberosThriftClient, HThriftClient

public interface HClient

Hector Client Interface.

Author:
patricioe (Patricio Echague - patricio@datastax.com)

Method Summary
 void clearAuthentication()
          Clears current authentication
 HClient close()
          Close this client and its underlying connection.
 org.apache.cassandra.thrift.Cassandra.Client getCassandra()
          Returns a new Cassandra.Client on each invocation using the underlying transport.
 org.apache.cassandra.thrift.Cassandra.Client getCassandra(String keyspaceNameArg)
          Returns a new Cassandra.Client on each invocation using the underlying transport.
 CassandraHost getCassandraHost()
          Retrieves the CassandraHost associate to this client.
 long getSinceLastUsed()
          Retrieves the time in milliseconds since this client was used last time.
 boolean isAlreadyAuthenticated(Map<String,String> credentials)
          Retrieves whether client has been authenticated with the given credentials.
 boolean isOpen()
          Retrieves whether the underlying connection for this client is open or not.
 HClient open()
          Open a connection for this client.
 void setAuthenticated(Map<String,String> credentials)
          Sets authentication credentials to the client.
 void startToUse()
          Start tracking the beginning of use for this client.
 

Method Detail

getCassandra

org.apache.cassandra.thrift.Cassandra.Client getCassandra()
Returns a new Cassandra.Client on each invocation using the underlying transport.

Returns:
Cassandra.Client from the underlying transport
Throws:
IllegalStateException - if it is called on a closed client

getCassandra

org.apache.cassandra.thrift.Cassandra.Client getCassandra(String keyspaceNameArg)
Returns a new Cassandra.Client on each invocation using the underlying transport.

Parameters:
keyspaceNameArg - a keyspace
Returns:
Cassandra.Client from the underlying transport
Throws:
IllegalStateException - if it is called on a closed client
HInvalidRequestException - if the keyspace does not exist or if it is malformed
HectorTransportException - if any other error occurs

close

HClient close()
Close this client and its underlying connection.

Returns:
this object

open

HClient open()
Open a connection for this client.

Returns:
this object
Throws:
IllegalStateException - if this method is called from a client with an open connection
HectorTransportException - if the connection cannot be established

isOpen

boolean isOpen()
Retrieves whether the underlying connection for this client is open or not.

Returns:
TRUE if the underlying connection for this client is open. FALSE otherwise

startToUse

void startToUse()
Start tracking the beginning of use for this client. This is expected to be called per operation basis. Followed by a getSinceLastUsed()


getSinceLastUsed

long getSinceLastUsed()
Retrieves the time in milliseconds since this client was used last time.

Returns:
time in milliseconds since last used.

getCassandraHost

CassandraHost getCassandraHost()
Retrieves the CassandraHost associate to this client.

Returns:
the @link CassandraHost object for this client

setAuthenticated

void setAuthenticated(Map<String,String> credentials)
Sets authentication credentials to the client.

Parameters:
credentials - credentials to be set.

isAlreadyAuthenticated

boolean isAlreadyAuthenticated(Map<String,String> credentials)
Retrieves whether client has been authenticated with the given credentials.

Parameters:
credentials - authentication credentials
Returns:
TRUE if the client has previously been authenticated using the credentials, FALSE otherwise (wrong credentials or not authenticated)

clearAuthentication

void clearAuthentication()
Clears current authentication



Copyright © 2012. All Rights Reserved.