final File downloadDir = new File(config.getStringProperty(BackFillerConfig.DOWNLOAD_DIR));
downloadDir.mkdirs();
// connect the download service to the file manager.
FileManager fileManager = new CloudFilesManager(USER, KEY, PROVIDER, ZONE, CONTAINER, config.getIntegerProperty(BackFillerConfig.BATCH_SIZE));
DownloadService downloadService = new DownloadService(downloadDir);
downloadService.setFileManager(fileManager);
// delete any temp files before starting.
for (File tmp : downloadDir.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith(".json.gz.tmp");
}
})) {
if (!tmp.delete()) {
log.error("Could not delete a temp file %s", tmp.getName());
System.exit(-1);
}
}
try {
downloadService.start();
} catch (IOException ex) {
ex.printStackTrace();
System.exit(-1);
}
}