Ejemplo n.º 1
0
        public override void DoAction(bool onRemote, bool isFromMe)
        {
            if (!LuceneManager.Running)
            {
                return;
            }

            if (onRemote && !isFromMe)
            {
                //TODO: Remove unnecessary inheritance steps.
                var luceneIndexingActivity = this as LuceneIndexingActivity;
                if (luceneIndexingActivity != null)
                {
                    // We can drop activities here because the queue will load these from the database
                    // anyway when it processed all the previous activities.
                    if (IndexingActivityQueue.IsOverloaded())
                    {
                        SnTrace.Index.Write("IAQ OVERLOAD drop activity FromReceiver A:" + luceneIndexingActivity.Id);
                        return;
                    }

                    luceneIndexingActivity.FromReceiver = true;

                    IndexingActivityQueue.ExecuteActivity(luceneIndexingActivity);
                }
                else
                {
                    this.InternalExecuteIndexingActivity();
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Waits for a release signal that indicates that this activity has been executed
        /// successfully in the background.
        /// </summary>
        public void WaitForComplete()
        {
            if (_finished)
            {
                return;
            }

            _waitingThreadId = Thread.CurrentThread.ManagedThreadId;

            var indexingActivity = this as LuceneIndexingActivity;

            SnTrace.IndexQueue.Write("IAQ: A{0} blocks the T{1}", indexingActivity.Id, _waitingThreadId);

            if (Debugger.IsAttached)
            {
                _finishSignal.WaitOne();
            }
            else
            {
                if (!_finishSignal.WaitOne(SenseNet.Configuration.Indexing.LuceneActivityTimeoutInSeconds * 1000, false))
                {
                    string message;

                    if (indexingActivity != null)
                    {
                        message = string.Format("IndexingActivity is timed out. Id: {0}, Type: {1}. Max task id and exceptions: {2}"
                                                , indexingActivity.Id, indexingActivity.ActivityType, IndexingActivityQueue.GetCurrentCompletionState());
                    }
                    else
                    {
                        message = "Activity is not finishing on a timely manner";
                    }

                    throw new ApplicationException(message);
                }
            }
        }