} catch (Exception ex) {
// if something happens make sure buckets locks are being release
releaseLocks(expiredBuckets);
log.failedClearingJdbcCacheStore(ex);
throw new CacheLoaderException("Failed clearing JdbcBinaryStore", ex);
} finally {
JdbcUtil.safeClose(ps);
JdbcUtil.safeClose(rs);
}
try {
PersistenceUtil.waitForAllTasksToComplete(ecs, taskCount);
} catch (CacheLoaderException e) {
releaseLocks(emptyBuckets);
}
if (emptyBuckets.isEmpty())
return;
if (log.isTraceEnabled()) {
log.tracef("About to remove empty buckets %s", emptyBuckets);
}
// then remove the empty buckets
try {
String sql = tableManipulation.getDeleteRowSql();
ps = conn.prepareStatement(sql);
int deletionCount = 0;
for (Bucket bucket : emptyBuckets) {
ps.setString(1, bucket.getBucketIdAsString());
ps.addBatch();
deletionCount++;
if (deletionCount % batchSize == 0) {
if (log.isTraceEnabled()) {
log.tracef("Flushing deletion batch, total deletion count so far is %d", deletionCount);
}
ps.executeBatch();
}
}
if (deletionCount % batchSize != 0) {
int[] batchResult = ps.executeBatch();
if (log.isTraceEnabled()) {
log.tracef("Flushed the batch and received following results: %s", Arrays.toString(batchResult));
}
}
} catch (Exception ex) {
// if something happens make sure buckets locks are being release
log.failedClearingJdbcCacheStore(ex);
throw new CacheLoaderException("Failed clearing JdbcBinaryStore", ex);
} finally {
releaseLocks(emptyBuckets);
JdbcUtil.safeClose(ps);
}
} finally {