private boolean isImmediateTimeout() { boolean timeoutAt0 = false; if ( timeoutManager.getType() == TimeoutManager.Type.LIMIT ) { final Long timeoutLeft = timeoutManager.getTimeoutLeftInMilliseconds(); if ( timeoutLeft != null ) { if ( timeoutLeft == 0L ) { if ( timeoutManager.isTimedOut() ) { timeoutManager.forceTimedOut(); timeoutAt0 = true; } } } else { if ( timeoutManager.isTimedOut() ) { timeoutManager.forceTimedOut(); } } } return timeoutAt0; }
private Collector decorateWithTimeOutCollector(Collector collector) { Collector maybeTimeLimitingCollector = collector; if ( timeoutManager.getType() == TimeoutManager.Type.LIMIT ) { final Long timeoutLeft = timeoutManager.getTimeoutLeftInMilliseconds(); if ( timeoutLeft != null ) { Counter counter = timeoutManager.getLuceneTimeoutCounter(); maybeTimeLimitingCollector = new TimeLimitingCollector( collector, counter, timeoutLeft ); } } return maybeTimeLimitingCollector; }
@Override public Long getTimeoutLeftInMilliseconds() { return getTimeoutLeft( 1000000 ); }
@Override protected TimeoutManagerImpl buildTimeoutManager() { return new TimeoutManagerImpl( rawSearchPayload, timeoutExceptionFactory, this.extendedIntegrator.getTimingSource() ); }
@Override public boolean isTimedOut() { if ( timeout == null ) { return false; } if ( timedOut ) { return true; } return isTimedOut( System.nanoTime() ); }
timeoutManager.forceTimedOut(); updateFacets(); timeoutManager.isTimedOut();
@Override public void setTimeout(long timeout, TimeUnit timeUnit) { this.timeout = timeUnit.toNanos( timeout ); //timeout of 0 means no more timeout if ( timeout == 0 ) { stop(); } }
@Override public int queryResultSize() { if ( resultSize == null ) { //the timeoutManager does not need to be stopped nor reset as a start does indeed reset getTimeoutManager().start(); //get result size without object initialization LazyQueryState searcher = buildSearcher( extendedIntegrator, false ); if ( searcher == null ) { resultSize = 0; } else { try { QueryHits queryHits = getQueryHits( searcher, 0 ); resultSize = queryHits.getTotalHits(); } catch (IOException e) { throw new SearchException( "Unable to query Lucene index", e ); } finally { closeSearcher( searcher ); } } } return this.resultSize; }
@Override protected TimeoutManagerImpl buildTimeoutManager() { return new TimeoutManagerImpl( rawSearchPayload, timeoutExceptionFactory, this.extendedIntegrator.getTimingSource() ); }
@Override public boolean isTimedOut() { if ( timeout == null ) { return false; } if ( timedOut ) { return true; } return isTimedOut( System.nanoTime() ); }
timeoutManager.forceTimedOut(); this.totalHits = hitCountCollector.getTotalHits(); timeoutManager.isTimedOut();
@Override public void setTimeout(long timeout, TimeUnit timeUnit) { this.timeout = timeUnit.toNanos( timeout ); //timeout of 0 means no more timeout if ( timeout == 0 ) { stop(); } }
@Override public int queryResultSize() { if ( resultSize == null ) { //the timeoutManager does not need to be stopped nor reset as a start does indeed reset getTimeoutManager().start(); //get result size without object initialization LazyQueryState searcher = buildSearcher( extendedIntegrator, false ); if ( searcher == null ) { resultSize = 0; } else { try { QueryHits queryHits = getQueryHits( searcher, 0, false ); resultSize = queryHits.getTotalHits(); } catch (IOException e) { throw new SearchException( "Unable to query Lucene index", e ); } finally { closeSearcher( searcher ); } } } return this.resultSize; }
@Override protected TimeoutManagerImpl buildTimeoutManager() { return new TimeoutManagerImpl( jsonQuery, timeoutExceptionFactory, this.extendedIntegrator.getTimingSource() ); }
private boolean isImmediateTimeout() { boolean timeoutAt0 = false; if ( timeoutManager.getType() == TimeoutManager.Type.LIMIT ) { final Long timeoutLeft = timeoutManager.getTimeoutLeftInMilliseconds(); if ( timeoutLeft != null ) { if ( timeoutLeft == 0l ) { if ( timeoutManager.isTimedOut() ) { timeoutManager.forceTimedOut(); timeoutAt0 = true; } } } else { if ( timeoutManager.isTimedOut() ) { timeoutManager.forceTimedOut(); } } } return timeoutAt0; }
private Collector decorateWithTimeOutCollector(Collector collector) { Collector maybeTimeLimitingCollector = collector; if ( timeoutManager.getType() == TimeoutManager.Type.LIMIT ) { final Long timeoutLeft = timeoutManager.getTimeoutLeftInMilliseconds(); if ( timeoutLeft != null ) { Counter counter = timeoutManager.getLuceneTimeoutCounter(); maybeTimeLimitingCollector = new TimeLimitingCollector( collector, counter, timeoutLeft ); } } return maybeTimeLimitingCollector; }
private Long getTimeoutLeft(long factor) { if ( timeout == null ) { return null; } else { final long currentTime = System.nanoTime(); if ( isTimedOut( currentTime ) ) { //0 means no limit so we return the lowest possible value return 0l; } long left = timeout - ( currentTime - start); long result; if ( left % factor == 0 ) { result = left / factor; } else { result = (left / factor) + 1; } if ( result <= 0 ) { //0 means no limit so we return the lowest possible value return 0l; } else { return result; } } }
@Override public Long getTimeoutLeftInSeconds() { return getTimeoutLeft( 1000000000 ); }
@Override protected TimeoutManagerImpl buildTimeoutManager() { if ( luceneQuery == null ) { throw new AssertionFailure( "Requesting TimeoutManager before setting luceneQuery()" ); } return new TimeoutManagerImpl( luceneQuery, timeoutExceptionFactory, this.extendedIntegrator.getTimingSource() ); }
private Long getTimeoutLeft(long factor) { if ( timeout == null ) { return null; } else { final long currentTime = System.nanoTime(); if ( isTimedOut( currentTime ) ) { //0 means no limit so we return the lowest possible value return 0L; } long left = timeout - ( currentTime - start); long result; if ( left % factor == 0 ) { result = left / factor; } else { result = (left / factor) + 1; } if ( result <= 0 ) { //0 means no limit so we return the lowest possible value return 0L; } else { return result; } } }