本文整理匯總了Java中org.apache.lucene.index.IndexWriter.isLocked方法的典型用法代碼示例。如果您正苦於以下問題:Java IndexWriter.isLocked方法的具體用法?Java IndexWriter.isLocked怎麽用?Java IndexWriter.isLocked使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.lucene.index.IndexWriter
的用法示例。
在下文中一共展示了IndexWriter.isLocked方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: removeLocks
import org.apache.lucene.index.IndexWriter; //導入方法依賴的package包/類
private void removeLocks() {
for (IndexType indexType : IndexType.values()) {
Directory dir = null;
try {
dir = FSDirectory.open(getIndexDirectory(indexType));
if (IndexWriter.isLocked(dir)) {
IndexWriter.unlock(dir);
LOG.info("Removed Lucene lock file in " + dir);
}
} catch (Exception x) {
LOG.warn("Failed to remove Lucene lock file in " + dir, x);
} finally {
FileUtil.closeQuietly(dir);
}
}
}
示例2: unlock
import org.apache.lucene.index.IndexWriter; //導入方法依賴的package包/類
/**
* Checks if the index is currently locked and unlocks it if it is.
* @throws IOException if there is a low-level IO error
*/
private void unlock() throws IOException {
if(IndexWriter.isLocked(directory)) {
IndexWriter.unlock(directory);
}
}
示例3: afterPropertiesSet
import org.apache.lucene.index.IndexWriter; //導入方法依賴的package包/類
@PostConstruct
public void afterPropertiesSet() throws IOException
{
if( !indexPath.exists() )
{
if( !indexPath.mkdirs() )
{
throw new Error("Error creating index:" + indexPath); //$NON-NLS-1$
}
}
directory = FSDirectory.open(indexPath);
if( IndexWriter.isLocked(directory) )
{
LOGGER.info("Unlocking index:" + indexPath); //$NON-NLS-1$
IndexWriter.unlock(directory);
}
LOGGER.info("Opening writer for index:" + indexPath); //$NON-NLS-1$
indexWriter = new IndexWriter(directory, new IndexWriterConfig(LuceneConstants.LATEST_VERSION, getAnalyser()));
nrtManager = new NRTManager(indexWriter, null);
// Possibly reopen a searcher every 5 seconds if necessary in the
// background
nrtReopenThread = new NRTManagerReopenThread(nrtManager, 5.0, 0.1);
nrtReopenThread.setName("NRT Reopen Thread: " + getClass());
nrtReopenThread.setPriority(Math.min(Thread.currentThread().getPriority() + 2, Thread.MAX_PRIORITY));
nrtReopenThread.setDaemon(true);
nrtReopenThread.start();
// Commit any changes to disk every 5 minutes
commiterThread = new Timer(true);
commiterThread.schedule(new TimerTask()
{
@Override
public void run()
{
try
{
indexWriter.commit();
}
catch( IOException ex )
{
LOGGER.error("Error attempting to commit index writer", ex);
}
}
}, 5 * 60 * 1000, 5 * 60 * 1000);
}