Revision 51745
Added by Alessia Bardi over 6 years ago
modules/dnet-parthenos/trunk/src/main/java/eu/dnetlib/parthenos/workflows/nodes/VirtuosoParthenosIterator.java | ||
---|---|---|
106 | 106 |
|
107 | 107 |
protected String tryGetRDF(final String subjectURL, int attempt) throws URISyntaxException, InterruptedException, VirtuosoParthenosException { |
108 | 108 |
log.debug("Quering Api, remaining attempts: "+attempt); |
109 |
if (attempt <= 0) throw new VirtuosoParthenosException("Too many retries...stopping. please check virtuoso server status"); |
|
109 |
if (attempt <= 0) { |
|
110 |
errors.merge("Failed tryGetRDF", 1, Integer::sum); |
|
111 |
return null; |
|
112 |
} |
|
110 | 113 |
ResponseEntity<String> response = null; |
111 | 114 |
try { |
112 | 115 |
response = getRDF(subjectURL); |
113 | 116 |
}catch(ResourceAccessException e){ |
114 |
//request timed out --> let's return null and skip this resource
|
|
115 |
log.warn("Request timeout for "+subjectURL); |
|
116 |
errors.merge(e.getMessage(), 1, Integer::sum);
|
|
117 |
return null;
|
|
117 |
//request timed out --> sleep and try again
|
|
118 |
log.warn("Request timeout for "+subjectURL+": I'll sleep and then try again");
|
|
119 |
Thread.sleep(SLEEP_MS);
|
|
120 |
return tryGetRDF(subjectURL, --attempt);
|
|
118 | 121 |
} |
119 | 122 |
HttpStatus responseStatus = response.getStatusCode(); |
120 | 123 |
if (responseStatus.is2xxSuccessful()) { |
... | ... | |
135 | 138 |
Thread.sleep(SLEEP_MS); |
136 | 139 |
return tryGetRDF(subjectURL, --attempt); |
137 | 140 |
} else { |
138 |
throw new VirtuosoParthenosException(
|
|
139 |
"ERROR: Can't get the RDF for " + subjectURL + " " + responseStatus.value() + ": " + responseStatus.getReasonPhrase());
|
|
141 |
log.error("ERROR: Can't get the RDF for " + subjectURL + " " + responseStatus.value() + ": " + responseStatus.getReasonPhrase());
|
|
142 |
errors.merge(responseStatus.value() + ": " + responseStatus.getReasonPhrase(), 1, Integer::sum);
|
|
140 | 143 |
} |
141 | 144 |
} |
145 |
return null; |
|
142 | 146 |
} |
143 | 147 |
|
144 | 148 |
protected URI getURIForSubjectList(final String graph) throws URISyntaxException { |
Also available in: Unified diff
Re-try after sleep on request timeout