me.prettyprint.cassandra.connection.client
Class HThriftClient

java.lang.Object
  extended by me.prettyprint.cassandra.connection.client.HThriftClient
All Implemented Interfaces:
HClient
Direct Known Subclasses:
HKerberosThriftClient

public class HThriftClient
extends Object
implements HClient


Field Summary
protected  org.apache.cassandra.thrift.Cassandra.Client cassandraClient
           
protected  String keyspaceName
           
protected  int timeout
           
protected  org.apache.thrift.transport.TTransport transport
           
 
Constructor Summary
HThriftClient(CassandraHost cassandraHost)
          Constructor
 
Method Summary
 void clearAuthentication()
          Clears current authentication
 HThriftClient close()
          Close this client and its underlying connection.
 boolean equals(Object obj)
          Compares the toString of these clients
 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.
 HThriftClient 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.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

timeout

protected final int timeout

keyspaceName

protected String keyspaceName

transport

protected org.apache.thrift.transport.TTransport transport

cassandraClient

protected org.apache.cassandra.thrift.Cassandra.Client cassandraClient
Constructor Detail

HThriftClient

public HThriftClient(CassandraHost cassandraHost)
Constructor

Parameters:
cassandraHost -
Method Detail

getCassandra

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

Specified by:
getCassandra in interface HClient
Returns:
Cassandra.Client from the underlying transport

getCassandra

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

Specified by:
getCassandra in interface HClient
Parameters:
keyspaceNameArg - a keyspace
Returns:
Cassandra.Client from the underlying transport

close

public HThriftClient close()
Close this client and its underlying connection.

Specified by:
close in interface HClient
Returns:
this object

open

public HThriftClient open()
Open a connection for this client.

Specified by:
open in interface HClient
Returns:
this object

isOpen

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

Specified by:
isOpen in interface HClient
Returns:
TRUE if the underlying connection for this client is open. FALSE otherwise

startToUse

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

Specified by:
startToUse in interface HClient

getSinceLastUsed

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

Specified by:
getSinceLastUsed in interface HClient
Returns:
time in milliseconds since last used.

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object obj)
Compares the toString of these clients

Overrides:
equals in class Object

getCassandraHost

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

Specified by:
getCassandraHost in interface HClient
Returns:
the @link CassandraHost object for this client

isAlreadyAuthenticated

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

Specified by:
isAlreadyAuthenticated in interface HClient
Parameters:
credentials - authentication credentials
Returns:
TRUE if the client has previously been authenticated using the credentials, FALSE otherwise (wrong credentials or not authenticated)

clearAuthentication

public void clearAuthentication()
Clears current authentication

Specified by:
clearAuthentication in interface HClient

setAuthenticated

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

Specified by:
setAuthenticated in interface HClient
Parameters:
credentials - credentials to be set.


Copyright © 2012. All Rights Reserved.