i have a Programm that is:
- Downloading files from an Ftp Server to a local directory.
- The parsed file contents will be written to a database and to another Ftp-server. The download/transfer can take while(in total 50GB of files transfered/downloaded).
If the Programm completely fails. I would have to restart the whole transfer/downloading process. So i added Error-Handling which enables me to continue on the point where my Programm was interrupted. What i dont like is the way my architecture looks like:
main(){
switch (whereToContinueProgramm) {
case "resumeDownloading":
resumeDownloadingFiles(targetDirectory.getPath().toString());
xmlFiles = Arrays.asList(targetDirectory.listFiles());
doImport(xmlFiles);
break;
case "resumeImport":
// All Files have already been downloaded so skip the download process
xmlFiles = Arrays.asList(targetDirectory.listFiles());
doImport(xmlFiles);
default:
//regular processing, start programm normally
downloadFiles(targetDirectory.getPath().toString());
xmlFiles = Arrays.asList(targetDirectory.listFiles());
doImport(xmlFiles);
break;
}
}
in the near feature there will be added smth. like:
switch (import_mode) {
case "daily":
//code you have seen above,logic of downloadFiles will be different.
switch (whereToContinueProgramm);
case "initial":
//code you have seen above
switch (whereToContinueProgramm);
}
Do you have any advices how to improve this architecture/design of this problem ?
Aucun commentaire:
Enregistrer un commentaire