public final class SplitIndexFileHelper extends Object
Constructor and Description |
---|
SplitIndexFileHelper(@NonNull File index,
@NonNull String name)
Creates an instance of the SplitIndexFileManager to manage the files of the index located at indexLocation
|
SplitIndexFileHelper(@NonNull String location,
@NonNull String name)
Creates an instance of the SplitIndexFileManager to manage the files of the index located at indexLocation
|
Modifier and Type | Method and Description |
---|---|
static String |
bytesToHumanReadable(long bytes)
Formats bytes in a human readable form, rounds up and tries not to give too many decimals if size is above 100
E.g., 1000 becomes 1000 bytes, 1024 becomes 1 KB, 982.12 MB becomes 983 MB etc.
|
Map<String,FileInfo> |
collectIndexFileInfos()
Gets the size of a Directory by sizing all the files.
|
static Map<String,FileInfo> |
collectIndexFileInfos(@NonNull File folder)
Gets the size of a Directory by sizing all the files.
|
static void |
copyFilesToFolder(@NonNull Collection<FileInfo> source,
@NonNull File target)
Copies all the files in the FileInfo list to the target folder
|
void |
createEmptyIndexIfNone()
If there is an index, this will just open it and do nothing.
|
File |
getIndex() |
SplitIndexPhase |
getPhase()
Tries to read the phase file if it exists
|
static long |
getTotalSize(@NonNull Collection<FileInfo> files)
Sums the sizes of the files in the FileInfo list
|
static long |
getTotalZipEntriesSize(File zipFile)
Returns the total size in bytes of the entries for given archive
|
static long |
getTotalZipEntriesSize(ZipEntry[] entries)
Returns the total size in bytes of the entries for given archive
|
static boolean |
hasFiles(File location)
Checks if there are files in a directory (excludes subfolders!) so will count only real files
|
static boolean |
isLuceneIndex(@NonNull File location)
Checks if a File is a Lucene index.
|
void |
overrideWithEmptyIndex()
This will create an empty index in the directory, regardless if the index existed here or not.
|
void |
purgeAllFiles()
deletes all files in the folder where this SplitIndexFileManager is pointed at.
|
void |
purgeChanges() |
void |
purgeContent() |
static org.apache.lucene.index.DirectoryReader |
refresh(org.apache.lucene.index.DirectoryReader reader)
Refreshes a reader so the written changes become visible.
|
@NonNull IndexInfo |
refreshIndexInfo()
Force refresh of the indexInfo.
|
void |
removePhase()
Removes the state file
|
void |
setPhase(@NonNull SplitIndexPhase phase)
Sets the phase in the index (writes state file)
|
public SplitIndexFileHelper(@NonNull String location, @NonNull String name)
location
- String location of the index.name
- String name of the index (for logging purposes)public SplitIndexFileHelper(@NonNull File index, @NonNull String name)
index
- File location of the index.name
- String name of the index (for logging purposes)public File getIndex()
public Map<String,FileInfo> collectIndexFileInfos()
public SplitIndexPhase getPhase()
public void setPhase(@NonNull SplitIndexPhase phase)
phase
- SplitIndexPhasepublic void removePhase()
public static Map<String,FileInfo> collectIndexFileInfos(@NonNull File folder)
folder
- Filepublic static void copyFilesToFolder(@NonNull Collection<FileInfo> source, @NonNull File target)
source
- Collection of FileInfotarget
- File target locationpublic static long getTotalSize(@NonNull Collection<FileInfo> files)
files
- List of FileInfopublic static String bytesToHumanReadable(long bytes)
bytes
- long size in bytespublic @NonNull IndexInfo refreshIndexInfo()
public static boolean isLuceneIndex(@NonNull File location)
location
- Filepublic static boolean hasFiles(File location)
location
- Filepublic void purgeContent()
public void purgeChanges()
public void createEmptyIndexIfNone()
public void overrideWithEmptyIndex()
public static long getTotalZipEntriesSize(File zipFile) throws IOException
zipFile
- file with zip archiveIOException
public static long getTotalZipEntriesSize(ZipEntry[] entries)
entries
- ZipEntry[]public static org.apache.lucene.index.DirectoryReader refresh(org.apache.lucene.index.DirectoryReader reader) throws IOException
reader
- DirectoryReaderIOException
- when something goes wrong inside lucene code.public void purgeAllFiles() throws UpgradeException
UpgradeException
Copyright © 2003–2021 Atlassian. All rights reserved.