com.atlassian.jira.issue.index
Class IndexConsistencyUtils

java.lang.Object
  extended by com.atlassian.jira.issue.index.IndexConsistencyUtils

public class IndexConsistencyUtils
extends Object

Utility methods related to performing consistency checks on indexes.

Since:
v5.2

Method Summary
static boolean isIndexConsistent(String name, int expectedCount, Supplier<org.apache.lucene.search.IndexSearcher> supplier)
          Performs a simple consistency check on an index by opening it, comparing the document count to an expected value supplied by the caller, and closing it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isIndexConsistent

public static boolean isIndexConsistent(String name,
                                        int expectedCount,
                                        Supplier<org.apache.lucene.search.IndexSearcher> supplier)
Performs a simple consistency check on an index by opening it, comparing the document count to an expected value supplied by the caller, and closing it. If the expected document count can not be determined reliably and efficiently, then -1 may be specified to skip that part of the check. If an expected count is given, the actual count must be within 10% of the expected value or 10 documents, whichever value is larger.

Parameters:
name - a name to identify the index
expectedCount - the expected count of documents in the index, or -1 to skip this check
supplier - provides a searcher for the index; should throw an exception if the index is unavailable
Returns:
true if the index is present and contains reasonably close to the expected number of documents; false if any exception is thrown or if the index document count is excessively different from the expected count


Copyright © 2002-2013 Atlassian. All Rights Reserved.