@Test public void testBackupDisabled( @Mocked IConfiguration configuration, @Mocked IBackupRestoreConfig backupRestoreConfig) throws Exception { new Expectations() { { configuration.getBackupCronExpression(); result = "-1"; configuration.getDataFileLocation(); result = "target/data"; } }; Path dummyDataDirectoryLocation = Paths.get(configuration.getDataFileLocation()); Instant snapshotInstant = DateUtil.getInstant(); String snapshotV1Name = DateUtil.formatInstant(DateUtil.yyyyMMdd, snapshotInstant); BackupFileUtils.generateDummyFiles( dummyDataDirectoryLocation, 2, 3, 3, AbstractBackup.SNAPSHOT_FOLDER, snapshotV1Name, true); String snapshotName = "meta_v2_" + snapshotV1Name; BackupFileUtils.generateDummyFiles( dummyDataDirectoryLocation, 2, 3, 3, AbstractBackup.SNAPSHOT_FOLDER, snapshotName, false); IService backupService = new BackupService( configuration, backupRestoreConfig, scheduler, cassandraTunerService); backupService.scheduleService(); Assert.assertEquals(0, scheduler.getScheduler().getJobKeys(null).size()); Set<Path> backupPaths = AbstractBackup.getBackupDirectories(configuration, AbstractBackup.SNAPSHOT_FOLDER); for (Path backupPath : backupPaths) { Assert.assertTrue(Files.exists(Paths.get(backupPath.toString(), snapshotName))); Assert.assertFalse(Files.exists(Paths.get(backupPath.toString(), snapshotV1Name))); } }
@Override public void scheduleService() throws Exception { TaskTimer snapshotTimer = SnapshotBackup.getTimer(config); scheduleTask(scheduler, SnapshotBackup.class, snapshotTimer); if (snapshotTimer != null) { scheduleTask(scheduler, UpdateCleanupPolicy.class, UpdateCleanupPolicy.getTimer()); scheduleTask( scheduler, CommitLogBackupTask.class, CommitLogBackupTask.getTimer(config)); } scheduleTask( scheduler, IncrementalBackup.class, IncrementalBackup.getTimer(config, backupRestoreConfig)); }
BackupService implements IService { @Override public void scheduleService() throws Exception { TaskTimer snapshotTimer = SnapshotBackup.getTimer(config); scheduleTask(scheduler, SnapshotBackup.class, snapshotTimer); if (snapshotTimer != null) { scheduleTask(scheduler, UpdateCleanupPolicy.class, UpdateCleanupPolicy.getTimer()); scheduleTask( scheduler, CommitLogBackupTask.class, CommitLogBackupTask.getTimer(config)); } scheduleTask( scheduler, IncrementalBackup.class, IncrementalBackup.getTimer(config, backupRestoreConfig)); } }
BackupService implements IService { @Override public void scheduleService() throws Exception { TaskTimer snapshotTimer = SnapshotBackup.getTimer(config); scheduleTask(scheduler, SnapshotBackup.class, snapshotTimer); if (snapshotTimer != null) { scheduleTask(scheduler, UpdateCleanupPolicy.class, UpdateCleanupPolicy.getTimer()); scheduleTask( scheduler, CommitLogBackupTask.class, CommitLogBackupTask.getTimer(config)); } scheduleTask( scheduler, IncrementalBackup.class, IncrementalBackup.getTimer(config, backupRestoreConfig)); } @Inject  BackupService(
            IConfiguration config,
            IBackupRestoreConfig backupRestoreConfig,
            PriamScheduler priamScheduler,
            CassandraTunerService cassandraTunerService); }
BackupService implements IService { @Override public void scheduleService() throws Exception { TaskTimer snapshotTimer = SnapshotBackup.getTimer(config); scheduleTask(scheduler, SnapshotBackup.class, snapshotTimer); if (snapshotTimer != null) { scheduleTask(scheduler, UpdateCleanupPolicy.class, UpdateCleanupPolicy.getTimer()); scheduleTask( scheduler, CommitLogBackupTask.class, CommitLogBackupTask.getTimer(config)); } scheduleTask( scheduler, IncrementalBackup.class, IncrementalBackup.getTimer(config, backupRestoreConfig)); } @Inject  BackupService(
            IConfiguration config,
            IBackupRestoreConfig backupRestoreConfig,
            PriamScheduler priamScheduler,
            CassandraTunerService cassandraTunerService); @Override void scheduleService(); @Override void updateServicePre(); @Override void updateServicePost(); }
BackupService implements IService { @Override public void scheduleService() throws Exception { TaskTimer snapshotTimer = SnapshotBackup.getTimer(config); scheduleTask(scheduler, SnapshotBackup.class, snapshotTimer); if (snapshotTimer != null) { scheduleTask(scheduler, UpdateCleanupPolicy.class, UpdateCleanupPolicy.getTimer()); scheduleTask( scheduler, CommitLogBackupTask.class, CommitLogBackupTask.getTimer(config)); } scheduleTask( scheduler, IncrementalBackup.class, IncrementalBackup.getTimer(config, backupRestoreConfig)); } @Inject  BackupService(
            IConfiguration config,
            IBackupRestoreConfig backupRestoreConfig,
            PriamScheduler priamScheduler,
            CassandraTunerService cassandraTunerService); @Override void scheduleService(); @Override void updateServicePre(); @Override void updateServicePost();  }