only call refresh if its needed, so we check outside of the readLock when async refreshing
This commit is contained in:
parent
df4f4f056a
commit
7c4d574a32
|
@ -66,6 +66,11 @@ public interface Engine extends IndexShardComponent, CloseableComponent {
|
|||
|
||||
Searcher searcher() throws EngineException;
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if a refresh is really needed.
|
||||
*/
|
||||
boolean refreshNeeded();
|
||||
|
||||
/**
|
||||
* Refreshes the engine for new search operations to reflect the latest
|
||||
* changes. Pass <tt>true</tt> if the refresh operation should include
|
||||
|
|
|
@ -588,6 +588,10 @@ public class RobinEngine extends AbstractIndexShardComponent implements Engine,
|
|||
}
|
||||
}
|
||||
|
||||
@Override public boolean refreshNeeded() {
|
||||
return dirty;
|
||||
}
|
||||
|
||||
@Override public void refresh(Refresh refresh) throws EngineException {
|
||||
if (indexWriter == null) {
|
||||
throw new EngineClosedException(shardId);
|
||||
|
|
|
@ -607,7 +607,9 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
|||
private class EngineRefresher implements Runnable {
|
||||
@Override public void run() {
|
||||
try {
|
||||
engine.refresh(new Engine.Refresh(false));
|
||||
if (engine.refreshNeeded()) {
|
||||
engine.refresh(new Engine.Refresh(false));
|
||||
}
|
||||
} catch (EngineClosedException e) {
|
||||
// we are being closed, ignore
|
||||
} catch (RefreshFailedEngineException e) {
|
||||
|
|
Loading…
Reference in New Issue