Beispiel #1
0
        public static void ExecuteActivity(LuceneIndexingActivity activity, bool waitForComplete, bool distribute)
        {
            if (distribute)
            {
                activity.Distribute();
            }

            // If there are too many activities in the queue, we have to drop at least the inner
            // data of the activity to prevent memory overflow. We still have to wait for the
            // activity to finish, but the inner data can (and will) be loaded from the db when
            // the time comes for this activity to be executed.
            if (IndexingActivityQueue.IsOverloaded())
            {
                SnTrace.Index.Write("IAQ OVERLOAD drop activity FromPopulator A:" + activity.Id);
                activity.IndexDocumentData = null;
            }

            // all activities must be executed through the activity queue's API
            IndexingActivityQueue.ExecuteActivity(activity);

            if (waitForComplete)
            {
                activity.WaitForComplete();
            }
        }
Beispiel #2
0
        internal static void HealthCheck()
        {
            if (IsWorking())
            {
                SnTrace.Index.Write("IAQ: Health check triggered but ignored.");

                return;
            }

            SnTrace.Index.Write("IAQ: Health check triggered.");


            var state      = TerminationHistory.GetCurrentState();
            var gapsLength = state.Gaps.Length;

            if (gapsLength > 0)
            {
                SnTrace.IndexQueue.Write("IAQ: Health checker is processing {0} gap{1}.", gapsLength, gapsLength > 1 ? "s" : "");

                foreach (LuceneIndexingActivity activity in new IndexingActivityLoader(state.Gaps, false))
                {
                    WaitIfOverloaded();
                    IndexingActivityQueue.ExecuteActivity(activity);
                }
            }

            var lastId     = TerminationHistory.GetLastTerminatedId();
            var lastDbId   = LuceneManager.GetLastStoredIndexingActivityId();
            var newerCount = lastDbId - lastId;

            if (lastId < lastDbId)
            {
                SnTrace.IndexQueue.Write("IAQ: Health checker is processing activities from {0} to {1}", (lastId + 1), lastDbId);

                foreach (LuceneIndexingActivity activity in new IndexingActivityLoader(lastId + 1, lastDbId, false))
                {
                    WaitIfOverloaded();
                    IndexingActivityQueue.ExecuteActivity(activity);
                }
            }
        }