Skip to content

Commit

Permalink
Continue to work on the purge process.
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Feb 29, 2008
1 parent be0ba92 commit ced9dd6
Showing 1 changed file with 12 additions and 1 deletion.
Expand Up @@ -114,6 +114,7 @@ private void purgeOutgoing(Calendar retentionCutoff) {
}

private void purgeOutgoingBatchHistory(Calendar retentionCutoff) {
logger.info("Purging outgoing batch history");
int[] minMax = (int[]) jdbcTemplate.queryForObject(selectOutgoingBatchHistoryRangeSql,
new Object[] { retentionCutoff.getTime() }, new RowMapper() {
public Object mapRow(ResultSet rs, int row) throws SQLException {
Expand All @@ -123,11 +124,21 @@ public Object mapRow(ResultSet rs, int row) throws SQLException {
if (minMax != null) {
int currentHistoryId = minMax[0];
int max = minMax[1];
long ts = System.currentTimeMillis();
int totalCount = 0;
while (currentHistoryId < max) {
currentHistoryId = currentHistoryId + maxNumOfDataIdsToPurgeInTx > max ? max : currentHistoryId
+ maxNumOfDataIdsToPurgeInTx;
jdbcTemplate.update(deleteFromOutgoingBatchHistSql, new Object[] { currentHistoryId });
totalCount += jdbcTemplate.update(deleteFromOutgoingBatchHistSql, new Object[] { currentHistoryId });

if (totalCount > 0 && (System.currentTimeMillis() - ts > DateUtils.MILLIS_PER_MINUTE * 5)) {
logger.info("Purged " + totalCount + " a total of outgoing batch history rows so far.");
ts = System.currentTimeMillis();
}
}

logger.info("Finished purging " + totalCount + " outgoing batch history rows.");

}
}

Expand Down

0 comments on commit ced9dd6

Please sign in to comment.