use of com.hortonworks.registries.storage.impl.jdbc.provider.sql.statement.PreparedStatementBuilder in project registry by hortonworks.
the class AbstractQueryExecutor method buildCache.
private Cache<SqlQuery, PreparedStatementBuilder> buildCache(CacheBuilder<SqlQuery, PreparedStatementBuilder> cacheBuilder) {
return cacheBuilder.removalListener(new RemovalListener<SqlQuery, PreparedStatementBuilder>() {
/**
* Cleanup operation for when the entry is removed from cache
*/
@Override
public void onRemoval(RemovalNotification<SqlQuery, PreparedStatementBuilder> notification) {
final PreparedStatementBuilder preparedStatementBuilder = notification.getValue();
log.debug("Removed entry from cache [key:{}, val: {}]", notification.getKey(), preparedStatementBuilder);
log.debug("Cache size: {}", cache.size());
if (preparedStatementBuilder != null && !transactionBookKeeper.hasActiveTransaction(Thread.currentThread().getId())) {
closeConnection(preparedStatementBuilder.getConnection());
}
}
}).build();
}
Aggregations