@Test public void shouldDeleteBackupTest() { GoldBackup goldBackup = new GoldBackup(); Long goldProtectionTime = ScheduledBackupType.getProtectedBackupTypes().get(goldBackup); assertTrue("gold backups should be protected", goldProtectionTime != null); String newGoldBackup = goldBackup.generateNameForTime(now, true); String youngGoldBackup = goldBackup.generateNameForTime(now - goldProtectionTime / 2, true); String oldGoldBackup = goldBackup.generateNameForTime(now - 3 * goldProtectionTime, true); assertTrue("should not delete new gold backup", !MinionTaskDeleter.shouldDeleteBackup(newGoldBackup, goldBackup)); assertTrue("should not delete young gold backup", !MinionTaskDeleter.shouldDeleteBackup(youngGoldBackup, goldBackup)); assertTrue("should delete old gold backup", MinionTaskDeleter.shouldDeleteBackup(oldGoldBackup, goldBackup)); DailyBackup dailyBackup = new DailyBackup(); assertTrue("should delete old daily backup", MinionTaskDeleter.shouldDeleteBackup(dailyBackup.generateNameForTime(now - dayInMillis, true), dailyBackup)); }
public static boolean shouldDeleteBackup(String backupName, ScheduledBackupType type) { if (type.isValidName(backupName) && protectedBackupTypes.containsKey(type)) { long age; try { age = System.currentTimeMillis() - type.parseDateFromName(backupName).getTime(); return age > protectedBackupTypes.get(type); } catch (IllegalArgumentException e) { return false; } } return true; }
MinionTaskDeleter implements Codable { public static boolean shouldDeleteBackup(String backupName, ScheduledBackupType type) { if (type.isValidName(backupName) && protectedBackupTypes.containsKey(type)) { long age; try { age = System.currentTimeMillis() - type.parseDateFromName(backupName).getTime(); return age > protectedBackupTypes.get(type); } catch (IllegalArgumentException e) { return false; } } return true; } }
MinionTaskDeleter implements Codable { public static boolean shouldDeleteBackup(String backupName, ScheduledBackupType type) { if (type.isValidName(backupName) && protectedBackupTypes.containsKey(type)) { long age; try { age = System.currentTimeMillis() - type.parseDateFromName(backupName).getTime(); return age > protectedBackupTypes.get(type); } catch (IllegalArgumentException e) { return false; } } return true; } MinionTaskDeleter(); }
MinionTaskDeleter implements Codable { public static boolean shouldDeleteBackup(String backupName, ScheduledBackupType type) { if (type.isValidName(backupName) && protectedBackupTypes.containsKey(type)) { long age; try { age = System.currentTimeMillis() - type.parseDateFromName(backupName).getTime(); return age > protectedBackupTypes.get(type); } catch (IllegalArgumentException e) { return false; } } return true; } MinionTaskDeleter(); void submitPathToDelete(String taskPath); void submitBackupToDelete(String backupPath, ScheduledBackupType type); synchronized void startDeletionThread(); synchronized void stopDeletionThread(); synchronized void deleteStoredItems(); boolean executeDelete(BackupToDelete backupToDelete); static boolean shouldDeleteBackup(String backupName, ScheduledBackupType type); Set<String> getTasksToDelete(); Set<BackupToDelete> getBackupsToDelete(); }
MinionTaskDeleter implements Codable { public static boolean shouldDeleteBackup(String backupName, ScheduledBackupType type) { if (type.isValidName(backupName) && protectedBackupTypes.containsKey(type)) { long age; try { age = System.currentTimeMillis() - type.parseDateFromName(backupName).getTime(); return age > protectedBackupTypes.get(type); } catch (IllegalArgumentException e) { return false; } } return true; } MinionTaskDeleter(); void submitPathToDelete(String taskPath); void submitBackupToDelete(String backupPath, ScheduledBackupType type); synchronized void startDeletionThread(); synchronized void stopDeletionThread(); synchronized void deleteStoredItems(); boolean executeDelete(BackupToDelete backupToDelete); static boolean shouldDeleteBackup(String backupName, ScheduledBackupType type); Set<String> getTasksToDelete(); Set<BackupToDelete> getBackupsToDelete();  }