org.hibernate.search.store.impl
Class DirectoryProviderHelper

java.lang.Object
  extended by org.hibernate.search.store.impl.DirectoryProviderHelper

public final class DirectoryProviderHelper
extends Object

Author:
Emmanuel Bernard, Sanne Grinovero, Hardy Ferentschik

Method Summary
static org.apache.lucene.store.FSDirectory createFSIndex(File indexDir, Properties properties)
          Creates an FSDirectory in provided directory and initializes an index if not already existing.
static org.apache.lucene.store.LockFactory createLockFactory(File indexDir, Properties dirConfiguration)
          Creates a LockFactory as selected in the configuration for the DirectoryProvider.
static long getCopyBufferSize(String indexName, Properties properties)
          Users may configure the number of MB to use as "chunk size" for large file copy operations performed by DirectoryProviders.
static File getSourceDirectory(String indexName, 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
static File getVerifiedIndexDir(String annotatedIndexName, Properties properties, boolean verifyIsWritable)
          Verify the index directory exists and is writable, or creates it if not existing.
static void initializeIndexIfNeeded(org.apache.lucene.store.Directory directory)
          Initialize the Lucene Directory if it isn't already.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getSourceDirectory

public static File getSourceDirectory(String indexName,
                                      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:
indexName - the name of the index (directory) to create
properties - the configuration properties
needWritePermissions - when true the directory will be tested for read-write permissions.
Returns:
The file representing the source directory

createFSIndex

public static org.apache.lucene.store.FSDirectory createFSIndex(File indexDir,
                                                                Properties properties)
                                                         throws IOException
Creates an FSDirectory in provided directory and initializes an index if not already existing.

Parameters:
indexDir - the directory where to write a new index
properties - the configuration properties
Returns:
the created FSDirectory instance
Throws:
IOException - if an error

initializeIndexIfNeeded

public static void initializeIndexIfNeeded(org.apache.lucene.store.Directory directory)
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

public static org.apache.lucene.store.LockFactory createLockFactory(File indexDir,
                                                                    Properties dirConfiguration)
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 implementation
dirConfiguration - 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 annotation
properties - The properties may override the indexname.
verifyIsWritable - Verify the directory is writable
Returns:
the File representing the Index Directory
Throws:
SearchException

getCopyBufferSize

public static long getCopyBufferSize(String indexName,
                                     Properties properties)
Users may configure the number of MB to use as "chunk size" for large file copy operations performed by DirectoryProviders.

Parameters:
indexName - the index name
properties - the configuration properties
Returns:
the number of Bytes to use as "chunk size" in file copy operations.


Copyright © 2006-2012 Red Hat Middleware, LLC. All Rights Reserved