GetUnprocessedActivities() public static method

public static GetUnprocessedActivities ( IEnumerable missingActivities ) : SenseNet.Search.Indexing.IndexingActivity[]
missingActivities IEnumerable
return SenseNet.Search.Indexing.IndexingActivity[]
Ejemplo n.º 1
0
        internal static void ExecuteLostIndexingActivities()
        {
            lock (_executingUnprocessedIndexingActivitiesLock)
            {
                var gap = MissingActivityHandler.GetOldestGapAndMoveToNext();

                var i = 0;
                while (i * ACTIVITIESFRAGMENTSIZE < gap.Length)
                {
                    var gapSegment = gap.Skip(i * ACTIVITIESFRAGMENTSIZE).Take(ACTIVITIESFRAGMENTSIZE).ToArray();

                    var activities = IndexingActivityManager.GetUnprocessedActivities(gapSegment);
                    if (activities.Length > 0)
                    {
                        foreach (var act in activities)
                        {
                            act.FromHealthMonitor = true;
                            IndexingActivityManager.ExecuteActivity(act, false, false);
                        }
                    }
                    i++;
                }
            }
        }
Ejemplo n.º 2
0
        //---- Caller: Startup, ForceRestore
        internal static void ExecuteUnprocessedIndexingActivities(System.IO.TextWriter consoleOut)
        {
            lock (_executingUnprocessedIndexingActivitiesLock)
            {
                try
                {
                    _executingUnprocessedIndexingActivities = true;

                    CommitUserData cud;
                    using (var readerFrame = LuceneManager.GetIndexReaderFrame())
                    {
                        cud = IndexManager.ReadCommitUserData(readerFrame.IndexReader);
                    }
                    MissingActivityHandler.MaxActivityId = cud.LastActivityId;
                    MissingActivityHandler.SetGap(cud.Gap);

                    var logProps = new Dictionary <string, object> {
                        { "LastActivityID", cud.LastActivityId }, { "Size of gap", cud.Gap.Count }
                    };
                    Logger.WriteInformation("Executing unprocessed indexing activities from the stored commit point.",
                                            Logger.EmptyCategoryList, logProps);

                    var i        = 0;
                    var sumCount = 0;

                    // This loop was created to avoid loading too many activities at once that are present in the gap.
                    while (i * ACTIVITIESFRAGMENTSIZE <= cud.Gap.Count)
                    {
                        // get activities from the DB that are in the current gap fragment
                        var gapSegment = cud.Gap.Skip(i * ACTIVITIESFRAGMENTSIZE).Take(ACTIVITIESFRAGMENTSIZE).ToArray();
                        var activities = IndexingActivityManager.GetUnprocessedActivities(gapSegment);
                        ProcessTasks(activities, consoleOut);
                        sumCount += activities.Length;
                        i++;
                    }

                    // Execute activities where activity id is bigger than than our last (activity) task id
                    var maxIdInDb = 0;
                    var newtasks  = IndexingActivityManager.GetUnprocessedActivities(MissingActivityHandler.MaxActivityId, out maxIdInDb, ACTIVITIESFRAGMENTSIZE);
                    while (newtasks.Length > 0)
                    {
                        ProcessTasks(newtasks, consoleOut);
                        sumCount += newtasks.Length;

                        //load the remaining activities, but only if they were created before this operation started
                        var tempMax = 0;
                        newtasks = IndexingActivityManager.GetUnprocessedActivities(MissingActivityHandler.MaxActivityId, out tempMax, ACTIVITIESFRAGMENTSIZE, maxIdInDb);
                    }

                    if (consoleOut != null)
                    {
                        consoleOut.WriteLine("ok.");
                    }

                    logProps.Add("Processed tasks", sumCount);

                    //write the latest max activity id and gap size to log
                    logProps["LastActivityID"] = MissingActivityHandler.MaxActivityId;
                    logProps["Size of gap"]    = MissingActivityHandler.GetGap().Count;

                    Logger.WriteInformation("Executing unprocessed tasks is finished.", Logger.EmptyCategoryList, logProps);
                }
                finally
                {
                    _executingUnprocessedIndexingActivities = false;
                }
            }
        }