當前位置: 首頁>>代碼示例>>Java>>正文


Java IndexWriter.unlock方法代碼示例

本文整理匯總了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);
        }
    }
}
 
開發者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.unlock方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。