Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harvest 205: ignore LDD if fails all retries for rest of running instance #109

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ private void updateLdd(String uri, String prefix) throws Exception

try
{
fileDownloader.download(jsonUrl, lddFile);
lddLoader.load(lddFile, schemaFileName, prefix);
if (fileDownloader.download(jsonUrl, lddFile)) {
lddLoader.load(lddFile, schemaFileName, prefix);
}
}
catch(Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;

import java.util.ArrayList;
import javax.net.ssl.SSLContext;

import org.apache.http.HttpEntity;
Expand Down Expand Up @@ -37,6 +37,7 @@
*/
public class FileDownloader
{
final private static ArrayList<String> ignore = new ArrayList<String>();
private Logger log;
private int numRetries = 3;

Expand All @@ -62,17 +63,16 @@ public FileDownloader(boolean sslTrustAll) throws Exception
* @param toFile Save to this file
* @throws Exception an exception
*/
public void download(String fromUrl, File toFile) throws Exception
public boolean download(String fromUrl, File toFile) throws Exception
{
int count = 0;

while(true)
while(!ignore.contains(fromUrl))
{
try
{
count++;
downloadOnce(fromUrl, toFile);
return;
}
catch(Exception ex)
{
Expand All @@ -84,10 +84,12 @@ public void download(String fromUrl, File toFile) throws Exception
}
else
{
throw new Exception("Could not download " + fromUrl);
ignore.add(fromUrl);
throw new Exception("Could not download " + fromUrl + " and will not try again in this running instance.");
}
}
}
return ignore.contains(fromUrl);
}


Expand Down