Issue #2224 Add enable flag to archive purger and move properties to plug-in.

Change-Id: I6fd80f4b5f1326a173bd8e980735781d9ec03898

Former-commit-id: c9b8280236e1a3fc3afe9fb74e0b4c7c88c31179
This commit is contained in:
Roger Ferrel 2013-09-03 12:55:23 -05:00
parent 465d41c2e9
commit 23479aa5f7
3 changed files with 28 additions and 18 deletions

View file

@ -12,10 +12,6 @@ qc.cron=0+2,7,12,17,22,27,32,37,42,47,52,57+*+*+*+?
acarssounding.cron=00+10,30,50+*+*+*+?
gfe.cron=0+15+*+*+*+?
repack.cron=0+20+*+*+*+?
# runs database and hdf5 archive for archive server to pull data from
archive.cron=0+40+*+*+*+?
# purge archives
archive.purge.cron=0+0+*+*+*+?
###purge configuration
# Interval at which the purge job kicks off

View file

@ -0,0 +1,6 @@
# runs database and hdf5 archive for archive server to pull data from
archive.cron=0+40+*+*+*+?
# purge archives
archive.purge.cron=0+5+*+*+*+?
# enable archive purge
archive.purge.enable=false

View file

@ -40,6 +40,7 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
* Added info logging for purge counts.
* Aug 28, 2013 2299 rferrel manager.purgeExpiredFromArchive now returns
* number of files purged.
* Sep 03, 2013 2224 rferrel Add check to enable/disable purger.
*
* </pre>
*
@ -49,27 +50,34 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
public class ArchivePurger {
private final static IUFStatusHandler statusHandler = UFStatus
.getHandler(ArchiveConfigManager.class);
.getHandler(ArchivePurger.class);
private final static String ENABLE_PROPERTY = "archive.purge.enable";
/**
* Purge expired elements from the archives.
*/
public static void purge() {
ArchiveConfigManager manager = ArchiveConfigManager.getInstance();
Collection<ArchiveConfig> archives = manager.getArchives();
for (ArchiveConfig archive : archives) {
int purgeCount = manager.purgeExpiredFromArchive(archive);
if (statusHandler.isPriorityEnabled(Priority.INFO)) {
StringBuilder sb = new StringBuilder(archive.getName());
sb.append("::Archive Purged ");
sb.append(purgeCount);
sb.append(" file");
if (purgeCount != 1) {
sb.append("s");
String enableString = System.getProperty(ENABLE_PROPERTY, "false");
if (Boolean.parseBoolean(enableString)) {
statusHandler.info("::Archive Purged started.");
ArchiveConfigManager manager = ArchiveConfigManager.getInstance();
Collection<ArchiveConfig> archives = manager.getArchives();
for (ArchiveConfig archive : archives) {
int purgeCount = manager.purgeExpiredFromArchive(archive);
if (statusHandler.isPriorityEnabled(Priority.INFO)) {
StringBuilder sb = new StringBuilder(archive.getName());
sb.append("::Archive Purged ");
sb.append(purgeCount);
sb.append(" file");
if (purgeCount != 1) {
sb.append("s");
}
sb.append(".");
statusHandler.info(sb.toString());
}
sb.append(".");
statusHandler.info(sb.toString());
}
statusHandler.info("::Archive Purged finished.");
}
}
}