findOld.setLong(1, minVers);
rs = findOld.executeQuery();
int cntB = 0;
try {
BlobStoreConnection bsc = wrappedStore.openConnection(null, null);
try {
while (rs.next()) {
cntB++;
String storeId = rs.getString(1);
if (logger.isTraceEnabled())
logger.trace("Purging deleted blob '" + storeId + "'");
try {
bsc.getBlob(URI.create(storeId), null).delete();
} catch (IOException ioe) {
logger.warn("Error purging blob '" + storeId + "'", ioe);
}
}
} finally {
bsc.close();
}
} catch (IOException ioe) {
logger.warn("Error opening connection to underlying store to purge old versions", ioe);
} finally {
try {
rs.close();
} finally {
findOld.close();
}
}
// purge processed entries from the delete table
String sql = "SELECT version FROM " + DEL_TABLE +
" -- DERBY-PROPERTIES index=DELETED_LIST_VIDX \n WHERE version < ?";
PreparedStatement purge =
con.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
purge.setLong(1, minVers);
rs = purge.executeQuery();
int cntD = 0;
try {
while (rs.next()) {
cntD++;
rs.deleteRow();
}
} finally {
try {
rs.close();
} finally {
purge.close();
}
}
// debug log the stats
try {
int cntL = 0;
if (logger.isTraceEnabled()) {
BlobStoreConnection bsc = wrappedStore.openConnection(null, null);
for (Iterator<URI> iter = bsc.listBlobIds(null); iter.hasNext(); iter.next())
cntL++;
bsc.close();
}
if (logger.isDebugEnabled())
logger.debug("purged: " + cntM + " mappings, " + cntB + " blobs, " + cntD +
" deletes" + (logger.isTraceEnabled() ? "; " + cntL + " blobs left" : ""));