@Test public void testBackupDisabled( @Mocked IConfiguration configuration, @Mocked IBackupRestoreConfig backupRestoreConfig) throws Exception { new Expectations() { { backupRestoreConfig.getSnapshotMetaServiceCronExpression(); result = "-1"; configuration.getDataFileLocation(); result = "target/data"; } }; Path dummyDataDirectoryLocation = Paths.get(configuration.getDataFileLocation()); Instant snapshotInstant = DateUtil.getInstant(); String snapshotName = snapshotMetaTask.generateSnapshotName(snapshotInstant); BackupFileUtils.generateDummyFiles( dummyDataDirectoryLocation, 2, 3, 3, AbstractBackup.SNAPSHOT_FOLDER, snapshotName, true); String snapshotV1Name = DateUtil.formatInstant(DateUtil.yyyyMMdd, snapshotInstant); BackupFileUtils.generateDummyFiles( dummyDataDirectoryLocation, 2, 3, 3, AbstractBackup.SNAPSHOT_FOLDER, snapshotV1Name, false); IService backupService = new BackupV2Service( configuration, backupRestoreConfig, scheduler, snapshotMetaTask, cassandraTunerService); backupService.scheduleService(); Assert.assertTrue(scheduler.getScheduler().getJobGroupNames().isEmpty()); Set<Path> backupPaths = AbstractBackup.getBackupDirectories(configuration, AbstractBackup.SNAPSHOT_FOLDER); for (Path backupPath : backupPaths) { Assert.assertFalse(Files.exists(Paths.get(backupPath.toString(), snapshotName))); Assert.assertTrue(Files.exists(Paths.get(backupPath.toString(), snapshotV1Name))); } }
@Override public void scheduleService() throws Exception { TaskTimer snapshotMetaTimer = SnapshotMetaTask.getTimer(configuration, backupRestoreConfig); scheduleTask(scheduler, SnapshotMetaTask.class, snapshotMetaTimer); if (snapshotMetaTimer != null) { snapshotMetaTask.uploadFiles(); scheduleTask( scheduler, BackupTTLTask.class, BackupTTLTask.getTimer(backupRestoreConfig)); scheduleTask( scheduler, BackupVerificationTask.class, BackupVerificationTask.getTimer(backupRestoreConfig)); } else { scheduler.deleteTask(BackupTTLTask.JOBNAME); scheduler.deleteTask(BackupVerificationTask.JOBNAME); } scheduleTask( scheduler, IncrementalBackup.class, IncrementalBackup.getTimer(configuration, backupRestoreConfig)); }
BackupV2Service implements IService { @Override public void scheduleService() throws Exception { TaskTimer snapshotMetaTimer = SnapshotMetaTask.getTimer(configuration, backupRestoreConfig); scheduleTask(scheduler, SnapshotMetaTask.class, snapshotMetaTimer); if (snapshotMetaTimer != null) { snapshotMetaTask.uploadFiles(); scheduleTask( scheduler, BackupTTLTask.class, BackupTTLTask.getTimer(backupRestoreConfig)); scheduleTask( scheduler, BackupVerificationTask.class, BackupVerificationTask.getTimer(backupRestoreConfig)); } else { scheduler.deleteTask(BackupTTLTask.JOBNAME); scheduler.deleteTask(BackupVerificationTask.JOBNAME); } scheduleTask( scheduler, IncrementalBackup.class, IncrementalBackup.getTimer(configuration, backupRestoreConfig)); } }
BackupV2Service implements IService { @Override public void scheduleService() throws Exception { TaskTimer snapshotMetaTimer = SnapshotMetaTask.getTimer(configuration, backupRestoreConfig); scheduleTask(scheduler, SnapshotMetaTask.class, snapshotMetaTimer); if (snapshotMetaTimer != null) { snapshotMetaTask.uploadFiles(); scheduleTask( scheduler, BackupTTLTask.class, BackupTTLTask.getTimer(backupRestoreConfig)); scheduleTask( scheduler, BackupVerificationTask.class, BackupVerificationTask.getTimer(backupRestoreConfig)); } else { scheduler.deleteTask(BackupTTLTask.JOBNAME); scheduler.deleteTask(BackupVerificationTask.JOBNAME); } scheduleTask( scheduler, IncrementalBackup.class, IncrementalBackup.getTimer(configuration, backupRestoreConfig)); } @Inject  BackupV2Service(
            IConfiguration configuration,
            IBackupRestoreConfig backupRestoreConfig,
            PriamScheduler scheduler,
            SnapshotMetaTask snapshotMetaService,
            CassandraTunerService cassandraTunerService); }
BackupV2Service implements IService { @Override public void scheduleService() throws Exception { TaskTimer snapshotMetaTimer = SnapshotMetaTask.getTimer(configuration, backupRestoreConfig); scheduleTask(scheduler, SnapshotMetaTask.class, snapshotMetaTimer); if (snapshotMetaTimer != null) { snapshotMetaTask.uploadFiles(); scheduleTask( scheduler, BackupTTLTask.class, BackupTTLTask.getTimer(backupRestoreConfig)); scheduleTask( scheduler, BackupVerificationTask.class, BackupVerificationTask.getTimer(backupRestoreConfig)); } else { scheduler.deleteTask(BackupTTLTask.JOBNAME); scheduler.deleteTask(BackupVerificationTask.JOBNAME); } scheduleTask( scheduler, IncrementalBackup.class, IncrementalBackup.getTimer(configuration, backupRestoreConfig)); } @Inject  BackupV2Service(
            IConfiguration configuration,
            IBackupRestoreConfig backupRestoreConfig,
            PriamScheduler scheduler,
            SnapshotMetaTask snapshotMetaService,
            CassandraTunerService cassandraTunerService); @Override void scheduleService(); @Override void updateServicePre(); @Override void updateServicePost(); }
BackupV2Service implements IService { @Override public void scheduleService() throws Exception { TaskTimer snapshotMetaTimer = SnapshotMetaTask.getTimer(configuration, backupRestoreConfig); scheduleTask(scheduler, SnapshotMetaTask.class, snapshotMetaTimer); if (snapshotMetaTimer != null) { snapshotMetaTask.uploadFiles(); scheduleTask( scheduler, BackupTTLTask.class, BackupTTLTask.getTimer(backupRestoreConfig)); scheduleTask( scheduler, BackupVerificationTask.class, BackupVerificationTask.getTimer(backupRestoreConfig)); } else { scheduler.deleteTask(BackupTTLTask.JOBNAME); scheduler.deleteTask(BackupVerificationTask.JOBNAME); } scheduleTask( scheduler, IncrementalBackup.class, IncrementalBackup.getTimer(configuration, backupRestoreConfig)); } @Inject  BackupV2Service(
            IConfiguration configuration,
            IBackupRestoreConfig backupRestoreConfig,
            PriamScheduler scheduler,
            SnapshotMetaTask snapshotMetaService,
            CassandraTunerService cassandraTunerService); @Override void scheduleService(); @Override void updateServicePre(); @Override void updateServicePost();  }