Example #1
0
 // *****
 // Lock acquisition sequence:  RAMDirectory, then RAMFile
 // *****
 /// <summary>
 /// Constructs an empty <seealso cref="Directory"/>. </summary>
 public RAMDirectory()
 {
     try
     {
         LockFactory = new SingleInstanceLockFactory();
     }
     catch (System.IO.IOException e)
     {
         // Cannot happen
     }
 }
Example #2
0
        // *****
        // Lock acquisition sequence:  RAMDirectory, then RAMFile
        // *****

        /// <summary>
        /// Constructs an empty <seealso cref="Directory"/>. </summary>
        public RAMDirectory()
        {
            try
            {
                LockFactory = new SingleInstanceLockFactory();
            }
            catch (System.IO.IOException e)
            {
                // Cannot happen
            }
        }
Example #3
0
        public virtual void  TestFSDirectoryDifferentLockFactory()
        {
            System.IO.FileInfo indexDirName = _TestUtil.GetTempDir("index.TestLockFactory5");

            LockFactory lf  = new SingleInstanceLockFactory();
            FSDirectory fs1 = FSDirectory.GetDirectory(indexDirName, lf);

            // Different lock factory instance should hit IOException:
            try
            {
                FSDirectory.GetDirectory(indexDirName, new SingleInstanceLockFactory());
                Assert.Fail("Should have hit an IOException because LockFactory instances differ");
            }
            catch (System.IO.IOException e)
            {
            }

            FSDirectory fs2 = null;

            // Same lock factory instance should not:
            try
            {
                fs2 = FSDirectory.GetDirectory(indexDirName, lf);
            }
            catch (System.IO.IOException e)
            {
                System.Console.Out.WriteLine(e.StackTrace);
                Assert.Fail("Should not have hit an IOException because LockFactory instances are the same");
            }

            fs1.Close();
            if (fs2 != null)
            {
                fs2.Close();
            }
            // Cleanup
            _TestUtil.RmDir(indexDirName);
        }
Example #4
0
		public virtual void  TestFSDirectoryDifferentLockFactory()
		{
			System.IO.FileInfo indexDirName = _TestUtil.GetTempDir("index.TestLockFactory5");
			
			LockFactory lf = new SingleInstanceLockFactory();
			FSDirectory fs1 = FSDirectory.GetDirectory(indexDirName, lf);
			
			// Different lock factory instance should hit IOException:
			try
			{
				FSDirectory.GetDirectory(indexDirName, new SingleInstanceLockFactory());
				Assert.Fail("Should have hit an IOException because LockFactory instances differ");
			}
			catch (System.IO.IOException e)
			{
			}
			
			FSDirectory fs2 = null;
			
			// Same lock factory instance should not:
			try
			{
				fs2 = FSDirectory.GetDirectory(indexDirName, lf);
			}
			catch (System.IO.IOException e)
			{
				System.Console.Out.WriteLine(e.StackTrace);
				Assert.Fail("Should not have hit an IOException because LockFactory instances are the same");
			}
			
			fs1.Close();
			if (fs2 != null)
			{
				fs2.Close();
			}
			// Cleanup
			_TestUtil.RmDir(indexDirName);
		}