SOLR-11805: SolrJ's SolrResponse.getElaspedTime was sometimes a millisecond off

This commit is contained in:
David Smiley 2018-01-03 15:47:32 -05:00
parent 1cc49d18c2
commit 9586d12af4
3 changed files with 7 additions and 3 deletions

View File

@ -105,6 +105,8 @@ Other Changes
* SOLR-11748: Remove Autoscaling action throttle. (shalin)
* SOLR-11805: SolrJ's SolrResponse.getElaspedTime was sometimes a millisecond off. (David Smiley)
================== 7.2.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.

View File

@ -189,11 +189,11 @@ public abstract class SolrRequest<T extends SolrResponse> implements Serializabl
* @throws IOException if there is a communication error
*/
public final T process(SolrClient client, String collection) throws SolrServerException, IOException {
long startTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
long startNanos = System.nanoTime();
T res = createResponse(client);
res.setResponse(client.request(this, collection));
long endTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
res.setElapsedTime(endTime - startTime);
long endNanos = System.nanoTime();
res.setElapsedTime(TimeUnit.NANOSECONDS.toMillis(endNanos - startNanos));
return res;
}

View File

@ -33,6 +33,8 @@ import java.io.Serializable;
* @since solr 1.3
*/
public abstract class SolrResponse implements Serializable {
/** Elapsed time in milliseconds for the request as seen from the client. */
public abstract long getElapsedTime();
public abstract void setResponse(NamedList<Object> rsp);