From 19b355e9f028d565612ba4602ee0f77e6f65e3c8 Mon Sep 17 00:00:00 2001 From: kimchy Date: Sat, 17 Apr 2010 22:15:50 +0300 Subject: [PATCH] ignore interruped exception when scheduled refresh is going on --- .../index/shard/service/InternalIndexShard.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java index a3530256073..c84d24a0646 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java @@ -23,6 +23,7 @@ import com.google.inject.Inject; import org.apache.lucene.document.Document; import org.apache.lucene.index.Term; import org.apache.lucene.search.*; +import org.apache.lucene.util.ThreadInterruptedException; import org.elasticsearch.ElasticSearchException; import org.elasticsearch.ElasticSearchIllegalArgumentException; import org.elasticsearch.ElasticSearchIllegalStateException; @@ -30,6 +31,7 @@ import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.index.cache.IndexCache; import org.elasticsearch.index.engine.Engine; import org.elasticsearch.index.engine.EngineException; +import org.elasticsearch.index.engine.RefreshFailedEngineException; import org.elasticsearch.index.engine.ScheduledRefreshableEngine; import org.elasticsearch.index.mapper.DocumentMapper; import org.elasticsearch.index.mapper.DocumentMapperNotFoundException; @@ -54,6 +56,7 @@ import org.elasticsearch.util.lucene.search.TermFilter; import org.elasticsearch.util.settings.Settings; import java.io.IOException; +import java.nio.channels.ClosedByInterruptException; import java.util.concurrent.ScheduledFuture; /** @@ -513,6 +516,16 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I @Override public void run() { try { engine.refresh(new Engine.Refresh(false)); + } catch (RefreshFailedEngineException e) { + if (e.getCause() instanceof InterruptedException) { + // ignore, we are being shutdown + } else if (e.getCause() instanceof ClosedByInterruptException) { + // ignore, we are being shutdown + } else if (e.getCause() instanceof ThreadInterruptedException) { + // ignore, we are being shutdown + } else { + logger.warn("Failed to perform scheduled engine refresh", e); + } } catch (Exception e) { logger.warn("Failed to perform scheduled engine refresh", e); }