示例#1
0
        /// <summary>
        /// Returns the current most RAM consuming non-pending <see cref="ThreadState"/> with
        /// at least one indexed document.
        /// <para/>
        /// This method will never return <c>null</c>
        /// </summary>
        protected virtual ThreadState FindLargestNonPendingWriter(DocumentsWriterFlushControl control, ThreadState perThreadState)
        {
            Debug.Assert(perThreadState.dwpt.NumDocsInRAM > 0);
            long maxRamSoFar = perThreadState.bytesUsed;
            // the dwpt which needs to be flushed eventually
            ThreadState maxRamUsingThreadState = perThreadState;

            Debug.Assert(!perThreadState.flushPending, "DWPT should have flushed");
            IEnumerator <ThreadState> activePerThreadsIterator = control.AllActiveThreadStates();

            while (activePerThreadsIterator.MoveNext())
            {
                ThreadState next = activePerThreadsIterator.Current;
                if (!next.flushPending)
                {
                    long nextRam = next.bytesUsed;
                    if (nextRam > maxRamSoFar && next.dwpt.NumDocsInRAM > 0)
                    {
                        maxRamSoFar            = nextRam;
                        maxRamUsingThreadState = next;
                    }
                }
            }
            Debug.Assert(AssertMessage("set largest ram consuming thread pending on lower watermark"));
            return(maxRamUsingThreadState);
        }
示例#2
0
        internal virtual void AssertActiveBytesAfter(DocumentsWriterFlushControl flushControl)
        {
            IEnumerator <ThreadState> allActiveThreads = flushControl.AllActiveThreadStates();
            long bytesUsed = 0;

            while (allActiveThreads.MoveNext())
            {
                ThreadState next = allActiveThreads.Current;
                if (next.DocumentsWriterPerThread != null)
                {
                    bytesUsed += next.DocumentsWriterPerThread.BytesUsed;
                }
            }
            Assert.AreEqual(bytesUsed, flushControl.ActiveBytes);
        }
示例#3
0
        internal static void FindPending(DocumentsWriterFlushControl flushControl, List <ThreadState> pending, List <ThreadState> notPending)
        {
            IEnumerator <ThreadState> allActiveThreads = flushControl.AllActiveThreadStates();

            while (allActiveThreads.MoveNext())
            {
                ThreadState next = allActiveThreads.Current;
                if (next.IsFlushPending)
                {
                    pending.Add(next);
                }
                else
                {
                    notPending.Add(next);
                }
            }
        }