Source:
protected void processColumnFamily(final String keyspace, final String columnFamily, final File backupDir) throws Exception { File snapshotDir = getValidSnapshot(backupDir, snapshotName); if (snapshotDir == null) { logger.warn("{} folder does not contain snapshots", backupDir, snapshotName); return; } logger.debug("Scanning for all SSTables in: {}", snapshotDir.getAbsolutePath()); Map<String, List<FileUploadResult>> filePrefixToFileMap = new HashMap<>(); Collection<File> files = FileUtils.listFiles(snapshotDir, FileFilterUtils.fileFileFilter(), null); files.stream().filter(file -> file.exists()).filter(file -> file.isFile()).forEach(file -> { try { String prefix = PrefixGenerator.getSSTFileBase(file.getName()); if (prefix == null && file.getName().equalsIgnoreCase(CASSANDRA_MANIFEST_FILE)) prefix = "manifest"; if (prefix == null) logger.error("Unknown file type with no SSTFileBase found: ", file.getAbsolutePath()); FileUploadResult fileUploadResult = FileUploadResult.getFileUploadResult(keyspace, columnFamily, file); filePrefixToFileMap.putIfAbsent(prefix, new ArrayList<>()); filePrefixToFileMap.get(prefix).add(fileUploadResult); } catch (Exception e) { logger.error("Internal error while trying to generate FileUploadResult and/or reading FileAttributes for file: " + file.getAbsolutePath(), e); } }); ColumnfamilyResult columnfamilyResult = convertToColumnFamilyResult(keyspace, columnFamily, filePrefixToFileMap); filePrefixToFileMap.clear(); logger.debug("Starting the processing of KS: {}, CF: {}, No.of SSTables: {}", columnfamilyResult.getKeyspaceName(), columnfamilyResult.getColumnfamilyName(), columnfamilyResult.getSstables().size()); FileUtils.cleanDirectory(snapshotDir); FileUtils.deleteDirectory(snapshotDir); dataStep.addColumnfamilyResult(columnfamilyResult); logger.debug("Finished processing KS: {}, CF: {}", columnfamilyResult.getKeyspaceName(), columnfamilyResult.getColumnfamilyName()); }

Target:
protected void processColumnFamily(final String keyspace, final String columnFamily, final File backupDir) throws Exception { File snapshotDir = getValidSnapshot(backupDir, snapshotName); if (snapshotDir == null) { logger.warn("{} folder does not contain snapshots", backupDir, snapshotName); return; } logger.debug("Scanning for all SSTables in: {}", snapshotDir.getAbsolutePath()); Map<String, List<FileUploadResult>> filePrefixToFileMap = new HashMap<>(); Collection<File> files = FileUtils.listFiles(snapshotDir, FileFilterUtils.fileFileFilter(), null); for (File file: files){ if (!file.exists()) continue; try { String prefix = PrefixGenerator.getSSTFileBase(file.getName()); if (prefix == null && file.getName().equalsIgnoreCase(CASSANDRA_MANIFEST_FILE)) prefix = "manifest"; if (prefix == null) { logger.error("Unknown file type with no SSTFileBase found: ", file.getAbsolutePath()); return; } FileUploadResult fileUploadResult = FileUploadResult.getFileUploadResult(keyspace, columnFamily, file); filePrefixToFileMap.putIfAbsent(prefix, new ArrayList<>()); filePrefixToFileMap.get(prefix).add(fileUploadResult); } catch (Exception e) { logger.error("Internal error while trying to generate FileUploadResult and/or reading FileAttributes for file: " + file.getAbsolutePath(), e); throw e; } } ColumnfamilyResult columnfamilyResult = convertToColumnFamilyResult(keyspace, columnFamily, filePrefixToFileMap); filePrefixToFileMap.clear(); logger.debug("Starting the processing of KS: {}, CF: {}, No.of SSTables: {}", columnfamilyResult.getKeyspaceName(), columnfamilyResult.getColumnfamilyName(), columnfamilyResult.getSstables().size()); FileUtils.cleanDirectory(snapshotDir); FileUtils.deleteDirectory(snapshotDir); dataStep.addColumnfamilyResult(columnfamilyResult); logger.debug("Finished processing KS: {}, CF: {}", columnfamilyResult.getKeyspaceName(), columnfamilyResult.getColumnfamilyName()); }