Ejemplo n.º 1
0
        public virtual void  _testStressLocks(LockFactory lockFactory, System.IO.FileInfo indexDir)
        {
            FSDirectory fs1 = FSDirectory.Open(new System.IO.DirectoryInfo(indexDir.FullName), lockFactory);

            // First create a 1 doc index:
            IndexWriter w = new IndexWriter(fs1, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);

            AddDoc(w);
            w.Close();

            WriterThread   writer   = new WriterThread(this, 100, fs1);
            SearcherThread searcher = new SearcherThread(this, 100, fs1);

            writer.Start();
            searcher.Start();

            while (writer.IsAlive || searcher.IsAlive)
            {
                System.Threading.Thread.Sleep(new System.TimeSpan((System.Int64) 10000 * 1000));
            }

            Assert.IsTrue(!writer.hitException, "IndexWriter hit unexpected exceptions");
            Assert.IsTrue(!searcher.hitException, "IndexSearcher hit unexpected exceptions");

            // Cleanup
            _TestUtil.RmDir(indexDir);
        }
Ejemplo n.º 2
0
        public virtual void _testStressLocks(LockFactory lockFactory, DirectoryInfo indexDir)
        {
            Directory dir = NewFSDirectory(indexDir, lockFactory);

            // First create a 1 doc index:
            IndexWriter w = new IndexWriter(dir, (new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random()))).SetOpenMode(IndexWriterConfig.OpenMode_e.CREATE));

            AddDoc(w);
            w.Dispose();

            WriterThread   writer   = new WriterThread(this, 100, dir);
            SearcherThread searcher = new SearcherThread(this, 100, dir);

            writer.Start();
            searcher.Start();

            while (writer.IsAlive || searcher.IsAlive)
            {
                Thread.Sleep(1000);
            }

            Assert.IsTrue(!writer.HitException, "IndexWriter hit unexpected exceptions");
            Assert.IsTrue(!searcher.HitException, "IndexSearcher hit unexpected exceptions");

            dir.Dispose();
            // Cleanup
            System.IO.Directory.Delete(indexDir.FullName, true);
        }
Ejemplo n.º 3
0
        public virtual void TestIsCurrentWithThreads()
        {
            Directory         dir    = NewDirectory();
            IndexWriterConfig conf   = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random));
            IndexWriter       writer = new IndexWriter(dir, conf);
            ReaderHolder      holder = new ReaderHolder();

            ReaderThread[] threads      = new ReaderThread[AtLeast(3)];
            CountdownEvent latch        = new CountdownEvent(1);
            WriterThread   writerThread = new WriterThread(holder, writer, AtLeast(500), Random, latch);

            for (int i = 0; i < threads.Length; i++)
            {
                threads[i] = new ReaderThread(holder, latch);
                threads[i].Start();
            }
            writerThread.Start();

            writerThread.Join();
            bool failed = writerThread.failed != null;

            if (failed)
            {
                Console.WriteLine(writerThread.failed.ToString());
                Console.Write(writerThread.failed.StackTrace);
            }
            for (int i = 0; i < threads.Length; i++)
            {
                threads[i].Join();
                if (threads[i].failed != null)
                {
                    Console.WriteLine(threads[i].failed.ToString());
                    Console.Write(threads[i].failed.StackTrace);
                    failed = true;
                }
            }
            Assert.IsFalse(failed);
            writer.Dispose();
            dir.Dispose();
        }
        public virtual void TestIsCurrentWithThreads()
        {
            Directory dir = NewDirectory();
            IndexWriterConfig conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random()));
            IndexWriter writer = new IndexWriter(dir, conf);
            ReaderHolder holder = new ReaderHolder();
            ReaderThread[] threads = new ReaderThread[AtLeast(3)];
            CountdownEvent latch = new CountdownEvent(1);
            WriterThread writerThread = new WriterThread(holder, writer, AtLeast(500), Random(), latch);
            for (int i = 0; i < threads.Length; i++)
            {
                threads[i] = new ReaderThread(holder, latch);
                threads[i].Start();
            }
            writerThread.Start();

            writerThread.Join();
            bool failed = writerThread.Failed != null;
            if (failed)
            {
                Console.WriteLine(writerThread.Failed.ToString());
                Console.Write(writerThread.Failed.StackTrace);
            }
            for (int i = 0; i < threads.Length; i++)
            {
                threads[i].Join();
                if (threads[i].Failed != null)
                {
                    Console.WriteLine(threads[i].Failed.ToString());
                    Console.Write(threads[i].Failed.StackTrace);
                    failed = true;
                }
            }
            Assert.IsFalse(failed);
            writer.Dispose();
            dir.Dispose();
        }
Ejemplo n.º 5
0
 /// <summary>
 /// This method will copy the file or directory represented by this
 /// <tt>SmbFile</tt> and it's sub-contents to the location specified by the
 /// <tt>dest</tt> parameter.
 /// </summary>
 /// <remarks>
 /// This method will copy the file or directory represented by this
 /// <tt>SmbFile</tt> and it's sub-contents to the location specified by the
 /// <tt>dest</tt> parameter. This file and the destination file do not
 /// need to be on the same host. This operation does not copy extended
 /// file attibutes such as ACLs but it does copy regular attributes as
 /// well as create and last write times. This method is almost twice as
 /// efficient as manually copying as it employs an additional write
 /// thread to read and write data concurrently.
 /// <p/>
 /// It is not possible (nor meaningful) to copy entire workgroups or
 /// servers.
 /// </remarks>
 /// <param name="dest">the destination file or directory</param>
 /// <exception cref="SmbException">SmbException</exception>
 /// <exception cref="SharpCifs.Smb.SmbException"></exception>
 public virtual void CopyTo(SmbFile dest)
 {
     SmbComReadAndX req;
     SmbComReadAndXResponse resp;
     WriterThread w;
     int bsize;
     byte[][] b;
     if (_share == null || dest._share == null)
     {
         throw new SmbException("Invalid operation for workgroups or servers");
     }
     req = new SmbComReadAndX();
     resp = new SmbComReadAndXResponse();
     Connect0();
     dest.Connect0();
     ResolveDfs(null);
     try
     {
         if (GetAddress().Equals(dest.GetAddress()) && _canon.RegionMatches(true, 0, dest._canon
             , 0, Math.Min(_canon.Length, dest._canon.Length)))
         {
             throw new SmbException("Source and destination paths overlap.");
         }
     }
     catch (UnknownHostException)
     {
     }
     w = new WriterThread(this);
     w.SetDaemon(true);
     w.Start();
     SmbTransport t1 = Tree.Session.transport;
     SmbTransport t2 = dest.Tree.Session.transport;
     if (t1.SndBufSize < t2.SndBufSize)
     {
         t2.SndBufSize = t1.SndBufSize;
     }
     else
     {
         t1.SndBufSize = t2.SndBufSize;
     }
     bsize = Math.Min(t1.RcvBufSize - 70, t1.SndBufSize - 70);
     b = new[] { new byte[bsize], new byte[bsize] };
     try
     {
         CopyTo0(dest, b, bsize, w, req, resp);
     }
     finally
     {
         w.Write(null, -1, null, 0);
     }
 }
Ejemplo n.º 6
0
        public virtual void _testStressLocks(LockFactory lockFactory, DirectoryInfo indexDir)
        {
            Directory dir = NewFSDirectory(indexDir, lockFactory);

            // First create a 1 doc index:
            IndexWriter w = new IndexWriter(dir, (new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random()))).SetOpenMode(IndexWriterConfig.OpenMode_e.CREATE));
            AddDoc(w);
            w.Dispose();

            WriterThread writer = new WriterThread(this, 100, dir);
            SearcherThread searcher = new SearcherThread(this, 100, dir);
            writer.Start();
            searcher.Start();

            while (writer.IsAlive || searcher.IsAlive)
            {
                Thread.Sleep(1000);
            }

            Assert.IsTrue(!writer.HitException, "IndexWriter hit unexpected exceptions");
            Assert.IsTrue(!searcher.HitException, "IndexSearcher hit unexpected exceptions");

            dir.Dispose();
            // Cleanup
            System.IO.Directory.Delete(indexDir.FullName, true);
        }
Ejemplo n.º 7
0
		public virtual void  _testStressLocks(LockFactory lockFactory, System.IO.FileInfo indexDir)
		{
			FSDirectory fs1 = FSDirectory.Open(new System.IO.DirectoryInfo(indexDir.FullName), lockFactory);
			
			// First create a 1 doc index:
			IndexWriter w = new IndexWriter(fs1, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
			AddDoc(w);
			w.Close();
			
			WriterThread writer = new WriterThread(this, 100, fs1);
			SearcherThread searcher = new SearcherThread(this, 100, fs1);
			writer.Start();
			searcher.Start();
			
			while (writer.IsAlive || searcher.IsAlive)
			{
				System.Threading.Thread.Sleep(new System.TimeSpan((System.Int64) 10000 * 1000));
			}
			
			Assert.IsTrue(!writer.hitException, "IndexWriter hit unexpected exceptions");
			Assert.IsTrue(!searcher.hitException, "IndexSearcher hit unexpected exceptions");
			
			// Cleanup
			_TestUtil.RmDir(indexDir);
		}
Ejemplo n.º 8
0
		public virtual void  _TestStressLocks(LockFactory lockFactory, System.String indexDirName)
		{
			FSDirectory fs1 = FSDirectory.GetDirectory(indexDirName, lockFactory);
			
			// First create a 1 doc index:
			IndexWriter w = new IndexWriter(fs1, new WhitespaceAnalyzer(), true);
			AddDoc(w);
			w.Close();
			
			WriterThread writer = new WriterThread(this, 100, fs1);
			SearcherThread searcher = new SearcherThread(this, 100, fs1);
			writer.Start();
			searcher.Start();
			
			while (writer.IsAlive || searcher.IsAlive)
			{
				try
				{
					System.Threading.Thread.Sleep(new System.TimeSpan((System.Int64) 10000 * 1000));
				}
				catch (System.Threading.ThreadInterruptedException)
				{
				}
			}
			
			Assert.IsTrue(!writer.hitException, "IndexWriter hit unexpected exceptions");
			Assert.IsTrue(!searcher.hitException, "IndexSearcher hit unexpected exceptions");
			
			// Cleanup
			RmDir(indexDirName);
		}