Revision 56601
Added by Katerina Iatropoulou almost 5 years ago
SearchServiceImpl.java | ||
---|---|---|
24 | 24 |
import gr.uoa.di.driver.enabling.resultset.ResultSet; |
25 | 25 |
import gr.uoa.di.driver.enabling.resultset.ResultSetFactory; |
26 | 26 |
import gr.uoa.di.driver.util.ServiceLocator; |
27 |
import io.micrometer.core.instrument.Timer; |
|
28 |
import io.micrometer.prometheus.PrometheusMeterRegistry; |
|
27 | 29 |
import org.apache.log4j.Logger; |
28 | 30 |
import org.apache.solr.client.solrj.SolrServerException; |
31 |
import org.springframework.beans.factory.annotation.Autowired; |
|
29 | 32 |
import org.w3c.dom.Document; |
30 | 33 |
import org.w3c.dom.Node; |
31 | 34 |
import org.xml.sax.InputSource; |
... | ... | |
66 | 69 |
|
67 | 70 |
private SearchServiceBlackboardHandler blackboardNotificationHandler = null; |
68 | 71 |
|
72 |
@Autowired |
|
73 |
private PrometheusMeterRegistry registry; |
|
74 |
|
|
75 |
|
|
69 | 76 |
//private CQLParser cqlParser = null; |
70 | 77 |
@Override |
71 | 78 |
public void init() { |
... | ... | |
206 | 213 |
return formattedSearchResult; |
207 | 214 |
} |
208 | 215 |
|
216 |
|
|
209 | 217 |
public SearchResult newSearch (String text, String locale, List<String> refinefields, List<String> fieldQueries, |
210 | 218 |
int from, int to, String format, Transformer transformer, Transformer oldRefineTransformer, |
211 | 219 |
boolean oldPaging) throws SearchServiceException { |
212 | 220 |
logger.info("newSearch > from: " + from + " to:" + to); |
213 | 221 |
long startTime = System.nanoTime(); |
214 | 222 |
|
223 |
Timer.Sample timer = Timer.start(registry); |
|
224 |
|
|
215 | 225 |
IndexService index = getIndexLocator().getService(); |
216 | 226 |
|
217 | 227 |
EPR epr = null; |
... | ... | |
242 | 252 |
|
243 | 253 |
rs = rsFactory.createResultSet(epr); |
244 | 254 |
|
255 |
|
|
245 | 256 |
Map<String, List<String>> list = null; |
246 | 257 |
if (oldPaging) { |
247 | 258 |
list = ((SolrResultSet)rs).newGet(from-1, to, format, transformer, oldRefineTransformer); |
... | ... | |
250 | 261 |
list = ((SolrResultSet)rs).newGet(from, to, format, transformer, oldRefineTransformer); |
251 | 262 |
} |
252 | 263 |
|
253 |
|
|
254 | 264 |
searchResults = list.get("search"); |
255 | 265 |
browseResults = list.get("refine"); |
256 | 266 |
|
... | ... | |
258 | 268 |
logger.error("Error getting refine results.", ise); |
259 | 269 |
throw new SearchServiceException("Error getting refine results.", ise); |
260 | 270 |
|
271 |
} finally { |
|
272 |
timer.stop(registry.timer("search.server.response.duration")); |
|
273 |
/* |
|
274 |
histogram.observe(System.currentTimeMillis()-startTime); |
|
275 |
*/ |
|
261 | 276 |
} |
262 | 277 |
|
263 | 278 |
long estimatedTime = System.nanoTime() - startTime; |
279 |
|
|
264 | 280 |
logger.debug("Search time " + estimatedTime/1000000 + " milliseconds for query " + query + |
265 | 281 |
" and fields " + fieldQueries + " and refine " + refinefields + " from: "+ from + " and size " + to); |
266 | 282 |
|
267 | 283 |
//logger.info("Returned results for NEW search query '" + query + "' and fields " + fieldQueries + " and refine " + refinefields);; |
268 | 284 |
rs.close(); |
285 |
|
|
269 | 286 |
return new SearchResult(query, Locale.getDefault().toString(), rs.size(), from, to, searchResults, browseResults, refinefields); |
270 | 287 |
} |
288 |
|
|
271 | 289 |
public void cursorSearch(String text, List<String> refinefields, List<String> fieldQueries, |
272 |
String format, Transformer transformer, OutputStream os) throws SearchServiceException {
|
|
290 |
String format, Transformer transformer, OutputStream os) throws SearchServiceException { |
|
273 | 291 |
|
274 | 292 |
long startTime = System.nanoTime(); |
275 | 293 |
|
276 | 294 |
IndexService index = getIndexLocator().getService(); |
277 | 295 |
|
296 |
|
|
278 | 297 |
EPR epr = null; |
279 | 298 |
ResultSet<String> rs = null; |
280 | 299 |
|
... | ... | |
388 | 407 |
//If we want to keep this I need to redesign. |
389 | 408 |
|
390 | 409 |
public SearchResult newSearchWithoutFieldQueries (String text, String locale, List<String> refinefields, List<String> fieldQueries, |
391 |
int from, int to, String format, Transformer transformer, Transformer oldRefineTransformer, |
|
392 |
boolean oldPaging) throws SearchServiceException { |
|
410 |
int from, int to, String format, Transformer transformer, Transformer oldRefineTransformer,
|
|
411 |
boolean oldPaging) throws SearchServiceException {
|
|
393 | 412 |
logger.info("non filtered search for... > from: " + from + " to:" + to); |
394 | 413 |
long startTime = System.nanoTime(); |
395 | 414 |
|
Also available in: Unified diff
Adding metrics with micrometer