@Test public void testIsMetaFileValid() throws Exception { Instant snapshotInstant = DateUtil.getInstant(); Path metaPath = backupUtils.createMeta(getRemoteFakeFiles(), snapshotInstant); AbstractBackupPath abstractBackupPath = abstractBackupPathProvider.get(); abstractBackupPath.parseLocal(metaPath.toFile(), AbstractBackupPath.BackupFileType.META_V2); Assert.assertTrue(metaProxy.isMetaFileValid(abstractBackupPath).valid); FileUtils.deleteQuietly(metaPath.toFile()); List<String> fileToAdd = getRemoteFakeFiles(); fileToAdd.add( Paths.get( getPrefix(), AbstractBackupPath.BackupFileType.SST_V2.toString(), "1859817645000", "keyspace1", "columnfamily1", "SNAPPY", "PLAINTEXT", "file9.Data.db") .toString()); metaPath = backupUtils.createMeta(fileToAdd, snapshotInstant); Assert.assertFalse(metaProxy.isMetaFileValid(abstractBackupPath).valid); FileUtils.deleteQuietly(metaPath.toFile()); metaPath = Paths.get(configuration.getDataFileLocation(), "meta_v2_201801010000.json"); Assert.assertFalse(metaProxy.isMetaFileValid(abstractBackupPath).valid); }
@Override public BackupVerificationResult isMetaFileValid(AbstractBackupPath metaBackupPath) { MetaFileBackupValidator metaFileBackupValidator = new MetaFileBackupValidator(); BackupVerificationResult result = metaFileBackupValidator.verificationResult; result.remotePath = metaBackupPath.getRemotePath(); result.snapshotInstant = metaBackupPath.getLastModified(); Path metaFile = null; try { metaFile = downloadMetaFile(metaBackupPath); result.manifestAvailable = true; metaFileBackupValidator.readMeta(metaFile); result.valid = (result.filesInMetaOnly.isEmpty()); } catch (FileNotFoundException fne) { logger.error(fne.getLocalizedMessage()); } catch (IOException ioe) { logger.error( "IO Error while processing meta file: " + metaFile, ioe.getLocalizedMessage()); ioe.printStackTrace(); } catch (BackupRestoreException bre) { logger.error("Error while trying to download the manifest file: {}", metaBackupPath); } finally { if (metaFile != null) FileUtils.deleteQuietly(metaFile.toFile()); } return result; }
MetaV2Proxy implements IMetaProxy { @Override public BackupVerificationResult isMetaFileValid(AbstractBackupPath metaBackupPath) { MetaFileBackupValidator metaFileBackupValidator = new MetaFileBackupValidator(); BackupVerificationResult result = metaFileBackupValidator.verificationResult; result.remotePath = metaBackupPath.getRemotePath(); result.snapshotInstant = metaBackupPath.getLastModified(); Path metaFile = null; try { metaFile = downloadMetaFile(metaBackupPath); result.manifestAvailable = true; metaFileBackupValidator.readMeta(metaFile); result.valid = (result.filesInMetaOnly.isEmpty()); } catch (FileNotFoundException fne) { logger.error(fne.getLocalizedMessage()); } catch (IOException ioe) { logger.error( "IO Error while processing meta file: " + metaFile, ioe.getLocalizedMessage()); ioe.printStackTrace(); } catch (BackupRestoreException bre) { logger.error("Error while trying to download the manifest file: {}", metaBackupPath); } finally { if (metaFile != null) FileUtils.deleteQuietly(metaFile.toFile()); } return result; } }
MetaV2Proxy implements IMetaProxy { @Override public BackupVerificationResult isMetaFileValid(AbstractBackupPath metaBackupPath) { MetaFileBackupValidator metaFileBackupValidator = new MetaFileBackupValidator(); BackupVerificationResult result = metaFileBackupValidator.verificationResult; result.remotePath = metaBackupPath.getRemotePath(); result.snapshotInstant = metaBackupPath.getLastModified(); Path metaFile = null; try { metaFile = downloadMetaFile(metaBackupPath); result.manifestAvailable = true; metaFileBackupValidator.readMeta(metaFile); result.valid = (result.filesInMetaOnly.isEmpty()); } catch (FileNotFoundException fne) { logger.error(fne.getLocalizedMessage()); } catch (IOException ioe) { logger.error( "IO Error while processing meta file: " + metaFile, ioe.getLocalizedMessage()); ioe.printStackTrace(); } catch (BackupRestoreException bre) { logger.error("Error while trying to download the manifest file: {}", metaBackupPath); } finally { if (metaFile != null) FileUtils.deleteQuietly(metaFile.toFile()); } return result; } @Inject  MetaV2Proxy(
            IConfiguration configuration,
            IFileSystemContext backupFileSystemCtx,
            Provider<AbstractBackupPath> abstractBackupPathProvider); }
MetaV2Proxy implements IMetaProxy { @Override public BackupVerificationResult isMetaFileValid(AbstractBackupPath metaBackupPath) { MetaFileBackupValidator metaFileBackupValidator = new MetaFileBackupValidator(); BackupVerificationResult result = metaFileBackupValidator.verificationResult; result.remotePath = metaBackupPath.getRemotePath(); result.snapshotInstant = metaBackupPath.getLastModified(); Path metaFile = null; try { metaFile = downloadMetaFile(metaBackupPath); result.manifestAvailable = true; metaFileBackupValidator.readMeta(metaFile); result.valid = (result.filesInMetaOnly.isEmpty()); } catch (FileNotFoundException fne) { logger.error(fne.getLocalizedMessage()); } catch (IOException ioe) { logger.error( "IO Error while processing meta file: " + metaFile, ioe.getLocalizedMessage()); ioe.printStackTrace(); } catch (BackupRestoreException bre) { logger.error("Error while trying to download the manifest file: {}", metaBackupPath); } finally { if (metaFile != null) FileUtils.deleteQuietly(metaFile.toFile()); } return result; } @Inject  MetaV2Proxy(
            IConfiguration configuration,
            IFileSystemContext backupFileSystemCtx,
            Provider<AbstractBackupPath> abstractBackupPathProvider); @Override Path getLocalMetaFileDirectory(); @Override String getMetaPrefix(DateUtil.DateRange dateRange); @Override Iterator<AbstractBackupPath> getIncrementals(DateUtil.DateRange dateRange); @Override List<AbstractBackupPath> findMetaFiles(DateUtil.DateRange dateRange); @Override Path downloadMetaFile(AbstractBackupPath meta); @Override void cleanupOldMetaFiles(); @Override List<String> getSSTFilesFromMeta(Path localMetaPath); @Override BackupVerificationResult isMetaFileValid(AbstractBackupPath metaBackupPath); }
MetaV2Proxy implements IMetaProxy { @Override public BackupVerificationResult isMetaFileValid(AbstractBackupPath metaBackupPath) { MetaFileBackupValidator metaFileBackupValidator = new MetaFileBackupValidator(); BackupVerificationResult result = metaFileBackupValidator.verificationResult; result.remotePath = metaBackupPath.getRemotePath(); result.snapshotInstant = metaBackupPath.getLastModified(); Path metaFile = null; try { metaFile = downloadMetaFile(metaBackupPath); result.manifestAvailable = true; metaFileBackupValidator.readMeta(metaFile); result.valid = (result.filesInMetaOnly.isEmpty()); } catch (FileNotFoundException fne) { logger.error(fne.getLocalizedMessage()); } catch (IOException ioe) { logger.error( "IO Error while processing meta file: " + metaFile, ioe.getLocalizedMessage()); ioe.printStackTrace(); } catch (BackupRestoreException bre) { logger.error("Error while trying to download the manifest file: {}", metaBackupPath); } finally { if (metaFile != null) FileUtils.deleteQuietly(metaFile.toFile()); } return result; } @Inject  MetaV2Proxy(
            IConfiguration configuration,
            IFileSystemContext backupFileSystemCtx,
            Provider<AbstractBackupPath> abstractBackupPathProvider); @Override Path getLocalMetaFileDirectory(); @Override String getMetaPrefix(DateUtil.DateRange dateRange); @Override Iterator<AbstractBackupPath> getIncrementals(DateUtil.DateRange dateRange); @Override List<AbstractBackupPath> findMetaFiles(DateUtil.DateRange dateRange); @Override Path downloadMetaFile(AbstractBackupPath meta); @Override void cleanupOldMetaFiles(); @Override List<String> getSSTFilesFromMeta(Path localMetaPath); @Override BackupVerificationResult isMetaFileValid(AbstractBackupPath metaBackupPath);  }