コード例 #1
0
 /// <summary>
 /// Constructs the worker thread for the slave and starts it
 /// </summary>
 public virtual void BuildThreads()
 {
     Reader = new AnonymousClassThread(this);
     Writer = new AnonymousClassThread1(this);
     Writer.Start();
     Reader.Start();
 }
コード例 #2
0
ファイル: Jamocha.cs プロジェクト: joaocc/creshendo--git
 public virtual void  startGui()
 {
     if (jamochaGui == null)
     {
         jamochaGui = new JamochaGui(engine);
         SupportClass.ThreadClass guiThread = new AnonymousClassThread1(this);
         guiThread.Start();
     }
 }
コード例 #3
0
        public virtual void  TestDuringAddDelete()
        {
            Directory   dir1   = new MockRAMDirectory();
            IndexWriter writer = new IndexWriter(dir1, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);

            writer.SetInfoStream(infoStream);
            writer.SetMergeFactor(2);

            // create the index
            CreateIndexNoClose(false, "test", writer);
            writer.Commit();

            IndexReader r = writer.GetReader();

            int   NUM_THREAD = 5;
            float SECONDS    = 3;

            long endTime = (long)((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) + 1000.0 * SECONDS);

            System.Collections.IList excs = (System.Collections.IList)System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(new System.Collections.ArrayList()));

            SupportClass.ThreadClass[] threads = new SupportClass.ThreadClass[NUM_THREAD];
            for (int i = 0; i < NUM_THREAD; i++)
            {
                threads[i] = new AnonymousClassThread1(endTime, writer, excs, this);
                threads[i].IsBackground = true;
                threads[i].Start();
            }

            int sum = 0;

            while ((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) < endTime)
            {
                IndexReader r2 = r.Reopen();
                if (r2 != r)
                {
                    r.Close();
                    r = r2;
                }
                Query q = new TermQuery(new Term("indexname", "test"));
                sum += new IndexSearcher(r).Search(q, 10).totalHits;
            }

            for (int i = 0; i < NUM_THREAD; i++)
            {
                threads[i].Join();
            }
            Assert.IsTrue(sum > 0);

            Assert.AreEqual(0, excs.Count);
            writer.Close();

            _TestUtil.CheckIndex(dir1);
            r.Close();
            dir1.Close();
        }
コード例 #4
0
 public virtual void startGui()
 {
     if (jamochaGui == null)
     {
         jamochaGui = new JamochaGui(engine);
         SupportClass.ThreadClass guiThread = new AnonymousClassThread1(this);
         guiThread.Start();
     }
 }
コード例 #5
0
 public virtual void  TestDuringAddDelete()
 {
     Directory dir1 = new MockRAMDirectory();
     IndexWriter writer = new IndexWriter(dir1, new WhitespaceAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
     writer.SetInfoStream(infoStream);
     writer.MergeFactor = 2;
     
     // create the index
     CreateIndexNoClose(false, "test", writer);
     writer.Commit();
     
     IndexReader r = writer.GetReader();
     
     int NUM_THREAD = 5;
     float SECONDS = 3;
     
     long endTime = (long) ((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) + 1000.0 * SECONDS);
     System.Collections.IList excs = (System.Collections.IList) System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(new System.Collections.ArrayList()));
     
     ThreadClass[] threads = new ThreadClass[NUM_THREAD];
     for (int i = 0; i < NUM_THREAD; i++)
     {
         threads[i] = new AnonymousClassThread1(endTime, writer, excs, this);
         threads[i].IsBackground = true;
         threads[i].Start();
     }
     
     int sum = 0;
     while ((DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond) < endTime)
     {
         IndexReader r2 = r.Reopen();
         if (r2 != r)
         {
             r.Close();
             r = r2;
         }
         Query q = new TermQuery(new Term("indexname", "test"));
         sum += new IndexSearcher(r).Search(q, 10).TotalHits;
     }
     
     for (int i = 0; i < NUM_THREAD; i++)
     {
         threads[i].Join();
     }
     Assert.IsTrue(sum > 0);
     
     Assert.AreEqual(0, excs.Count);
     writer.Close();
     
     _TestUtil.CheckIndex(dir1);
     r.Close();
     dir1.Close();
 }
コード例 #6
0
ファイル: TestIndexWriter.cs プロジェクト: Rationalle/ravendb
		public virtual void  TestNoWaitClose()
		{
			RAMDirectory directory = new MockRAMDirectory();
			
			Document doc = new Document();
			Field idField = new Field("id", "", Field.Store.YES, Field.Index.NOT_ANALYZED);
			doc.Add(idField);
			
			for (int pass = 0; pass < 3; pass++)
			{
				bool autoCommit = pass % 2 == 0;
				IndexWriter writer = new IndexWriter(directory, autoCommit, new WhitespaceAnalyzer(), true);
				
				//System.out.println("TEST: pass="******" ac=" + autoCommit + " cms=" + (pass >= 2));
				for (int iter = 0; iter < 10; iter++)
				{
					//System.out.println("TEST: iter=" + iter);
					MergeScheduler ms;
					if (pass >= 2)
						ms = new ConcurrentMergeScheduler();
					else
						ms = new SerialMergeScheduler();
					
					writer.SetMergeScheduler(ms);
					writer.SetMaxBufferedDocs(2);
					writer.SetMergeFactor(100);
					
					for (int j = 0; j < 199; j++)
					{
						idField.SetValue(System.Convert.ToString(iter * 201 + j));
						writer.AddDocument(doc);
					}
					
					int delID = iter * 199;
					for (int j = 0; j < 20; j++)
					{
						writer.DeleteDocuments(new Term("id", System.Convert.ToString(delID)));
						delID += 5;
					}
					
					// Force a bunch of merge threads to kick off so we
					// stress out aborting them on close:
					writer.SetMergeFactor(2);
					
					IndexWriter finalWriter = writer;
					System.Collections.ArrayList failure = new System.Collections.ArrayList();
					SupportClass.ThreadClass t1 = new AnonymousClassThread1(finalWriter, doc, failure, this);
					
					if (failure.Count > 0)
					{
						throw (System.Exception) failure[0];
					}
					
					t1.Start();
					
					writer.Close(false);
					t1.Join();
					
					// Make sure reader can read
					IndexReader reader = IndexReader.Open(directory);
					reader.Close();
					
					// Reopen
					writer = new IndexWriter(directory, autoCommit, new WhitespaceAnalyzer(), false);
				}
				writer.Close();
			}
			
			directory.Close();
		}
コード例 #7
0
        /// <summary> Initializes the KeyListener to catch all Keypresses.
        /// 
        /// </summary>
        private void initKeyListener()
        {
            KeyAdapter adapter = new AnonymousClassKeyAdapter(this);
            addKeyListener(adapter);
            outputArea.addKeyListener(adapter);

            SupportClass.ThreadClass eventThread = new AnonymousClassThread1(this);
            eventThread.Start();
        }