Example #1
0
 public IndexManager(IDataStore dataStore, ISearchManager searchManager)
 {
     _dataStore     = dataStore;
     _searchManager = searchManager;
     DistributedIndexingActivityQueue = new DistributedIndexingActivityQueue(this);
     CentralizedIndexingActivityQueue = new CentralizedIndexingActivityQueue();
 }
Example #2
0
        /// <summary>
        /// Generates a history from the recent items.
        /// </summary>
        /// <returns></returns>
        public static IndexingActivityHistory GetHistory()
        {
            IndexingActivityHistory result;
            var list = new List <IndexingActivityHistoryItem>(History.Length);

            lock (Lock)
            {
                for (int i = _position; i < History.Length; i++)
                {
                    if (History[i] != null)
                    {
                        list.Add(History[i]);
                    }
                }
                for (int i = 0; i < _position; i++)
                {
                    if (History[i] != null)
                    {
                        list.Add(History[i]);
                    }
                }

                result = new IndexingActivityHistory()
                {
                    State  = DistributedIndexingActivityQueue.GetCurrentState(),
                    Recent = list.ToArray()
                };
            }
            return(result);
        }
 internal Serializer(DistributedIndexingActivityQueue activityQueue,
                     DependencyManager dependencyManager,
                     TerminationHistory terminationHistory,
                     IndexingActivityHistoryController activityHistory
                     , IndexManager indexManager)
 {
     _activityQueue      = activityQueue;
     _dependencyManager  = dependencyManager;
     _terminationHistory = terminationHistory;
     _activityHistory    = activityHistory;
     _indexManager       = indexManager;
 }
Example #4
0
        private static async STT.Task ExecuteDistributedActivityAsync(IndexingActivityBase activity, CancellationToken cancellationToken)
        {
            SnTrace.Index.Write("ExecuteDistributedActivity: #{0}", activity.Id);
            await activity.DistributeAsync(cancellationToken).ConfigureAwait(false);

            // 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 (DistributedIndexingActivityQueue.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
            DistributedIndexingActivityQueue.ExecuteActivity(activity);

            await activity.WaitForCompleteAsync(cancellationToken).ConfigureAwait(false);
        }
Example #5
0
 // for testing purposes we need a parameterless method because ElapsedEventArgs has only internal constructor
 private static void Timer_Elapsed()
 {
     if (SearchManager.ContentQueryIsAllowed)
     {
         var timerEnabled = _timer.Enabled;
         _timer.Enabled = false;
         try
         {
             DistributedIndexingActivityQueue.HealthCheck();
         }
         catch (Exception ex) // logged
         {
             SnLog.WriteException(ex);
         }
         finally
         {
             _timer.Enabled = timerEnabled;
         }
     }
 }
Example #6
0
        /// <summary>
        /// Initializes the indexing feature: starts the IndexingEngine, CommitManager and indexing activity organizer.
        /// If "consoleOut" is not null, writes progress and debug messages into it.
        /// </summary>
        /// <param name="consoleOut">A <see cref="TextWriter"/> instance or null.</param>
        /// <param name="cancellationToken">The token to monitor for cancellation requests. The default value is None.</param>
        /// <returns>A Task that represents the asynchronous operation.</returns>
        public static async STT.Task StartAsync(TextWriter consoleOut, CancellationToken cancellationToken)
        {
            await IndexingEngine.StartAsync(consoleOut, cancellationToken).ConfigureAwait(false);

            CommitManager = IndexingEngine.IndexIsCentralized
                ? (ICommitManager) new NoDelayCommitManager()
                : new NearRealTimeCommitManager();

            SnTrace.Index.Write("LM: {0} created.", CommitManager.GetType().Name);

            CommitManager.Start();

            if (IndexingEngine.IndexIsCentralized)
            {
                CentralizedIndexingActivityQueue.Startup(consoleOut);
            }
            else
            {
                DistributedIndexingActivityQueue.Startup(consoleOut);
            }
        }
Example #7
0
        /// <summary>
        /// Shuts down the indexing feature: stops CommitManager, indexing activity organizator and IndexingEngine.
        /// </summary>
        public static void ShutDown()
        {
            CommitManager?.ShutDown();

            if (IndexingEngine == null)
            {
                return;
            }

            if (IndexingEngine.IndexIsCentralized)
            {
                CentralizedIndexingActivityQueue.ShutDown();
            }
            else
            {
                DistributedIndexingActivityQueue.ShutDown();
            }

            IndexingEngine.ShutDown();
            SnLog.WriteInformation("Indexing engine has stopped. Max task id and exceptions: " + DistributedIndexingActivityQueue.GetCurrentCompletionState());
        }
Example #8
0
        /// <summary>
        /// Initializes the indexing feature: starts the IndexingEngine, CommitManager and indexing activity organizator.
        /// If "consoleOut" is not null, writes progress and debug messages into it.
        /// </summary>
        /// <param name="consoleOut">A <see cref="TextWriter"/> instance or null.</param>
        public static void Start(TextWriter consoleOut)
        {
            IndexingEngine.Start(consoleOut);

            CommitManager = IndexingEngine.IndexIsCentralized
                ? (ICommitManager) new NoDelayCommitManager()
                : new NearRealTimeCommitManager();

            SnTrace.Index.Write("LM: {0} created.", CommitManager.GetType().Name);

            CommitManager.Start();

            if (IndexingEngine.IndexIsCentralized)
            {
                CentralizedIndexingActivityQueue.Startup(consoleOut);
            }
            else
            {
                DistributedIndexingActivityQueue.Startup(consoleOut);
            }
        }
Example #9
0
        /// <summary>
        /// Resets the history and returns with the starting state.
        /// </summary>
        public static IndexingActivityHistory Reset()
        {
            IndexingActivityHistory result;

            lock (Lock)
            {
                for (int i = 0; i < History.Length; i++)
                {
                    History[i] = null;
                }

                _position   = 0;
                _unfinished = 0;

                result = new IndexingActivityHistory()
                {
                    State  = DistributedIndexingActivityQueue.GetCurrentState(),
                    Recent = new IndexingActivityHistoryItem[0]
                };
            }
            return(result);
        }
Example #10
0
        public void ShutDown()
        {
            CommitManager?.ShutDown();

            if (IndexingEngine == null)
            {
                return;
            }

            //TODO: [async] rewrite this using async APIs.
            if (IndexingEngine.IndexIsCentralized)
            {
                CentralizedIndexingActivityQueue.ShutDown();
            }
            else
            {
                DistributedIndexingActivityQueue.ShutDown();
            }

            //TODO: [async] rewrite this using async APIs.
            IndexingEngine.ShutDownAsync(CancellationToken.None).GetAwaiter().GetResult();
            SnLog.WriteInformation("Indexing engine has stopped. Max task id and exceptions: " + DistributedIndexingActivityQueue.GetCurrentCompletionState());
        }
Example #11
0
 public IndexingActivityStatus GetCurrentIndexingActivityStatus()
 {
     return(DistributedIndexingActivityQueue.GetCurrentCompletionState());
 }
 public IndexingActivityHistoryController(DistributedIndexingActivityQueue activityQueue)
 {
     _activityQueue = activityQueue;
 }