当前位置: 首页>>代码示例>>Java>>正文


Java IndexWriter.isLocked方法代码示例

本文整理汇总了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);
        }
    }
}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:17,代码来源:SearchService.java

示例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);
	}
}
 
开发者ID:XMBomb,项目名称:InComb,代码行数:10,代码来源:Index.java

示例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);
}
 
开发者ID:equella,项目名称:Equella,代码行数:48,代码来源:AbstractIndexEngine.java


注:本文中的org.apache.lucene.index.IndexWriter.isLocked方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。