AddMergeException() private method

private AddMergeException ( MergePolicy merge ) : void
merge MergePolicy
return void
示例#1
0
            override public void  Run()
            {
                // First time through the while loop we do the merge
                // that we were started with:
                MergePolicy.OneMerge merge = this.startMerge;

                try
                {
                    Enclosing_Instance.Message("  merge thread: start");

                    while (true)
                    {
                        SetRunningMerge(merge);
                        writer.Merge(merge);

                        // Subsequent times through the loop we do any new
                        // merge that writer says is necessary:
                        merge = writer.GetNextMerge();
                        if (merge != null)
                        {
                            writer.MergeInit(merge);
                            Enclosing_Instance.Message("  merge thread: do another merge " + merge.SegString(Enclosing_Instance.dir));
                        }
                        else
                        {
                            break;
                        }
                    }

                    Enclosing_Instance.Message("  merge thread: done");
                }
                catch (System.Exception exc)
                {
                    if (merge != null)
                    {
                        merge.SetException(exc);
                        writer.AddMergeException(merge);
                    }

                    // Ignore the exception if it was due to abort:
                    if (!(exc is MergePolicy.MergeAbortedException))
                    {
                        lock (Enclosing_Instance)
                        {
                            Enclosing_Instance.exceptions.Add(exc);
                        }

                        if (!Enclosing_Instance.suppressExceptions)
                        {
                            // suppressExceptions is normally only set during
                            // testing.
                            Lucene.Net.Index.ConcurrentMergeScheduler.anyExceptions = true;
                            throw new MergePolicy.MergeException(exc);
                        }
                    }
                }
                finally
                {
                    lock (Enclosing_Instance)
                    {
                        Enclosing_Instance.mergeThreads.Remove(this);
                        System.Threading.Monitor.PulseAll(Enclosing_Instance);
                    }
                }
            }