implemented closeConnection to shutdown connection pool to cassandra nodes

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/social-networking-library@130200 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-07-09 15:54:33 +00:00
parent 13afd36dce
commit e5fa6e59a7
2 changed files with 36 additions and 3 deletions

View File

@ -71,6 +71,26 @@ public class CassandraClusterConnection {
_log.info(keyspaceName + " KeySpace SetUp ...");
SetUpKeySpaces(clusterContext, dropSchema);
_log.info("CONNECTED! using KeySpace: " + keyspaceName);
// then close connection pool for cluster
_log.info("Closing cluster connection pool no longer needed (keyspace one will be used)");
clusterContext.shutdown();
_log.info("Closed cluster connection pool no longer needed (keyspace one will be used)");
}
/**
* Close the connection pool
*/
public void closeConnection(){
if(myKeyspace != null){
try{
_log.info("Closing pool connection");
myKeyspace.getConnectionPool().shutdown();
}catch(Exception e){
_log.error("Unable to close connection pool", e);
}
}
}
/**
@ -100,6 +120,11 @@ public class CassandraClusterConnection {
_log.info(keyspaceName + " KeySpace SetUp ...");
SetUpKeySpaces(clusterContext, dropSchema);
_log.info("CONNECTED! using KeySpace: " + keyspaceName);
// then close connection pool for cluster
_log.info("Closing cluster connection pool no longer needed (keyspace one will be used)");
clusterContext.shutdown();
_log.info("Closed cluster connection pool no longer needed (keyspace one will be used)");
}
/**

View File

@ -2022,6 +2022,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
*/
@Override
public void closeConnection() {
conn.closeConnection();
}
/*
*
@ -2409,4 +2410,11 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
}
@Override
protected void finalize() throws Throwable {
super.finalize();
_log.info("On Finalize called...");
this.closeConnection();
}
}