Пример #1
0
        private static STT.Task ExecuteCentralizedActivityAsync(IndexingActivityBase activity, CancellationToken cancellationToken)
        {
            SnTrace.Index.Write("ExecuteCentralizedActivity: #{0}", activity.Id);
            CentralizedIndexingActivityQueue.ExecuteActivity(activity);

            return(activity.WaitForCompleteAsync(cancellationToken));
        }
Пример #2
0
 public IndexManager(IDataStore dataStore, ISearchManager searchManager)
 {
     _dataStore     = dataStore;
     _searchManager = searchManager;
     DistributedIndexingActivityQueue = new DistributedIndexingActivityQueue(this);
     CentralizedIndexingActivityQueue = new CentralizedIndexingActivityQueue();
 }
Пример #3
0
        private static void ExecuteCentralizedActivity(IndexingActivityBase activity)
        {
            SnTrace.Index.Write("ExecuteCentralizedActivity: #{0}", activity.Id);
            CentralizedIndexingActivityQueue.ExecuteActivity(activity);

            activity.WaitForComplete();
        }
Пример #4
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);
            }
        }
Пример #5
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());
        }
Пример #6
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);
            }
        }
Пример #7
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());
        }