Package org.hibernate.search.store
Class DirectoryProviderHelper
java.lang.Object
org.hibernate.search.store.DirectoryProviderHelper
-
Method Summary
Modifier and TypeMethodDescriptionstatic FSDirectorycreateFSIndex(File indexDir, Properties properties) Creates an FSDirectory in provided directory and initializes an index if not already existing.static LockFactorycreateLockFactory(File indexDir, Properties dirConfiguration) Creates a LockFactory as selected in the configuration for the DirectoryProvider.static longgetCopyBufferSize(String directoryProviderName, Properties properties) Users may configure the number of MB to use as "chunk size" for large file copy operations performed by DirectoryProviders.static FilegetSourceDirectory(String directoryProviderName, Properties properties, boolean needWritePermissions) Build a directory name out of a root and relative path, guessing the significant part and checking for the file availabilitystatic FilegetVerifiedIndexDir(String annotatedIndexName, Properties properties, boolean verifyIsWritable) Verify the index directory exists and is writable, or creates it if not existing.static voidinitializeIndexIfNeeded(Directory directory) Initialize the Lucene Directory if it isn't already.
-
Method Details
-
getSourceDirectory
public static File getSourceDirectory(String directoryProviderName, Properties properties, boolean needWritePermissions) Build a directory name out of a root and relative path, guessing the significant part and checking for the file availability- Parameters:
directoryProviderName-properties- the configuration propertiesneedWritePermissions- when true the directory will be tested for read-write permissions.- Returns:
- The file representing the source directory
-
createFSIndex
Creates an FSDirectory in provided directory and initializes an index if not already existing.- Parameters:
indexDir- the directory where to write a new indexproperties- the configuration properties- Returns:
- the created
FSDirectoryinstance - Throws:
IOException- if an error
-
initializeIndexIfNeeded
Initialize the Lucene Directory if it isn't already.- Parameters:
directory- the Directory to initialize- Throws:
SearchException- in case of lock acquisition timeouts, IOException, or if a corrupt index is found
-
createLockFactory
Creates a LockFactory as selected in the configuration for the DirectoryProvider. The SimpleFSLockFactory and NativeFSLockFactory need a File to know where to stock the filesystem based locks; other implementations ignore this parameter.- Parameters:
indexDir- the directory to use to store locks, if needed by implementationdirConfiguration- the configuration of current DirectoryProvider- Returns:
- the LockFactory as configured, or a SimpleFSLockFactory in case of configuration errors or as a default.
- Throws:
IOException
-
getVerifiedIndexDir
public static File getVerifiedIndexDir(String annotatedIndexName, Properties properties, boolean verifyIsWritable) Verify the index directory exists and is writable, or creates it if not existing.- Parameters:
annotatedIndexName- The index name declared on the @Indexed annotationproperties- The properties may override the indexname.verifyIsWritable- Verify the directory is writable- Returns:
- the File representing the Index Directory
- Throws:
SearchException
-
getCopyBufferSize
Users may configure the number of MB to use as "chunk size" for large file copy operations performed by DirectoryProviders.- Parameters:
directoryProviderName-properties- the configuration properties- Returns:
- the number of Bytes to use as "chunk size" in file copy operations.
-