本文整理汇总了Java中org.apache.lucene.index.IndexWriter.unlock方法的典型用法代码示例。如果您正苦于以下问题:Java IndexWriter.unlock方法的具体用法?Java IndexWriter.unlock怎么用?Java IndexWriter.unlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.index.IndexWriter
的用法示例。
在下文中一共展示了IndexWriter.unlock方法的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);
}