@Test public void verifyBackupVersion1() throws Exception { setUp(); Optional<BackupVerificationResult> backupVerificationResultOptinal = backupVerification.verifyBackup( BackupVersion.SNAPSHOT_BACKUP, false, new DateRange(backupDate + "," + backupDate)); Assert.assertTrue(backupVerificationResultOptinal.isPresent()); Assert.assertEquals(Instant.EPOCH, backupVerificationResultOptinal.get().snapshotInstant); Optional<BackupMetadata> backupMetadata = backupStatusMgr .getLatestBackupMetadata( BackupVersion.SNAPSHOT_BACKUP, new DateRange(backupDate + "," + backupDate)) .stream() .findFirst(); Assert.assertTrue(backupMetadata.isPresent()); Assert.assertNotNull(backupMetadata.get().getLastValidated()); backupMetadata = backupStatusMgr .getLatestBackupMetadata( BackupVersion.SNAPSHOT_META_SERVICE, new DateRange(backupDate + "," + backupDate)) .stream() .findFirst(); Assert.assertTrue(backupMetadata.isPresent()); Assert.assertNull(backupMetadata.get().getLastValidated()); }
public Optional<BackupVerificationResult> verifyBackup( BackupVersion backupVersion, boolean force, 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<BackupMetadata> metadata = backupStatusMgr.getLatestBackupMetadata(backupVersion, dateRange); if (metadata == null || metadata.isEmpty()) return Optional.empty(); for (BackupMetadata backupMetadata : metadata) { if (backupMetadata.getLastValidated() != null && !force) { BackupVerificationResult result = new BackupVerificationResult(); result.valid = true; result.manifestAvailable = true; result.snapshotInstant = backupMetadata.getStart().toInstant(); Path snapshotLocation = Paths.get(backupMetadata.getSnapshotLocation()); result.remotePath = snapshotLocation.subpath(1, snapshotLocation.getNameCount()).toString(); return Optional.of(result); } 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); return Optional.of(backupVerificationResult); } } return Optional.empty(); }
BackupVerification { public Optional<BackupVerificationResult> verifyBackup( BackupVersion backupVersion, boolean force, 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<BackupMetadata> metadata = backupStatusMgr.getLatestBackupMetadata(backupVersion, dateRange); if (metadata == null || metadata.isEmpty()) return Optional.empty(); for (BackupMetadata backupMetadata : metadata) { if (backupMetadata.getLastValidated() != null && !force) { BackupVerificationResult result = new BackupVerificationResult(); result.valid = true; result.manifestAvailable = true; result.snapshotInstant = backupMetadata.getStart().toInstant(); Path snapshotLocation = Paths.get(backupMetadata.getSnapshotLocation()); result.remotePath = snapshotLocation.subpath(1, snapshotLocation.getNameCount()).toString(); return Optional.of(result); } 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); return Optional.of(backupVerificationResult); } } return Optional.empty(); } }
BackupVerification { public Optional<BackupVerificationResult> verifyBackup( BackupVersion backupVersion, boolean force, 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<BackupMetadata> metadata = backupStatusMgr.getLatestBackupMetadata(backupVersion, dateRange); if (metadata == null || metadata.isEmpty()) return Optional.empty(); for (BackupMetadata backupMetadata : metadata) { if (backupMetadata.getLastValidated() != null && !force) { BackupVerificationResult result = new BackupVerificationResult(); result.valid = true; result.manifestAvailable = true; result.snapshotInstant = backupMetadata.getStart().toInstant(); Path snapshotLocation = Paths.get(backupMetadata.getSnapshotLocation()); result.remotePath = snapshotLocation.subpath(1, snapshotLocation.getNameCount()).toString(); return Optional.of(result); } 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); return Optional.of(backupVerificationResult); } } return Optional.empty(); } @Inject  BackupVerification(
            @Named("v1") IMetaProxy metaV1Proxy,
            @Named("v2") IMetaProxy metaV2Proxy,
            IBackupStatusMgr backupStatusMgr,
            Provider<AbstractBackupPath> abstractBackupPathProvider); }
BackupVerification { public Optional<BackupVerificationResult> verifyBackup( BackupVersion backupVersion, boolean force, 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<BackupMetadata> metadata = backupStatusMgr.getLatestBackupMetadata(backupVersion, dateRange); if (metadata == null || metadata.isEmpty()) return Optional.empty(); for (BackupMetadata backupMetadata : metadata) { if (backupMetadata.getLastValidated() != null && !force) { BackupVerificationResult result = new BackupVerificationResult(); result.valid = true; result.manifestAvailable = true; result.snapshotInstant = backupMetadata.getStart().toInstant(); Path snapshotLocation = Paths.get(backupMetadata.getSnapshotLocation()); result.remotePath = snapshotLocation.subpath(1, snapshotLocation.getNameCount()).toString(); return Optional.of(result); } 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); return Optional.of(backupVerificationResult); } } return Optional.empty(); } @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 Optional<BackupVerificationResult> verifyBackup( BackupVersion backupVersion, boolean force, 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<BackupMetadata> metadata = backupStatusMgr.getLatestBackupMetadata(backupVersion, dateRange); if (metadata == null || metadata.isEmpty()) return Optional.empty(); for (BackupMetadata backupMetadata : metadata) { if (backupMetadata.getLastValidated() != null && !force) { BackupVerificationResult result = new BackupVerificationResult(); result.valid = true; result.manifestAvailable = true; result.snapshotInstant = backupMetadata.getStart().toInstant(); Path snapshotLocation = Paths.get(backupMetadata.getSnapshotLocation()); result.remotePath = snapshotLocation.subpath(1, snapshotLocation.getNameCount()).toString(); return Optional.of(result); } 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); return Optional.of(backupVerificationResult); } } return Optional.empty(); } @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);  }