@Test public void verifyBackupVersion1DateRange() throws Exception { setUp(); List<BackupVerificationResult> backupVerificationResults = backupVerification.verifyAllBackups( BackupVersion.SNAPSHOT_BACKUP, new DateRange(backupDate + "," + backupDateEnd)); Assert.assertTrue(!backupVerificationResults.isEmpty()); Assert.assertTrue(backupVerificationResults.size() == numFakeBackups); backupVerificationResults .stream() .forEach(b -> Assert.assertEquals(Instant.EPOCH, b.snapshotInstant)); List<BackupMetadata> backupMetadata = backupStatusMgr.getLatestBackupMetadata( BackupVersion.SNAPSHOT_BACKUP, new DateRange(backupDate + "," + backupDateEnd)); Assert.assertTrue(!backupMetadata.isEmpty()); Assert.assertTrue(backupMetadata.size() == numFakeBackups); backupMetadata.stream().forEach(b -> Assert.assertNotNull(b.getLastValidated())); backupMetadata = backupStatusMgr.getLatestBackupMetadata( BackupVersion.SNAPSHOT_META_SERVICE, new DateRange(backupDate + "," + backupDateEnd)); Assert.assertTrue(!backupMetadata.isEmpty()); Assert.assertTrue(backupMetadata.size() == numFakeBackups); backupMetadata.stream().forEach(b -> Assert.assertNull(b.getLastValidated())); }
public List<BackupVerificationResult> verifyAllBackups( BackupVersion backupVersion, DateRange dateRange) throws UnsupportedTypeException, IllegalArgumentException { IMetaProxy metaProxy = getMetaProxy(backupVersion); if (metaProxy == null) { throw new UnsupportedTypeException( "BackupVersion type: " + backupVersion + " is not supported"); } if (dateRange == null) { throw new IllegalArgumentException("dateRange provided is null"); } List<BackupVerificationResult> result = new ArrayList<>(); List<BackupMetadata> metadata = backupStatusMgr.getLatestBackupMetadata(backupVersion, dateRange); if (metadata == null || metadata.isEmpty()) return result; for (BackupMetadata backupMetadata : metadata) { if (backupMetadata.getLastValidated() == null) { BackupVerificationResult backupVerificationResult = verifyBackup(metaProxy, backupMetadata); if (logger.isDebugEnabled()) logger.debug( "BackupVerification: metadata: {}, result: {}", backupMetadata, backupVerificationResult); if (backupVerificationResult.valid) { backupMetadata.setLastValidated(new Date(DateUtil.getInstant().toEpochMilli())); backupStatusMgr.update(backupMetadata); result.add(backupVerificationResult); } } } return result; }
BackupVerification { public List<BackupVerificationResult> verifyAllBackups( BackupVersion backupVersion, DateRange dateRange) throws UnsupportedTypeException, IllegalArgumentException { IMetaProxy metaProxy = getMetaProxy(backupVersion); if (metaProxy == null) { throw new UnsupportedTypeException( "BackupVersion type: " + backupVersion + " is not supported"); } if (dateRange == null) { throw new IllegalArgumentException("dateRange provided is null"); } List<BackupVerificationResult> result = new ArrayList<>(); List<BackupMetadata> metadata = backupStatusMgr.getLatestBackupMetadata(backupVersion, dateRange); if (metadata == null || metadata.isEmpty()) return result; for (BackupMetadata backupMetadata : metadata) { if (backupMetadata.getLastValidated() == null) { BackupVerificationResult backupVerificationResult = verifyBackup(metaProxy, backupMetadata); if (logger.isDebugEnabled()) logger.debug( "BackupVerification: metadata: {}, result: {}", backupMetadata, backupVerificationResult); if (backupVerificationResult.valid) { backupMetadata.setLastValidated(new Date(DateUtil.getInstant().toEpochMilli())); backupStatusMgr.update(backupMetadata); result.add(backupVerificationResult); } } } return result; } }
BackupVerification { public List<BackupVerificationResult> verifyAllBackups( BackupVersion backupVersion, DateRange dateRange) throws UnsupportedTypeException, IllegalArgumentException { IMetaProxy metaProxy = getMetaProxy(backupVersion); if (metaProxy == null) { throw new UnsupportedTypeException( "BackupVersion type: " + backupVersion + " is not supported"); } if (dateRange == null) { throw new IllegalArgumentException("dateRange provided is null"); } List<BackupVerificationResult> result = new ArrayList<>(); List<BackupMetadata> metadata = backupStatusMgr.getLatestBackupMetadata(backupVersion, dateRange); if (metadata == null || metadata.isEmpty()) return result; for (BackupMetadata backupMetadata : metadata) { if (backupMetadata.getLastValidated() == null) { BackupVerificationResult backupVerificationResult = verifyBackup(metaProxy, backupMetadata); if (logger.isDebugEnabled()) logger.debug( "BackupVerification: metadata: {}, result: {}", backupMetadata, backupVerificationResult); if (backupVerificationResult.valid) { backupMetadata.setLastValidated(new Date(DateUtil.getInstant().toEpochMilli())); backupStatusMgr.update(backupMetadata); result.add(backupVerificationResult); } } } return result; } @Inject  BackupVerification(
            @Named("v1") IMetaProxy metaV1Proxy,
            @Named("v2") IMetaProxy metaV2Proxy,
            IBackupStatusMgr backupStatusMgr,
            Provider<AbstractBackupPath> abstractBackupPathProvider); }
BackupVerification { public List<BackupVerificationResult> verifyAllBackups( BackupVersion backupVersion, DateRange dateRange) throws UnsupportedTypeException, IllegalArgumentException { IMetaProxy metaProxy = getMetaProxy(backupVersion); if (metaProxy == null) { throw new UnsupportedTypeException( "BackupVersion type: " + backupVersion + " is not supported"); } if (dateRange == null) { throw new IllegalArgumentException("dateRange provided is null"); } List<BackupVerificationResult> result = new ArrayList<>(); List<BackupMetadata> metadata = backupStatusMgr.getLatestBackupMetadata(backupVersion, dateRange); if (metadata == null || metadata.isEmpty()) return result; for (BackupMetadata backupMetadata : metadata) { if (backupMetadata.getLastValidated() == null) { BackupVerificationResult backupVerificationResult = verifyBackup(metaProxy, backupMetadata); if (logger.isDebugEnabled()) logger.debug( "BackupVerification: metadata: {}, result: {}", backupMetadata, backupVerificationResult); if (backupVerificationResult.valid) { backupMetadata.setLastValidated(new Date(DateUtil.getInstant().toEpochMilli())); backupStatusMgr.update(backupMetadata); result.add(backupVerificationResult); } } } return result; } @Inject  BackupVerification(
            @Named("v1") IMetaProxy metaV1Proxy,
            @Named("v2") IMetaProxy metaV2Proxy,
            IBackupStatusMgr backupStatusMgr,
            Provider<AbstractBackupPath> abstractBackupPathProvider); IMetaProxy getMetaProxy(BackupVersion backupVersion); Optional<BackupVerificationResult> verifyBackup(
            BackupVersion backupVersion, boolean force, DateRange dateRange); List<BackupVerificationResult> verifyAllBackups(
            BackupVersion backupVersion, DateRange dateRange); }
BackupVerification { public List<BackupVerificationResult> verifyAllBackups( BackupVersion backupVersion, DateRange dateRange) throws UnsupportedTypeException, IllegalArgumentException { IMetaProxy metaProxy = getMetaProxy(backupVersion); if (metaProxy == null) { throw new UnsupportedTypeException( "BackupVersion type: " + backupVersion + " is not supported"); } if (dateRange == null) { throw new IllegalArgumentException("dateRange provided is null"); } List<BackupVerificationResult> result = new ArrayList<>(); List<BackupMetadata> metadata = backupStatusMgr.getLatestBackupMetadata(backupVersion, dateRange); if (metadata == null || metadata.isEmpty()) return result; for (BackupMetadata backupMetadata : metadata) { if (backupMetadata.getLastValidated() == null) { BackupVerificationResult backupVerificationResult = verifyBackup(metaProxy, backupMetadata); if (logger.isDebugEnabled()) logger.debug( "BackupVerification: metadata: {}, result: {}", backupMetadata, backupVerificationResult); if (backupVerificationResult.valid) { backupMetadata.setLastValidated(new Date(DateUtil.getInstant().toEpochMilli())); backupStatusMgr.update(backupMetadata); result.add(backupVerificationResult); } } } return result; } @Inject  BackupVerification(
            @Named("v1") IMetaProxy metaV1Proxy,
            @Named("v2") IMetaProxy metaV2Proxy,
            IBackupStatusMgr backupStatusMgr,
            Provider<AbstractBackupPath> abstractBackupPathProvider); IMetaProxy getMetaProxy(BackupVersion backupVersion); Optional<BackupVerificationResult> verifyBackup(
            BackupVersion backupVersion, boolean force, DateRange dateRange); List<BackupVerificationResult> verifyAllBackups(
            BackupVersion backupVersion, DateRange dateRange);  }