Przeglądaj źródła

Removed exception handling in InternalIndexShard.docStats() & storeStats()

This is already caught at another level, see #4203
Boaz Leskes 12 lat temu
rodzic
commit
b865047125

+ 10 - 14
src/main/java/org/elasticsearch/index/shard/service/InternalIndexShard.java

@@ -85,6 +85,7 @@ import org.elasticsearch.search.suggest.completion.Completion090PostingsFormat;
 import org.elasticsearch.search.suggest.completion.CompletionStats;
 import org.elasticsearch.threadpool.ThreadPool;
 
+import java.io.IOException;
 import java.io.PrintStream;
 import java.nio.channels.ClosedByInterruptException;
 import java.util.concurrent.ScheduledFuture;
@@ -349,8 +350,9 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
 
     /**
      * Changes the state of the current shard
+     *
      * @param newState the new shard state
-     * @param reason the reason for the state change
+     * @param reason   the reason for the state change
      * @return the previous shard state
      */
     private IndexShardState changeState(IndexShardState newState, String reason) {
@@ -487,16 +489,11 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
 
     @Override
     public DocsStats docStats() {
+        final Engine.Searcher searcher = acquireSearcher("doc_stats");
         try {
-            final Engine.Searcher searcher = acquireSearcher("doc_stats");
-            try {
-                return new DocsStats(searcher.reader().numDocs(), searcher.reader().numDeletedDocs());
-            } finally {
-                searcher.release();
-            }
-        } catch (Throwable e) {
-            logger.debug("Can not build 'doc stats' from engine shard state [{}]", e, state);
-            return new DocsStats();
+            return new DocsStats(searcher.reader().numDocs(), searcher.reader().numDeletedDocs());
+        } finally {
+            searcher.release();
         }
     }
 
@@ -519,9 +516,8 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
     public StoreStats storeStats() {
         try {
             return store.stats();
-        } catch (Throwable e) {
-            logger.debug("Can not build 'store stats' from engine shard state [{}]", e, state);
-            return new StoreStats();
+        } catch (IOException e) {
+            throw new ElasticSearchException("io exception while building 'store stats'", e);
         }
     }
 
@@ -1040,4 +1036,4 @@ public class InternalIndexShard extends AbstractIndexShardComponent implements I
             logger.warn("failed to check index", e);
         }
     }
-}
+}