AbstractFileSystem implements IBackupFileSystem, EventGenerator<BackupEvent> { @Override public void downloadFile(final Path remotePath, final Path localPath, final int retry) throws BackupRestoreException { if (remotePath == null || localPath == null) return; localPath.toFile().getParentFile().mkdirs(); logger.info("Downloading file: {} to location: {}", remotePath, localPath); try { new BoundedExponentialRetryCallable<Void>(500, 10000, retry) { @Override public Void retriableCall() throws Exception { downloadFileImpl(remotePath, localPath); return null; } }.call(); backupMetrics.recordDownloadRate(getFileSize(remotePath)); backupMetrics.incrementValidDownloads(); logger.info("Successfully downloaded file: {} to location: {}", remotePath, localPath); } catch (Exception e) { backupMetrics.incrementInvalidDownloads(); logger.error("Error while downloading file: {} to location: {}", remotePath, localPath); throw new BackupRestoreException(e.getMessage()); } } @Inject  AbstractFileSystem(
            IConfiguration configuration,
            BackupMetrics backupMetrics,
            BackupNotificationMgr backupNotificationMgr,
            Provider<AbstractBackupPath> pathProvider); @Override Future<Path> asyncDownloadFile(
            final Path remotePath, final Path localPath, final int retry); @Override void downloadFile(final Path remotePath, final Path localPath, final int retry); @Override Future<Path> asyncUploadFile(
            final Path localPath,
            final Path remotePath,
            final AbstractBackupPath path,
            final int retry,
            final boolean deleteAfterSuccessfulUpload); @Override void uploadFile(
            final Path localPath,
            final Path remotePath,
            final AbstractBackupPath path,
            final int retry,
            final boolean deleteAfterSuccessfulUpload); @Override boolean checkObjectExists(Path remotePath); @Override void deleteRemoteFiles(List<Path> remotePaths); @Override String getShard(); @Override Path getPrefix(); @Override Iterator<AbstractBackupPath> listPrefixes(Date date); @Override Iterator<AbstractBackupPath> list(String path, Date start, Date till); @Override final void addObserver(EventObserver<BackupEvent> observer); @Override void removeObserver(EventObserver<BackupEvent> observer); @Override void notifyEventStart(BackupEvent event); @Override void notifyEventSuccess(BackupEvent event); @Override void notifyEventFailure(BackupEvent event); @Override void notifyEventStop(BackupEvent event); @Override int getUploadTasksQueued(); @Override int getDownloadTasksQueued(); @Override void clearCache();  }
@Test public void testFailedRetriesDownload() { try { failureFileSystem.downloadFile(Paths.get(""), null, 2); } catch (BackupRestoreException e) { Assert.assertEquals(1, (int) backupMetrics.getInvalidDownloads().count()); } }
@Test public void testDownload() throws Exception { myFileSystem.downloadFile(Paths.get(""), Paths.get(configuration.getDataFileLocation()), 2); Assert.assertEquals(1, (int) backupMetrics.getValidDownloads().actualCount()); }