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,8 +71,28 @@ 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);
}
}
}
/**
*
* @param dropSchema set true if you want do drop the current and set up new one
@ -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)");
}
/**
@ -132,7 +157,7 @@ public class CassandraClusterConnection {
context.start();
// save keyspace reference
myKeyspace = context.getEntity();
@ -229,7 +254,7 @@ public class CassandraClusterConnection {
* define Attachments CF with FeedId as secondary index
*/
ColumnFamilyDefinition cfDefAttachments = getStaticCFDef(DBCassandraAstyanaxImpl.ATTACHMENTS, "Feedid");
//get dynamic column families, act as auxiliary indexes
ColumnFamilyDefinition cfDefConn = getDynamicCFDef(DBCassandraAstyanaxImpl.CONNECTIONS);

View File

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