Revision 48399
Added by Claudio Atzori almost 7 years ago
DatasourceDao.java | ||
---|---|---|
4 | 4 |
import java.util.Queue; |
5 | 5 |
import java.util.concurrent.*; |
6 | 6 |
|
7 |
import javax.annotation.PostConstruct; |
|
8 |
|
|
7 | 9 |
import com.google.common.collect.Lists; |
8 | 10 |
import com.google.common.util.concurrent.*; |
11 |
import eu.dnetlib.OpenaireExporterConfig; |
|
9 | 12 |
import eu.dnetlib.openaire.exporter.datasource.ApiException; |
10 | 13 |
import eu.dnetlib.openaire.exporter.datasource.clients.utils.IndexDsInfo; |
11 | 14 |
import eu.dnetlib.openaire.exporter.datasource.clients.utils.IndexRecordsInfo; |
... | ... | |
20 | 23 |
import org.apache.commons.logging.LogFactory; |
21 | 24 |
import org.apache.http.HttpStatus; |
22 | 25 |
import org.springframework.beans.factory.annotation.Autowired; |
23 |
import org.springframework.beans.factory.annotation.Value; |
|
24 | 26 |
import org.springframework.data.domain.Pageable; |
25 | 27 |
import org.springframework.data.domain.Slice; |
26 | 28 |
import org.springframework.stereotype.Component; |
... | ... | |
36 | 38 |
private static final Log log = LogFactory.getLog(DatasourceDao.class); |
37 | 39 |
|
38 | 40 |
@Autowired |
41 |
private OpenaireExporterConfig config; |
|
42 |
|
|
43 |
@Autowired |
|
39 | 44 |
private MongoLoggerClient mongoLoggerClient; |
40 | 45 |
|
41 | 46 |
@Autowired |
... | ... | |
70 | 75 |
|
71 | 76 |
private ListeningExecutorService service; |
72 | 77 |
|
73 |
private final static int WORKERS = 100; |
|
74 |
|
|
75 |
@Value("${openaire.datasource.publisher.timeout}") |
|
76 |
private int timeout = 10; |
|
77 |
|
|
78 |
public DatasourceDao() { |
|
78 |
@PostConstruct |
|
79 |
public void init() { |
|
79 | 80 |
service = MoreExecutors.listeningDecorator( |
80 |
new ScheduledThreadPoolExecutor(WORKERS,
|
|
81 |
new ScheduledThreadPoolExecutor(config.getRequestWorkers(),
|
|
81 | 82 |
new ThreadFactoryBuilder().setNameFormat("datasource-info-retriever-%d").build())); |
82 | 83 |
} |
83 | 84 |
|
... | ... | |
99 | 100 |
dsRepository.findByOfficialnameContainingOrEnglishnameContainingAllIgnoreCase(name, name, pageable); |
100 | 101 |
c.addCallback(getSearchCallback(outerLatch, errors, datasourceResponse)); |
101 | 102 |
|
102 |
waitLatch(outerLatch, errors, timeout);
|
|
103 |
waitLatch(outerLatch, errors, config.getRequestTimeout());
|
|
103 | 104 |
|
104 | 105 |
return datasourceResponse; |
105 | 106 |
} |
... | ... | |
114 | 115 |
log.debug(String.format("search ds by country '%s'", country)); |
115 | 116 |
//dsRepository.findByOrganizationsCountryIgnoreCase(country, pageable).addCallback(getSearchCallback(outerLatch, errors, datasourceResponse)); |
116 | 117 |
|
117 |
waitLatch(outerLatch, errors, timeout);
|
|
118 |
waitLatch(outerLatch, errors, config.getRequestTimeout());
|
|
118 | 119 |
|
119 | 120 |
return datasourceResponse; |
120 | 121 |
} |
... | ... | |
128 | 129 |
log.debug(String.format("search ds by email '%s'", email)); |
129 | 130 |
dsRepository.findByContactemailContainingAllIgnoreCase(email, pageable).addCallback(getSearchCallback(outerLatch, errors, datasourceResponse)); |
130 | 131 |
|
131 |
waitLatch(outerLatch, errors, timeout);
|
|
132 |
waitLatch(outerLatch, errors, config.getRequestTimeout());
|
|
132 | 133 |
|
133 | 134 |
return datasourceResponse; |
134 | 135 |
} |
... | ... | |
184 | 185 |
|
185 | 186 |
getIndexDsInfo(dsId, outerLatch, errors, datasourceResponse); |
186 | 187 |
|
187 |
waitLatch(outerLatch, errors, timeout);
|
|
188 |
waitLatch(outerLatch, errors, config.getRequestTimeout());
|
|
188 | 189 |
|
189 | 190 |
/* |
190 | 191 |
if (!errors.isEmpty()) { |
... | ... | |
322 | 323 |
innerLatch.countDown(); |
323 | 324 |
} |
324 | 325 |
}); |
325 |
waitLatch(innerLatch, errors, timeout);
|
|
326 |
waitLatch(innerLatch, errors, config.getRequestTimeout());
|
|
326 | 327 |
|
327 | 328 |
outerLatch.countDown(); |
328 | 329 |
} |
Also available in: Unified diff
refactor of the application properties