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


C# Lucene.Net.Store.MockRAMDirectory.ClearDoFail方法代码示例

本文整理汇总了C#中Lucene.Net.Store.MockRAMDirectory.ClearDoFail方法的典型用法代码示例。如果您正苦于以下问题:C# Lucene.Net.Store.MockRAMDirectory.ClearDoFail方法的具体用法?C# Lucene.Net.Store.MockRAMDirectory.ClearDoFail怎么用?C# Lucene.Net.Store.MockRAMDirectory.ClearDoFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lucene.Net.Store.MockRAMDirectory的用法示例。


在下文中一共展示了Lucene.Net.Store.MockRAMDirectory.ClearDoFail方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: _testSingleThreadFailure

		// Runs test, with one thread, using the specific failure
		// to trigger an IOException
		public virtual void  _testSingleThreadFailure(MockRAMDirectory.Failure failure)
		{
			MockRAMDirectory dir = new MockRAMDirectory();
			
			IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer());
			writer.SetMaxBufferedDocs(2);
			Document doc = new Document();
			doc.Add(new Field("field", "aaa bbb ccc ddd eee fff ggg hhh iii jjj", Field.Store.YES, Field.Index.TOKENIZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
			
			for (int i = 0; i < 6; i++)
				writer.AddDocument(doc);
			
			dir.FailOn(failure);
			failure.SetDoFail();
			try
			{
				writer.AddDocument(doc);
				writer.AddDocument(doc);
				Assert.Fail("did not hit exception");
			}
			catch (System.IO.IOException)
			{
			}
			failure.ClearDoFail();
			writer.AddDocument(doc);
			writer.Close(false);
		}
开发者ID:vikasraz,项目名称:indexsearchutils,代码行数:29,代码来源:TestIndexWriter.cs

示例2: _testMultipleThreadsFailure

		// Runs test, with multiple threads, using the specific
		// failure to trigger an IOException
		public virtual void  _testMultipleThreadsFailure(MockRAMDirectory.Failure failure)
		{
			
			int NUM_THREADS = 3;
			
			for (int iter = 0; iter < 5; iter++)
			{
				MockRAMDirectory dir = new MockRAMDirectory();
				IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
				ConcurrentMergeScheduler cms = new ConcurrentMergeScheduler();
				// We expect disk full exceptions in the merge threads
				cms.SetSuppressExceptions();
				writer.SetMergeScheduler(cms);
				writer.SetMaxBufferedDocs(2);
				writer.SetMergeFactor(4);
				
				IndexerThread[] threads = new IndexerThread[NUM_THREADS];
				
				for (int i = 0; i < NUM_THREADS; i++)
					threads[i] = new IndexerThread(this, writer, true);
				
				for (int i = 0; i < NUM_THREADS; i++)
					threads[i].Start();
				
				System.Threading.Thread.Sleep(new System.TimeSpan((System.Int64) 10000 * 10));
				
				dir.FailOn(failure);
				failure.SetDoFail();
				
				for (int i = 0; i < NUM_THREADS; i++)
				{
					threads[i].Join();
					Assert.IsTrue(threads[i].error == null, "hit unexpected Throwable");
				}
				
				bool success = false;
				try
				{
					writer.Close(false);
					success = true;
				}
				catch (System.IO.IOException ioe)
				{
					failure.ClearDoFail();
					writer.Close(false);
				}
				
				if (success)
				{
					IndexReader reader = IndexReader.Open(dir);
					for (int j = 0; j < reader.MaxDoc(); j++)
					{
						if (!reader.IsDeleted(j))
						{
							reader.Document(j);
							reader.GetTermFreqVectors(j);
						}
					}
					reader.Close();
				}
				
				dir.Close();
			}
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:66,代码来源:TestIndexWriter.cs


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