|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.dataforte.cassandra.pool.PooledConnection
public class PooledConnection
Represents a pooled connection
and holds a reference to the Cassandra.Client and TTransport object
Derived from org.apache.tomcat.jdbc.pool.PooledConnection by fhanik
| Field Summary | |
|---|---|
protected static AtomicInteger |
counter
Instance counter |
protected ConnectionPool |
parent
The parent |
protected PoolConfiguration |
poolProperties
The properties for the connection pool |
static int |
VALIDATE_BORROW
Validate when connection is borrowed flag |
static int |
VALIDATE_IDLE
Validate when connection is idle flag |
static int |
VALIDATE_INIT
Validate when connection is initialized flag |
static int |
VALIDATE_RETURN
Validate when connection is returned flag |
| Constructor Summary | |
|---|---|
PooledConnection(PoolConfiguration prop,
ConnectionPool parent)
Constructor |
|
| Method Summary | |
|---|---|
void |
connect()
|
long |
getAbandonTimeout()
Returns abandon timeout in milliseconds |
HashMap<Object,Object> |
getAttributes()
|
org.apache.cassandra.thrift.Cassandra.Client |
getConnection()
Returns the underlying connection |
long |
getLastConnected()
Returns the timestamp of when the connection was last connected to the database |
long |
getLastValidated()
Returns the timestamp of the last successful validation query execution. |
PoolConfiguration |
getPoolProperties()
Returns the configuration for this connection and pool |
long |
getReleaseTime()
The time limit for how long the object can remain unused before it is released |
String |
getStackTrace()
Returns the stack trace from when this connection was borrowed. |
long |
getTimestamp()
Return the timestamps of last pool action. |
org.apache.thrift.transport.TTransport |
getTransport()
|
boolean |
isDiscarded()
Returns the discarded flag. |
boolean |
isInitialized()
|
boolean |
isReleased()
Returns true if this connection has been released and wont be reused. |
boolean |
isSuspect()
|
void |
lock()
Locks the connection only if either PoolConfiguration.isPoolSweeperEnabled() or
PoolConfiguration.getUseLock() return true. |
void |
reconnect()
Issues a call to disconnect(boolean) with the argument false followed by a call to
connect() |
boolean |
release()
This method is called if (Now - timeCheckedIn > getReleaseTime()) This method disconnects the connection, logs an error in debug mode if it happens then sets the released flag to false. |
void |
setDiscarded(boolean discarded)
An interceptor can call this method with the value true, and the connection will be closed when it is returned to the pool. |
void |
setLastValidated(long lastValidated)
Set the timestamp the connection was last validated. |
void |
setPoolProperties(PoolConfiguration poolProperties)
Sets the pool configuration for this connection and connection pool. |
void |
setStackTrace(String trace)
The pool will set the stack trace when it is check out and checked in |
void |
setSuspect(boolean suspect)
|
void |
setTimestamp(long timestamp)
Sets a timestamp on this connection. |
String |
toString()
|
void |
unlock()
Unlocks the connection only if the sweeper is enabled Otherwise this is a noop for performance |
boolean |
validate(int validateAction)
Returns true if the object is still valid. if not the pool will call the getExpiredAction() and follow up with one of the four expired methods |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static AtomicInteger counter
public static final int VALIDATE_BORROW
public static final int VALIDATE_RETURN
public static final int VALIDATE_IDLE
public static final int VALIDATE_INIT
protected PoolConfiguration poolProperties
protected ConnectionPool parent
| Constructor Detail |
|---|
public PooledConnection(PoolConfiguration prop,
ConnectionPool parent)
prop - - pool propertiesparent - - the parent connection pool| Method Detail |
|---|
public void connect()
throws org.apache.thrift.TException
org.apache.thrift.TExceptionpublic boolean isInitialized()
public void reconnect()
throws org.apache.thrift.TException,
org.apache.cassandra.thrift.AuthenticationException,
org.apache.cassandra.thrift.AuthorizationException,
org.apache.cassandra.thrift.InvalidRequestException
disconnect(boolean) with the argument false followed by a call to
connect()
org.apache.thrift.TException - if the call to connect() fails.
org.apache.cassandra.thrift.InvalidRequestException
org.apache.cassandra.thrift.AuthorizationException
org.apache.cassandra.thrift.AuthenticationExceptionpublic long getAbandonTimeout()
public boolean validate(int validateAction)
public long getReleaseTime()
PoolConfiguration.getMinEvictableIdleTimeMillis()public boolean release()
released flag to false. Any attempts to connect this cached object again
will fail per connect()
The connection pool uses the atomic return value to decrement the pool size counter.
public void setStackTrace(String trace)
trace - the stack trace for this connectionpublic String getStackTrace()
public void setTimestamp(long timestamp)
timestamp - the timestamp as defined by System.currentTimeMillis()public boolean isSuspect()
public void setSuspect(boolean suspect)
public void setDiscarded(boolean discarded)
discarded - - only valid value is true
IllegalStateException - if this method is called with the value false and the value true has already been set.public void setLastValidated(long lastValidated)
validation-interval.
lastValidated - a timestamp as defined by System.currentTimeMillis()public void setPoolProperties(PoolConfiguration poolProperties)
ConnectionPool
poolProperties - public long getTimestamp()
abandon-timeouts.
System.currentTimeMillis()public boolean isDiscarded()
disconnect(boolean) has been called or it will be called when the connection is returned to the pool.public long getLastValidated()
System.currentTimeMillis()public PoolConfiguration getPoolProperties()
public void lock()
PoolConfiguration.isPoolSweeperEnabled() or
PoolConfiguration.getUseLock() return true. The per connection lock ensures thread safety is
multiple threads are performing operations on the connection.
Otherwise this is a noop for performance
public void unlock()
public org.apache.cassandra.thrift.Cassandra.Client getConnection()
public org.apache.thrift.transport.TTransport getTransport()
public long getLastConnected()
System.currentTimeMillis()public String toString()
toString in class Objectpublic boolean isReleased()
release() has been calledpublic HashMap<Object,Object> getAttributes()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||