com.hmsonline.virgil.pool.ConnectionPoolClient Maven / Gradle / Ivy
The newest version!
package com.hmsonline.virgil.pool;
import org.apache.cassandra.thrift.Cassandra;
import org.apache.cassandra.thrift.InvalidRequestException;
import org.apache.thrift.TException;
public class ConnectionPoolClient {
ThreadLocal connection = new ThreadLocal() {
@Override
protected Cassandra.Iface initialValue() {
throw new RuntimeException("Using connection w/o attaining from the pool.");
}
};
public void setConnection(Cassandra.Iface connection) {
this.connection.set(connection);
}
public Cassandra.Iface getConnection(String keyspace) throws InvalidRequestException, TException{
Cassandra.Iface connection = this.connection.get();
if (keyspace != null)
connection.set_keyspace(keyspace);
return connection;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy