コード例 #1
0
ファイル: IndexReader.cs プロジェクト: raj581/Marvin
 /// <summary> Commit changes resulting from delete, undeleteAll, or setNorm operations
 ///
 /// </summary>
 /// <throws>  IOException </throws>
 protected internal void  Commit()
 {
     lock (this)
     {
         if (hasChanges)
         {
             if (directoryOwner)
             {
                 lock (directory)
                 {
                     // in- & inter-process sync
                     new AnonymousClassWith1(this, directory.MakeLock(IndexWriter.COMMIT_LOCK_NAME), IndexWriter.COMMIT_LOCK_TIMEOUT).Run();
                 }
                 if (writeLock != null)
                 {
                     writeLock.Release();                             // release write lock
                     writeLock = null;
                 }
             }
             else
             {
                 DoCommit();
             }
         }
         hasChanges = false;
     }
 }
コード例 #2
0
ファイル: IndexReader.cs プロジェクト: raj581/Marvin
        /// <summary> Trys to acquire the WriteLock on this directory.
        /// this method is only valid if this IndexReader is directory owner.
        ///
        /// </summary>
        /// <throws>  IOException If WriteLock cannot be acquired. </throws>
        private void  AquireWriteLock()
        {
            if (stale)
            {
                throw new System.IO.IOException("IndexReader out of date and no longer valid for delete, undelete, or setNorm operations");
            }

            if (this.writeLock == null)
            {
                Lock writeLock = directory.MakeLock(IndexWriter.WRITE_LOCK_NAME);
                if (!writeLock.Obtain(IndexWriter.WRITE_LOCK_TIMEOUT))
                // obtain write lock
                {
                    throw new System.IO.IOException("Index locked for write: " + writeLock);
                }
                this.writeLock = writeLock;

                // we have to check whether index has changed since this reader was opened.
                // if so, this reader is no longer valid for deletion
                if (SegmentInfos.ReadCurrentVersion(directory) > segmentInfos.GetVersion())
                {
                    stale = true;
                    this.writeLock.Release();
                    this.writeLock = null;
                    throw new System.IO.IOException("IndexReader out of date and no longer valid for delete, undelete, or setNorm operations");
                }
            }
        }
コード例 #3
0
 /// <summary>Flushes all changes to an index and closes all associated files. </summary>
 public virtual void  Close()
 {
     lock (this)
     {
         FlushRamSegments();
         ramDirectory.Close();
         writeLock.Release(); // release write lock
         writeLock = null;
         if (closeDir)
         {
             directory.Close();
         }
         System.GC.SuppressFinalize(this);
     }
 }
コード例 #4
0
        private IndexWriter(Directory d, Analyzer a, bool create, bool closeDir)
        {
            InitBlock();
            this.closeDir = closeDir;
            directory     = d;
            analyzer      = a;

            Lock writeLock = directory.MakeLock(IndexWriter.WRITE_LOCK_NAME);

            if (!writeLock.Obtain(WRITE_LOCK_TIMEOUT))
            // obtain write lock
            {
                throw new System.IO.IOException("Index locked for write: " + writeLock);
            }
            this.writeLock = writeLock; // save it

            lock (directory)
            {
                // in- & inter-process sync
                new AnonymousClassWith(create, this, directory.MakeLock(IndexWriter.COMMIT_LOCK_NAME), COMMIT_LOCK_TIMEOUT).Run();
            }
        }
コード例 #5
0
ファイル: IndexReader.cs プロジェクト: emtees/old-code
		/// <summary> Commit changes resulting from delete, undeleteAll, or setNorm operations
		/// 
		/// </summary>
		/// <throws>  IOException </throws>
		protected internal void  Commit()
		{
			lock (this)
			{
				if (hasChanges)
				{
					if (directoryOwner)
					{
						lock (directory)
						{
							// in- & inter-process sync
							new AnonymousClassWith1(this, directory.MakeLock(IndexWriter.COMMIT_LOCK_NAME), IndexWriter.COMMIT_LOCK_TIMEOUT).Run();
						}
						if (writeLock != null)
						{
							writeLock.Release(); // release write lock
							writeLock = null;
						}
					}
					else
						DoCommit();
				}
				hasChanges = false;
			}
		}
コード例 #6
0
ファイル: IndexReader.cs プロジェクト: emtees/old-code
		/// <summary> Trys to acquire the WriteLock on this directory.
		/// this method is only valid if this IndexReader is directory owner.
		/// 
		/// </summary>
		/// <throws>  IOException If WriteLock cannot be acquired. </throws>
		private void  AquireWriteLock()
		{
			if (stale)
				throw new System.IO.IOException("IndexReader out of date and no longer valid for delete, undelete, or setNorm operations");
			
			if (this.writeLock == null)
			{
				Lock writeLock = directory.MakeLock(IndexWriter.WRITE_LOCK_NAME);
				if (!writeLock.Obtain(IndexWriter.WRITE_LOCK_TIMEOUT))
				// obtain write lock
				{
					throw new System.IO.IOException("Index locked for write: " + writeLock);
				}
				this.writeLock = writeLock;
				
				// we have to check whether index has changed since this reader was opened.
				// if so, this reader is no longer valid for deletion
				if (SegmentInfos.ReadCurrentVersion(directory) > segmentInfos.GetVersion())
				{
					stale = true;
					this.writeLock.Release();
					this.writeLock = null;
					throw new System.IO.IOException("IndexReader out of date and no longer valid for delete, undelete, or setNorm operations");
				}
			}
		}
コード例 #7
0
		/// <summary>Flushes all changes to an index and closes all associated files. </summary>
		public virtual void  Close()
		{
			lock (this)
			{
				FlushRamSegments();
				ramDirectory.Close();
				writeLock.Release(); // release write lock
				writeLock = null;
				if (closeDir)
					directory.Close();
				System.GC.SuppressFinalize(this);
			}
		}
コード例 #8
0
		private IndexWriter(Directory d, Analyzer a, bool create, bool closeDir)
		{
			InitBlock();
			this.closeDir = closeDir;
			directory = d;
			analyzer = a;
			
			Lock writeLock = directory.MakeLock(IndexWriter.WRITE_LOCK_NAME);
			if (!writeLock.Obtain(WRITE_LOCK_TIMEOUT))
			// obtain write lock
			{
				throw new System.IO.IOException("Index locked for write: " + writeLock);
			}
			this.writeLock = writeLock; // save it
			
			lock (directory)
			{
				// in- & inter-process sync
				new AnonymousClassWith(create, this, directory.MakeLock(IndexWriter.COMMIT_LOCK_NAME), COMMIT_LOCK_TIMEOUT).Run();
			}
		}