added shub retry on InputManager class, getLocalFile method

This commit is contained in:
roberto cirillo 2020-05-12 15:23:26 +02:00
parent 34083f1357
commit c573360e2a
3 changed files with 31 additions and 3 deletions

16
changelog.md Normal file
View File

@ -0,0 +1,16 @@
# Changelog
All notable changes to this project will be documented in this file.
this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [1.6.0] - 2020-05-12
### Added
- added storagehub retry in InputsManager class, getLocalFile method
### Changed
-

View File

@ -9,7 +9,7 @@
</parent>
<groupId>org.gcube.dataanalysis</groupId>
<artifactId>dataminer</artifactId>
<version>1.5.9-SNAPSHOT</version>
<version>1.6.0-SNAPSHOT</version>
<name>dataminer</name>
<description>An e-Infrastructure service providing state-of-the art DataMining algorithms and ecological modelling approaches under the Web Processing Service (WPS) standard.</description>

View File

@ -5,6 +5,7 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
@ -43,6 +44,8 @@ public class InputsManager {
private static final Logger LOGGER = LoggerFactory.getLogger(InputsManager.class);
private static final long SHUB_RETRY_MILLIS = 2000;
LinkedHashMap<String, Object> inputs;
List<String> generatedTables;
List<File> generatedFiles;
@ -242,8 +245,17 @@ public class InputsManager {
InputStream is = null;
HttpURLConnection urlConnection = null;
URL url = new URL(subfilelink);
urlConnection = (HttpURLConnection) url.openConnection();
is = new BufferedInputStream(urlConnection.getInputStream());
try {
urlConnection = (HttpURLConnection) url.openConnection();
is = new BufferedInputStream(urlConnection.getInputStream());
}catch(IOException e) {
LOGGER.warn("download from storagehub failed. Retry ongoing...");
LOGGER.debug("waiting "+SHUB_RETRY_MILLIS+" millis ");
Thread.sleep(SHUB_RETRY_MILLIS);
urlConnection = (HttpURLConnection) url.openConnection();
is = new BufferedInputStream(urlConnection.getInputStream());
LOGGER.debug(" retry success ");
}
// retrieve payload: for test purpose only
String fileNameTemp = inputNameFromHttpHeader(subfilelink);