only fork a refresh if it actually needs to be refreshed
This commit is contained in:
parent
7c4d574a32
commit
fc88cccfb4
|
@ -581,7 +581,7 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
|||
|
||||
private void startScheduledTasksIfNeeded() {
|
||||
if (refreshInterval.millis() > 0) {
|
||||
refreshScheduledFuture = threadPool.schedule(new EngineRefresher(), refreshInterval, ThreadPool.ExecutionType.THREADED);
|
||||
refreshScheduledFuture = threadPool.schedule(new EngineRefresher(), refreshInterval, ThreadPool.ExecutionType.DEFAULT);
|
||||
logger.debug("scheduling refresher every {}", refreshInterval);
|
||||
} else {
|
||||
logger.debug("scheduled refresher disabled");
|
||||
|
@ -605,6 +605,15 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
|||
}
|
||||
|
||||
private class EngineRefresher implements Runnable {
|
||||
@Override public void run() {
|
||||
// we check before if a refresh is needed, if not, we reschedule, otherwise, we fork, refresh, and then reschedule
|
||||
if (!engine().refreshNeeded()) {
|
||||
if (state != IndexShardState.CLOSED) {
|
||||
refreshScheduledFuture = threadPool.schedule(this, refreshInterval, ThreadPool.ExecutionType.DEFAULT);
|
||||
}
|
||||
return;
|
||||
}
|
||||
threadPool.cached().execute(new Runnable() {
|
||||
@Override public void run() {
|
||||
try {
|
||||
if (engine.refreshNeeded()) {
|
||||
|
@ -626,9 +635,11 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
|
|||
logger.warn("Failed to perform scheduled engine refresh", e);
|
||||
}
|
||||
if (state != IndexShardState.CLOSED) {
|
||||
refreshScheduledFuture = threadPool.schedule(this, refreshInterval, ThreadPool.ExecutionType.THREADED);
|
||||
refreshScheduledFuture = threadPool.schedule(this, refreshInterval, ThreadPool.ExecutionType.DEFAULT);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private class EngineOptimizer implements Runnable {
|
||||
|
|
Loading…
Reference in New Issue