Class LuceneIndexHelper

java.lang.Object
com.atlassian.confluence.internal.index.lucene.LuceneIndexHelper

public class LuceneIndexHelper extends Object
Helper methods to deal with Lucene index in Confluence
Since:
7.6.0
  • Constructor Details

    • LuceneIndexHelper

      public LuceneIndexHelper()
  • Method Details

    • sizeOfIndex

      public static long sizeOfIndex(Path indexDirectory) throws IOException
      Calculate (approximately) current size of a Lucene index. This is done by adding up size of all regular files directly under the index directory. This cannot simply be done by normal File utils e.g. common-ios FileUtils#sizeOfDirectory because Confluence put indices inside main index directory.
      Parameters:
      indexDirectory - The index directory
      Returns:
      size in bytes of the index stored in specified directory
      Throws:
      IOException - if there is any error sizing index files
    • sizeOfIndexMB

      public static long sizeOfIndexMB(Path indexDirectory)
      Calculate the total size in megabytes of the index located in the specified directory
      Returns:
      index size in MB, else 0 If the size of the index cannot be calculated
    • getIndexVersion

      public static Optional<Long> getIndexVersion(Path indexDirectory)
      Parameters:
      indexDirectory - directory of the index
      Returns:
      current version of an index, or empty if the index cannot be read.
    • replaceIndexDirectory

      public static void replaceIndexDirectory(Path destination, Path source) throws IOException
      Delete existing index files in destination then move all index files from source to destination
      Parameters:
      destination - Index directory whose content is to be replaced
      source - Index directory whose content is to be moved to destination
      Throws:
      IOException - if there is any exception moving the files around