Revision 55458
Added by Alessia Bardi almost 5 years ago
modules/dnet-openaireplus-workflows/branches/solr75/src/main/java/eu/dnetlib/msro/openaireplus/workflows/nodes/index/SwitchIndexesJobNode.java | ||
---|---|---|
6 | 6 |
import com.googlecode.sarasvati.NodeToken; |
7 | 7 |
import eu.dnetlib.msro.rmi.MSROException; |
8 | 8 |
import eu.dnetlib.msro.workflows.nodes.SimpleJobNode; |
9 |
import org.apache.commons.httpclient.HttpStatus; |
|
9 | 10 |
import org.apache.commons.logging.Log; |
10 | 11 |
import org.apache.commons.logging.LogFactory; |
11 | 12 |
import org.apache.http.client.methods.CloseableHttpResponse; |
... | ... | |
25 | 26 |
|
26 | 27 |
private static final Log log = LogFactory.getLog(SwitchIndexesJobNode.class); |
27 | 28 |
|
28 |
@Value("dnet.openaire.index.api.cacheEvictUrl")
|
|
29 |
@Value("${dnet.openaire.index.api.cacheEvictUrl}")
|
|
29 | 30 |
private String indexApiCacheEvictUrl; |
30 | 31 |
|
31 | 32 |
@Override |
... | ... | |
34 | 35 |
log.debug("Got the searchService_ids queue: " + q.toString()); |
35 | 36 |
if (q == null) throw new MSROException("Transient param 'searchService_ids' with queue of string could not be found"); |
36 | 37 |
if (q.isEmpty()) { |
37 |
log.info("searchService_ids queue consumed, now ending cycle and evicting direct indexing api cache"); |
|
38 |
HttpGet get = new HttpGet(indexApiCacheEvictUrl); |
|
39 |
CloseableHttpClient httpclient = HttpClients.createDefault(); |
|
40 |
try(CloseableHttpResponse response = httpclient.execute(get)){ |
|
41 |
if(response.getStatusLine().getStatusCode() == 200){ |
|
42 |
return Arc.DEFAULT_ARC; |
|
38 |
log.info("searchService_ids queue consumed, now ending cycle and evicting direct indexing api cache on " + indexApiCacheEvictUrl); |
|
39 |
final HttpGet get = new HttpGet(indexApiCacheEvictUrl); |
|
40 |
|
|
41 |
try(CloseableHttpClient client = HttpClients.createDefault()) { |
|
42 |
try (CloseableHttpResponse response = client.execute(get)) { |
|
43 |
int statusCode = response.getStatusLine().getStatusCode(); |
|
44 |
log.info(String.format("GET on %s returned %s", indexApiCacheEvictUrl, statusCode)); |
|
45 |
if (statusCode == HttpStatus.SC_OK) { |
|
46 |
return Arc.DEFAULT_ARC; |
|
47 |
} else |
|
48 |
throw new MSROException("Cannot evict cache of direct indexing API at: " + indexApiCacheEvictUrl); |
|
43 | 49 |
} |
44 |
else throw new MSROException("Cannot evict cache of direct indexing API at: "+indexApiCacheEvictUrl); |
|
45 | 50 |
} |
46 |
|
|
47 | 51 |
} else { |
48 | 52 |
//we have something to do: setting the xqueryForServiceIdParam for the SwitchIndexJobNode |
49 | 53 |
String id = q.poll(); |
... | ... | |
57 | 61 |
} |
58 | 62 |
|
59 | 63 |
} |
60 |
|
|
61 | 64 |
} |
Also available in: Unified diff
Properly pass property value