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 Summary
Constructors Constructor Description LuceneIndexHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Optional<Long>getIndexVersion(Path indexDirectory)static voidreplaceIndexDirectory(Path destination, Path source)Delete existing index files indestinationthen move all index files fromsourcetodestinationstatic longsizeOfIndex(Path indexDirectory)Calculate (approximately) current size of a Lucene index.static longsizeOfIndexMB(Path indexDirectory)Calculate the total size in megabytes of the index located in the specified directory
-
-
-
Method Detail
-
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 indestinationthen move all index files fromsourcetodestination- Parameters:
destination- Index directory whose content is to be replacedsource- Index directory whose content is to be moved todestination- Throws:
IOException- if there is any exception moving the files around
-
-